• Spawning with Physicsgun/Toolgun/Camera
    11 replies, posted
Can someone give me a hook or an addon or something that makes it so when players spawn, they don't have the physics gun, toolgun, and camera.
What gamemode? And isn't it just like this, in init.lua? (not exactly like this ) [lua] if ply:Team == team1 then ply:Give("weapons here") [/lua] You would probably be able to find that in any gmaemode.
[QUOTE=vegasx;25687733]Can someone give me a hook or an addon or something that makes it so when players spawn, they don't have the physics gun, toolgun, and camera.[/QUOTE] With or Without? The title says With.
-snip- I read the post wrong.
[QUOTE=_Zoey_;25700356]With or Without? The title says With.[/QUOTE] Without. And its just for sandbox. I know enough lua to know where to edit if it was as simple as removing a ply:give code. I just need the code for removing the weapons, I can't get it to apply to every player as they spawn. Would this work? hook.Add( "PlayerSpawn", "Remove", function( ply ) ply:StripWeapon("weapon_physgun") ply:StripWeapon("gmod_tool") ply:StripWeapon("gmod_camera") end )
for k, v in pairs( player.GetAll() ) do v:StripWeapon("weapon_physgun") v:StripWeapon("gmod_tool") V:StripWeapon("gmod_camera") end Just a quick guess but there's no harm in trying it. In theory it looks like it should work ^.^ Also this goes into the 'shared' file somewhere
Is that with the hook.Add( "PlayerSpawn", "Remove", function( ply )? or just standalone
[lua]function GM:PlayerSpawn( ply ) ply:StripWeapons() end hook.Add( "PlayerSpawn", "PlayerTakeWeapons", playerRespawn )[/lua] Untested. I might've messed up the hook.Add.
Well, Heres something that will get the job done anyway. [code] function NoToolsOnSpawn(ply) timer.Simple(0.1, function() -- Lets call this a little later than default loadout, Just incase. if ValidEntity(ply) then ply:StripWeapon("weapon_physgun") ply:StripWeapon("gmod_tool") ply:StripWeapon("gmod_camera") end end) end hook.Add("PlayerSpawn","NoToolsSpawnHook",NoToolsOnSpawn)[/code]
[QUOTE=Dave_Parker;25718636]You already hook it by assigning it to the Gamemode table, no need to hook again. Also the last argument of hook.Add is the function name, and I don't know where you got playerRespawn from.[/QUOTE] Oh, I see. Thanks for the feedback.
[QUOTE=_Zoey_;25718770]Well, Heres something that will get the job done anyway. [code] function NoToolsOnSpawn(ply) timer.Simple(0.1, function() -- Lets call this a little later than default loadout, Just incase. if ValidEntity(ply) then ply:StripWeapon("weapon_physgun") ply:StripWeapon("gmod_tool") ply:StripWeapon("gmod_camera") end end) end hook.Add("PlayerSpawn","NoToolsSpawnHook",NoToolsOnSpawn)[/code][/QUOTE] Thanks. I have been looking for this for a long time, after a while I just decided to request it.
[QUOTE=vegasx;25728628]Thanks. I have been looking for this for a long time, after a while I just decided to request it.[/QUOTE] Glad i could help.
Sorry, you need to Log In to post a reply to this thread.