• Noob here: Weapon on spawn.
    6 replies, posted
I'm new to Garry's Mod, and I already have a server up and running. I run horror, and I need a good gamemode for that. I need it to where when people spawn in my server, they automatically spawn with a crowbar, and every time they die, and repawn, they get a crowbar again. \\
You'd use the [URL="http://wiki.garrysmod.com/page/Hooks/Base/PlayerSpawn"]PlayerSpawn[/URL] hook to call the [URL="http://wiki.garrysmod.com/page/Classes/Player/Give"]Player:Give[/URL] command on spawn. [editline]20th January 2013[/editline] So, for example: [code] function GM:PlayerSpawn(ply) ply:Give("weapon_crowbar") end[/code]
but where would I put this code?.. what file
You'd put it in init.lua
It worked when i spawned in. When I died, I did not respawn with one. Also my friend joined and did not spawn with one. Please help
I use this code on my gamemode, and no problem.. [lua]function GM:PlayerSpawn( ply ) ply:Give("weapon_crowbar") ply:Give("weapon_pistol") ply:Give("weapon_...") end[/lua] Check your console if you have an error.
[QUOTE=supersnail11;39297227]You'd use the [URL="http://wiki.garrysmod.com/page/Hooks/Base/PlayerSpawn"]PlayerSpawn[/URL] hook to call the [URL="http://wiki.garrysmod.com/page/Classes/Player/Give"]Player:Give[/URL] command on spawn. [editline]20th January 2013[/editline] So, for example: [code] function GM:PlayerSpawn(ply) ply:Give("weapon_crowbar") end[/code][/QUOTE] It may be better to have a hook, instead of overwriting the functionality of PlayerSpawn in his gamemode all together. Another example that will work. [CODE]hook.Add("PlayerSpawn", "Horror_LoadOut", function(Player) Player:Give("weapon_crowbar") end)[/CODE]
Sorry, you need to Log In to post a reply to this thread.