Ulysses Stuff > Suggestions
command time restrictions
pants:
I'd really like to see an addon where I could set it by rank to where say
moderators - must wait 10 seconds between using commands
admins - must wait 5 seconds between using commands
etc. to help with my command spam problems.
those times aren't my final choice just an example
pants:
And cobalt delivers! http://pastebin.com/9q9ev2rW
--- Code: ----- add all usergroups here with cooldown times
local groups = {}
groups.admin = 10
groups.superadmin = 5
groups.owner = 3
-- groups who shouldnt be affected by a cooldown
local blacklist = { "owner", "superadmin" }
timer.Simple( 10, function()
hook.Add( "ULibCommandCalled", "CheckCommands", function( ply, cmd, args )
if table.HasValue( blacklist, ply:GetUserGroup() ) then
return
end
if not ply.cooldown or ply.cooldown <= 0 then
ply.cooldown = groups[ ply:GetUserGroup() ]
else
ply:ChatPrint( "Please wait " .. tostring( ply.cooldown ) .. " more seconds before you use a command again." )
return false
end
end )
end )
timer.Create( "Cooldown", 1, 0, function()
for k, v in next, player.GetAll() do
if v.cooldown then
if v.cooldown > 0 then
v.cooldown = v.cooldown - 1
if v.cooldown == 0 then
v.cooldown = nil
end
elseif v.cooldown <= 0 then
v.cooldown = nil
end
end
end
end )
--- End code ---
Megiddo:
Excellent use of ULibCommandCalled. :D
pants:
I actually wasn't able to get it working, but I have really weird group names like "adept3+"
but cobalt said it worked for him, so it probably works.
An Error Has Occurred!
array_keys(): Argument #1 ($array) must be of type array, null given
[0] Board index
Go to full version