No decalfrequency for admins? (AllowImmediateDecalPainting)
7 replies, posted
So, I'm trying to make a lua script that allows admins to spray instantly without decal frequency. I don't want to change the decalfrequency value to 0, since it's supposed to be user/group restricted. I've tried something like this so far:
[lua]function Think()
for _, ply in pairs( player.GetAll() ) do
if ply:isAdmin() then
ply:AllowImmediateDecalPainting()
end
end
end[/lua]
My intentions would be to make this work with ULX superadmins/admins, but so far, I haven't succeeded at all (without the admin checks) and I couldn't find much anything on this. Any help here?
You can set decalfrequency to 0 and then use the hook to deny any sprays until a certain time after.
[lua]hook.Add( "PlayerSpray", "CanSpray", function( ply )
if ply:IsAdmin() then return false end
if not ply.LastSprayTime or ply.LastSprayTime - CurTime() >= 10 then -- 10 seconds
ply.LastSprayTime = CurTime()
return false
end
end[/lua]
[QUOTE=Ruzza;35340279]You can set decalfrequency to 0 and then use the hook to deny any sprays until a certain time after.
[lua]hook.Add( "PlayerSpray", "CanSpray", function( ply )
if ply:IsAdmin() then return false end
if not ply.LastSprayTime or ply.LastSprayTime >= 10 then -- 10 seconds
ply.LastSprayTime = CurTime()
return false
end
end[/lua][/QUOTE]
I tried it, but it doesn't seem to do much anything with decalfrequency 0, still allows me to spam it (commented out the IsAdmin()).
EDIT: Off-topic, but your post count seems to be 420. :P
The function doesn't seem to work.
I tried this too.
Oh my bad, I didn't complete the string, try this
[lua]hook.Add( "PlayerSpray", "CanSpray", function( ply )
if ply:IsAdmin() then return false end
if not ply.LastSprayTime or ply.LastSprayTime - CurTime() >= 10 then -- 10 seconds
ply.LastSprayTime = CurTime()
return false
end
end[/lua]
[lua]hook.Add( "PlayerSpray", "CanSpray", function( ply )
--if ply:IsAdmin() then return false end
if not ply.LastSprayTime or ply.LastSprayTime - CurTime() >= 5 then -- 5 seconds
ply.LastSprayTime = CurTime()
return false
end
end)[/lua]
I can still spam it with decalfrequency 0. You also forgot ) after last end (forgot to mention in previous post).
Wow, two mistakes :P, I forgot to put "return true" and the CurTime() equation is backwards.
Here you are, I tested it myself this time...
[lua]hook.Add( "PlayerSpray", "CanSpray", function( ply )
if ply:IsAdmin() then return false end
if not ply.LastSprayTime or CurTime() - ply.LastSprayTime >= 10 then -- 10 seconds
ply.LastSprayTime = CurTime()
return false
end
return true
end )[/lua]
[QUOTE=Ruzza;35343733]Wow, two mistakes :P, I forgot to put "return true" and the CurTime() equation is backwards.
Here you are, I tested it myself this time...
[lua]hook.Add( "PlayerSpray", "CanSpray", function( ply )
if ply:IsAdmin() then return false end
if not ply.LastSprayTime or CurTime() - ply.LastSprayTime >= 10 then -- 10 seconds
ply.LastSprayTime = CurTime()
return false
end
return true
end )[/lua][/QUOTE]
Thanks! Took me a bit of time to test it, but it works. You just saved me a bit, +1 for that. :)
Sorry, you need to Log In to post a reply to this thread.