Hello! So I’ve got a (probably) simple issue with a custom spawn script I’m making.
I’m adding a custom script that on spawn, the user is stripped of weapons, has their model set, and their “Color” adjusted.
Here is the code:
hook.Add( "PlayerSpawn", "SetTeam", function(ply) current = ply:GetNWString(ply:UserID() .. "_CurrentTeam") if current == "spectator" then ply:StripWeapons() ply:PrintMessage(HUD_PRINTCONSOLE, "Team spawned as: " .. current .. " Player Name: " .. ply:Nick()) ply:SetModel("models/hunter/blocks/cube025x025x025.mdl") ply:SetColor(Color(0,0,0,0)) ply:SetupHands() else ply:StripWeapons() print("Team spawned as: " .. current) model = table.Random(CPConf.Teams[current]["playermodels"]) util.PrecacheModel( model ) ply:SetModel(model) ply:SetColor(Color(255,255,255,255)) ply:SetupHands() wep = table.Random(CPConf.Teams[current]["weapons"]) ply:Give(wep) end end)
Now before you say “do X, Y, Z” I’d like to point out certain things:
- the ply:PrintMessage(HUD_PRINTCONSOLE, etc.) WORKS! In-game the message appears as it should! But the model isnt set directly after nor are weapons stripped.
- Tested using spectator team and not spectator, the print and PrintMessage’s BOTH APPEAR but models arent set, weapons arent removed and given, etc.
- The code for player modification in general does work! I have another custom hook based on the net library to respond to a command and uses this same code as an end game (run command, choose option, player model set, weapons stripped, etc.) and that works flawlessly!
- NO CONSOLE ERRORS
So in short, I’m guessing I’m using the player spawn hook incorrectly or there has to be another way to do this. If you guys know, please tell me, this has been a huge pain for me.