How can I make my new admin gun spawnable by ONLY me?

Hi guys, I’m fairly new to lua, but I have mad my own admin weapon. All it does it vaporize anything you shoot at.

So what i want to know is, how do i make it run some kind of check when spawned by someone to see if their steam id matches the one that the admin gun knows (mine). And if it doesnt it will kill them or not let them have it or something. Anyone know how to do that? Please help and thanks :slight_smile:

You could use the PlayerCanPickupWeapon hook.

Gamemode(Serverside):
[lua]
function GM:PlayerCanPickupWeapon(ply, wep)
local MySteamID = “STEAMIDHERE”
if wep:GetClass() == “WEAPON_CLASS” and ply:SteamID() != MySteamID then
return false
end

return true

end
[/lua]

Place inside lua/autorun/server if you’re not using in a gamemode(Serverside):
[lua]
hook.Add(“PlayerCanPickupWeapon”, “DontAllowAdminGuns”, function(ply, wep)
local MySteamID = “STEAMIDHERE”
if wep:GetClass() == “WEAPON_CLASS” and ply:SteamID() != MySteamID then
return false
end

return true

end
[/lua]

Thanks for the help! It works great!

No problem! :smiley: