• Select_sex.lua PERP -.-
    6 replies, posted
So here's the error: [gamemodes\perp\gamemode\vgui\select_sex.lua:28] attempt to concatenate field '?' (a nil value) This error happens when you join the server and is going to choose face (sex) I tried almost everything (i think) is the code just too old, cause I can't figure out what's wrong with it... And yes I tried searching if anyone had the same problem, that was a no go. [lua] local Models = {}; for k, v in pairs(file.Find('../models/players/humans/group01/clo1*.mdl')) do table.insert(Models, v); end function GM.Select_Sex ( ) local W, H = 256, 256; local DermaPanel = vgui.Create("DPanel") DermaPanel:SetPos(0, 0) DermaPanel:SetSize(ScrW(), ScrH()) function DermaPanel:Paint ( ) Derma_DrawBackgroundBlur( self, self.m_fCreateTime ) Derma_DrawBackgroundBlur( self, self.m_fCreateTime ) return true end local SEX_M = vgui.Create("DPanel", DermaPanel) SEX_M:SetPos(ScrW() * .5 - W * .5, ScrH() * .5 - H * .5) SEX_M:SetSize(W, H) local SELECT_SEX = vgui.Create("perp_select_sex_label", DermaPanel) SELECT_SEX:SetPos(ScrW() * .5 - W * .5, ScrH() * .5 - H * .85) SELECT_SEX:SetSize(W, H * .25) // Male Model local Position = 1; local ModelPanel = vgui.Create('DModelPanel', DermaPanel); ModelPanel:SetModel('models/players/humans/group01/' .. Models[1]); ModelPanel:SetPos(ScrW() * .5 - W * .5, ScrH() * .5 - H * .5); ModelPanel:SetSize(W, H); ModelPanel:SetFOV(70) ModelPanel:SetCamPos(Vector(14, 0, 60)) ModelPanel:SetLookAt(Vector(-1, 0, 64)) function ModelPanel:LayoutEntity( Entity ) end local iSeq = ModelPanel.Entity:LookupSequence('ragdoll'); ModelPanel.Entity:ResetSequence(iSeq); local W2, H2 = 64, 64; local ForwardButton = vgui.Create('DButton', DermaPanel); ForwardButton:SetSize(W2, H2); ForwardButton:SetPos(ScrW() * .5 + W * .6, ScrH() * .5 - H2 * .5); ForwardButton:SetText(">"); local BackButton = vgui.Create('DButton', DermaPanel); BackButton:SetSize(W2, H2); BackButton:SetPos(ScrW() * .5 - W * .6 - W2, ScrH() * .5 - H2 * .5); BackButton:SetText("<"); BackButton:SetEnabled(false); function BackButton.DoClick ( ) if Position != 1 then Position = Position - 1 ModelPanel:SetModel('models/players/humans/group01/' .. Models[Position]); if string.find(Models[Position], 'fe') then ModelPanel:SetCamPos(Vector(14, 0, 60)) ModelPanel:SetLookAt(Vector(-1, 0, 64)) ModelPanel:SetFOV(70) else ModelPanel:SetCamPos(Vector(14, 0, 62)) ModelPanel:SetLookAt(Vector(-1, 0, 66)) ModelPanel:SetFOV(70) end if Position == 1 then BackButton:SetEnabled(false); else ForwardButton:SetEnabled(true); end end end function ForwardButton.DoClick ( ) if Position != #Models then Position = Position + 1 ModelPanel:SetModel('models/players/humans/group01/' .. Models[Position]); if string.find(Models[Position], 'fe') then ModelPanel:SetCamPos(Vector(14, 0, 60)) ModelPanel:SetLookAt(Vector(-1, 0, 64)) ModelPanel:SetFOV(70) else ModelPanel:SetCamPos(Vector(14, 0, 62)) ModelPanel:SetLookAt(Vector(-1, 0, 66)) ModelPanel:SetFOV(70) end if Position == #Models then ForwardButton:SetEnabled(false); else BackButton:SetEnabled(true); end end end local W3, H3 = 128, 32; local ConfirmButton = vgui.Create('DButton', DermaPanel); ConfirmButton:SetSize(W3, H3); ConfirmButton:SetPos(ScrW() * .5 - W3 * .5, ScrH() * .5 + H * .6); ConfirmButton:SetText("Confirm Selection"); function ConfirmButton.DoClick ( ) RunConsoleCommand('perp_sm', Models[Position]); DermaPanel:Remove(); end DermaPanel:MakePopup() end [/lua]
Try replacing this line [lua]ModelPanel:SetModel('models/players/humans/group01/' .. Models[1]);[/lua] with this line [lua]ModelPanel:SetModel(Model('models/players/humans/group01/' .. Models[1]));[/lua]
Wrong, on the second line, change: [lua] for k, v in pairs(file.Find('../models/players/humans/group01/clo1*.mdl')) do table.insert(Models, v); end [/lua] To: [lua] for k, v in pairs(file.Find('models/players/humans/group01/clo1*.mdl', true)) do table.insert(Models, v); end; [/lua]
Lua isn't finding ../models/players/humans/group01/clo1*.mdl, so I'm going to assume you're missing those models
It can't find it because it isn't using the base folder, that is what the second argument is for.
[QUOTE=Helix Alioth;34583839]Lua isn't finding ../models/players/humans/group01/clo1*.mdl, so I'm going to assume you're missing those models[/QUOTE] No, the models ain't missing :-) Chessnut: I already tried using that line, from here: [url]http://www.facepunch.com/threads/1152473?highlight=select_sex[/url] - But thanks anyway :-) Hyper: I'll try yours when I get home, thank you guys :)
omfg.... Chessnut! I just tried your fix, it actually worked?!
Sorry, you need to Log In to post a reply to this thread.