Spray Blocker help

how do i make it so no one can spray.

hook.Add(“PlayerSpray”,“shit”, function()
–if or whatever
return true
end)

^ that doesn’t seem to work

sv_allowupload 0

can that be used in a lua script?

To toggle it on and off? no because it only refreshes when the server starts. (Server.cfg)

Aww :frowning: but you seem like you know what your doing since you knew i wanted it to be toggled.

[lua]
function GM:PlayerSpray(ply)
– True blocks, false allow
return !ply:IsAdmin()
end
[/lua]

okay so GM is a nil value, and do you know a hook thats for when a player sprays? So i can toggle weather they can spray or not.

That was a script for allowing sprays or not.
Put it in garrysmod/gamemodes/yourgamemode/gamemode/init.lua

i want to be able to disable sprays from another script. ex: when there looking at another players spray. I have all the other code set up i just need to actually disable the sprays.

[lua]
local function BlockSprays(ply)
return !ply:IsAdmin()
end
hook.Add(“PlayerSpray”, “BlockSprays”, BlockSprays)
[/lua]

lua/autorun/server

The gamemode function is probably not made, so the hook would be useless.
Which probably was the cause for the problem in his first code with the hook.

PlayerSpray is a base hook, it’s available in any gamemode.

any way to disable/enable sprays while the server is running? EX:

spraytrue = false

if spraytrue == false then
hook.add (“PlayerSpray”, “name”, BlockSprays)
end

local function BlockSprays(ply)
return true
end

if spraytrue == true then
hook.add (“PlayerSpray”, “name”, BlockSprays2)
end

local function BlockSprays2(ply)
return false
end

[lua]
local sprayallow = false
concommand.Add( “toggle_allow_sprays”, function( p, c, a )
if p:IsAdmin() then
sprayallow = !sprayallow
p:ChatPrint( "spray toggle allow now: " … tostring(sprayallow) )
end
end )

local function BlockSprays(ply)
return sprayallow
end
hook.Add(“PlayerSpray”, “BlockSprays”, BlockSprays)
[/lua]

Try this.

Can you block a players spray in the client side? I have my boolean in the Client side but my hooks wont how should i say “start my function” in server side. If a hook can run a function from client to server please tell me.

That is not a good idea.

Either way i need it done.

I think what he means is a script that would stop players from spraying over sprays.