I made a script for Sandbox RP, ( Stupid, I know ) I made it so it strips all the weapons and gives the player weapons on spawn.
[code]hook.Add( "PlayerSpawn", "Rofl P90_Man's Hook :D", function( ply )
ply:StripWeapons()
ply:Give( "weapon_physgun" )
ply:Give( "weapon_physcannon" )
ply:Give( "gmod_tool" )
ply:Give( "rcs_knife" )
ply:Give( "tf2_combo_fists" )
end )[/code]Now I need to know WHY it isn't working... I ain't getting the weapons, or losing my others. AND there are NO Errors, when I run it manually so.... Also, what is a hook? I've been wondering. (Someone told me I needed a hook. So they did it for me.)
Try doing this:
[code]
hook.Add( "PlayerSpawn", "Rofl P90_Man's Hook :D", function( ply )
timer.simple(0.1, function()
ply:StripWeapons()
ply:Give( "weapon_physgun" )
ply:Give( "weapon_physcannon" )
ply:Give( "gmod_tool" )
ply:Give( "rcs_knife" )
ply:Give( "tf2_combo_fists" )
end)
end )
[/code][edit]
heh, I just saw that, the hook name could be messing it up. Not positive though. I do know that you need some sort of delay before stripping all the players weapons. As for the "What is a hook" question. You should read up on [url=http://wiki.garrysmod.com/?title=Gamemode_Hooks]this[/url].
[code]
hook.Add( "PlayerSpawn", "CustomLoadout", function( ply )
timer.simple(0.1, function()
ply:StripWeapons()
ply:Give( "weapon_physgun" )
ply:Give( "weapon_physcannon" )
ply:Give( "gmod_tool" )
ply:Give( "rcs_knife" )
ply:Give( "tf2_combo_fists" )
end)
end )
[/code]
Thanks! I Will try it out NOW!
[editline]05:42PM[/editline]
Yes, I'm getting lua errors.
[code]Attempt to call field 'simple'.
Removing Hook *My hook...*[/code]
[editline]05:46PM[/editline]
I'm a newbie, so I don't know pretty much any hooks, functions, or anything.
[QUOTE=343N;20225489]Thanks! I Will try it out NOW!
[editline]05:42PM[/editline]
Yes, I'm getting lua errors.
[code]Attempt to call field 'simple'.
Removing Hook *My hook...*[/code][editline]05:46PM[/editline]
I'm a newbie, so I don't know pretty much any hooks, functions, or anything.[/QUOTE]
oh right, sorry, It's: [code]timer.Simple[/code] Capitalization matters, I didn't realize I forgot to capitalize "Simple", sorry about that.
This should work:
[code]
hook.Add( "PlayerSpawn", "CustomLoadout", function( ply )
timer.Simple(0.1, function()
ply:StripWeapons()
ply:Give( "weapon_physgun" )
ply:Give( "weapon_physcannon" )
ply:Give( "gmod_tool" )
ply:Give( "rcs_knife" )
ply:Give( "tf2_combo_fists" )
end)
end )
[/code]
Thats ok, I didn't realise, testing again! You've been great to me :downs:
P.S, Aussies spell 'realize' as 'realise'
[editline]06:40PM[/editline]
YES IT WORKS! Thanks!
Sorry, you need to Log In to post a reply to this thread.