• Fretta Playermodels.
    9 replies, posted
So basically i have [lua] ply = LocalPlayer() if ply:IsUserGroup("owner") then CLASS.PlayerModel = "models/player/barney.mdl" elseif ply:IsUserGroup("superadmin") then CLASS.PlayerModel = "models/player/combine_super_soldier.mdl" elseif ply:IsUserGroup("admin") then CLASS.PlayerModel = "models/player/combine_soldier.mdl" else CLASS.PlayerModel = "models/player/classic.mdl" end [/lua] In my class_teamone.lua for my gamemode but i get [lua][deathrun\gamemode\player_class\class_runner.lua:14] attempt to call method 'IsUserGroup' (a nil value)[/lua] I can see i've done something wrong and have tried multiple times, but i'm missing the obvious, can someone help me please.
Pretty sure the class files are executed before the players even connect, so thus, you'd need to do it in a playerspawn, or playerloadout hook.
And what would i add to those files?
Use something like this in a server-side lua file of the gamemode, such as init.lua: [lua] function GM:PlayerSetModel( ply ) if ply:Team() == YOUR_TEAM_NAME_FOR_THAT_CLASS if ply:IsUserGroup("owner") then ply:SetModel("models/player/barney.mdl") elseif ply:IsUserGroup("superadmin") then ply:SetModel("models/player/combine_super_soldier.mdl") elseif ply:IsUserGroup("admin") then ply:SetModel("models/player/combine_soldier.mdl") else ply:SetModel("models/player/classic.mdl") end end [/lua] Pretty sure that'd work, although not too sure with how Fretta handles that, so may need to use another hook such as PlayerLoadout.
Ok i tried adding that to my init and it made the gamemode run as Base Gamemode [editline]17th March 2011[/editline] As does PlayLoadout [editline]17th March 2011[/editline] PlayerLoadout*
The only reason it should run base is if you have a syntax error in your gamemode. Paste the code back into your init.lua and check your console for any errors. Just realised a forgot an "end" in that code above, so try adding that in, like so: [lua] function GM:PlayerSetModel( ply ) if ply:Team() == YOUR_TEAM_NAME_FOR_THAT_CLASS if ply:IsUserGroup("owner") then ply:SetModel("models/player/barney.mdl") elseif ply:IsUserGroup("superadmin") then ply:SetModel("models/player/combine_super_soldier.mdl") elseif ply:IsUserGroup("admin") then ply:SetModel("models/player/combine_soldier.mdl") else ply:SetModel("models/player/classic.mdl") end end end [/lua]
Still giving me base gamemode. It works if i remove this code though.
[QUOTE=jimbodude;28650138]The only reason it should run base is if you have a syntax error in your gamemode. Paste the code back into your init.lua and check your console for any errors. [/QUOTE]
Yeah it just tells me cl_init is missing, i remove those lines of code and it works fine.
Works now, was missing an if, doh. [lua] function GM:PlayerSetModel( ply ) if ply:Team() == TEAM_RUN then if ply:IsUserGroup("owner") then ply:SetModel("models/player/barney.mdl") elseif ply:IsUserGroup("superadmin") then ply:SetModel("models/player/combine_super_soldier.mdl") elseif ply:IsUserGroup("admin") then ply:SetModel("models/player/combine_soldier.mdl") elseif ply:Team() == TEAM_DEATH then ply:SetModel("models/player/death.mdl") else ply:SetModel("models/player/classic.mdl") end end end [/lua]
Sorry, you need to Log In to post a reply to this thread.