• SetModel() Not working on Player Models
    10 replies, posted
I'm trying to get work [lua] hook.Add("PlayerSpawn","SPAWNER",function(ply) Msg(ply:GetModel()) ply:SetModel("models/player/barney.mdl") Msg(ply:GetModel()) end) [/lua] When i spawn in the console show (please ignore the mayus and minus on the path) [code] "models/player.mdl" "models/player/barney.mdl" [/code] Nothing happend... (i'm using hooks and thinks hooks but nothing happen) I've problems on gmod 13 and gmod....and nothing works...
[lua] util.PrecacheModel( "models/player/odessa.mdl" ) function GM:PlayerSetModel( ply ) ply:SetModel( "models/player/odessa.mdl" ) end [/lua] [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index99a5.html?title=Gamemode.PlayerSetModel"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index99a5.html?title=Gamemode.PlayerSetModel[/URL]
[QUOTE=brandonj4;35156440][lua] util.PrecacheModel( "models/player/odessa.mdl" ) function GM:PlayerSetModel( ply ) ply:SetModel( "models/player/odessa.mdl" ) end [/lua] [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index99a5.html?title=Gamemode.PlayerSetModel"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index99a5.html?title=Gamemode.PlayerSetModel[/URL][/QUOTE] doesn't work...
Are you putting this in Init? It works for me.
nope,am putting this on a shared file...so you are saying of that are just a Serverside Code? Ok i will try I don't are creating a gamemode...am making simple codes for sandbox
Is it a Server or Client side error?
[QUOTE=Remscar;35157995]Is it a Server or Client side error?[/QUOTE] just...don't show up the new model :/
[QUOTE=gonzalolog;35158151]just...don't show up the new model :/[/QUOTE] So it doesn't set the model of the entity? Can i see the code your using? If its the code in the OP, then is this on your server or client?
This goes into init.lua NOT SHARED.LUA [lua] util.PrecacheModel( "models/player/odessa.mdl" ) function GM:PlayerSetModel( ply ) ply:SetModel( "models/player/odessa.mdl" ) end [/lua] Its serverside when you change a playermodel. You should maybe check out some tutorials on the wiki.
[Lua] if SERVER then function team_check( ply, command,args ) argument = table.GetFirstValue(args) if argument == "1" then ply:SetNWString("MODELO",Modelos_Comb[math.random(1,3)]) ply:SetNWInt("TEAM",1) end if argument == "2" then ply:SetNWString("MODELO","models/player/group03/male_0"..math.random(1,9)) ply:SetModel(ply:GetNWString("MODELO")) ply:SetNWInt("TEAM",2) end if argument == "3" then ply:SetNWString("MODELO",Modelos_CSS[math.random(1,4)]) ply:SetModel(ply:GetNWString("MODELO")) ply:SetNWInt("TEAM",3) end if argument == "4" then ply:SetNWString("MODELO",Modelos_TT[math.random(1,4)]) ply:SetModel(ply:GetNWString("MODELO")) ply:SetNWInt("TEAM",4) end if argument == "5" then ply:SetNWInt("TEAM",5) end end concommand.Add( "team_select_number", team_check ) Modelos_CSS = {} Modelos_CSS[1] = "models/player/swat.mdl" Modelos_CSS[2] = "models/Player/urban.mdl" Modelos_CSS[3] = "models/player/police.mdl" Modelos_CSS[4] = "models/player/gasmask.mdl" Modelos_TT = {} Modelos_TT[1] = "models/player/artic.mdl" Modelos_TT[2] = "models/player/guerilla.mdl" Modelos_TT[3] = "models/player/leet.mdl" Modelos_TT[4] = "models/player/Phoenix.mdl" Modelos_Comb = {} Modelos_Comb[1] = ("models/Player/combine_soldier.mdl") Modelos_Comb[2] = ("models/Player/combine_soldier_prisonguard.mdl") Modelos_Comb[3] = ("models/Player/combine_super_soldier.mdl") [/lua] Printing ply:GetNWInt("TEAM") return the team...but don't change the model I don't have a "Init" file, i just have the file like a autorun file
It's possible your gamemode is overriding this in GM:PlayerLoadout
Sorry, you need to Log In to post a reply to this thread.