Superadmin spawn with weapon

Hey, i’m new to this stuff and i’m learning how to create a file in autorun to give a weapon to a defined group

But this isnt working :confused:
why?

This is a file in gmod server folder\lua\autorun
startupweapons.lua

function dararmas( ply )
if ply:IsUserGroup(“superadmin”) then ply:Give(“weapon…”) end
end

Why isnt it working?

Because you’re not hooking it to anything. hook it to PlayerSpawn, and also make the function local. For future reference put your code in [noparse]




[/noparse] tags, please.

[editline]4th September 2014[/editline]

Also make sure it is wrapped in if (SERVER) then …yourstuff… end or in lua/autorun/server.

How can i “hook to playerspawn”

You should research the wiki before you do anything… Google is also a great tool for you.


hook.Add("PlayerSpawn", "RandomUniqueName", function(ply) 
	if (ply:IsSuperAdmin()) then 
		ply:Give("BLAH") 
	end 
end) 

Thanks!

PlayerLoadout already exists for that kind of stuff too.



hook.Add("PlayerLoadout", "RandomUniqueName", function(ply) 
	if (ply:IsSuperAdmin()) then 
		ply:Give("BLAH") 
		
		return true --hides default loadout
	end 
end)