Spray Stopper

Hey all, I need a piece of code that if your not an admin will msg(“You can’t spray!”) and if you are allows you to spray, when you try to spray.

If anyone could help I would be eternally greatful I know this should be a real simple script for someone more experienced with the GMOD hooks but unfortuately I am now and it would probably take me an hour or two to get it right…



function GM:PlayerSpray(Player)
    if Player:IsAdmin() then
        return false
    end
    Player:ChatPrint("You can't spray!")
    return true
end


Thank you very much!!

Anytime.

I just have to ask, this might be stupid, but, here it goes:
Where can I find a full list of all the variables(I think?) such as
GM:PlayerSpray.

Sorry if this is obvious.

Goto the gmod wiki and search for hooks.

Awful.

[lua]hook.Add(“PlayerSpray”, function(ply)
if ply:IsAdmin() then
return false
end
ply:ChatPrint(“You aren’t allowed to use sprays!”)
return true
end)
[/lua]

Put it in garrysmod/garrysmod/lua/autorun/server/spray.lua, creating folders and files if they don’t exist.

For PlayerSpray, you return true to block the spray, false to allow it - not the other way around.

Wow. Didn’t know that. Thanks.
Pretty dumb though.