Ulysses Stuff > Suggestions
command time restrictions
pants:
Thanks sorry this is so late I missed the post!
ulx.groupcooldown.grouplist = {
-- All groups must be formatted as followed:
-- "superadmin" = 5,
"superadmin" = 0,
"admin" = 0,
"padawan2s" = 5,
"padawan+" = 3,
"adept3s" = 4,
"adept+" = 2,
"jedimaster4s" = 2,
"jedimaster+" = 2
}
yeilds [ERROR] lua/autorun/server/timerestrictions2.lua:21: '}' expected (to close '{' at line 18) near '='
1. unknown - lua/autorun/server/timerestrictions2.lua:0
JamminR:
I'm reasonably sure you can't put lua comments in a table, at least, I used to have tons of trouble doing it years ago.
Try placing the two -- lines outside of the table.
And for good measure, place a comma at the end of the last table entry ("jedimaster+" = 2,
ActeonAk:
I tried the first script by Cobalt, it works for me except that whenever I try to do ulx commands through the console, it doesn't work and I get this error:
--- Quote ---[ERROR] lua/autorun/cooldown.lua:12: attempt to call method 'GetUserGroup' (a nil value)
1. fn - lua/autorun/cooldown.lua:12
2. Call - addons/ulib/lua/ulib/shared/hook.lua:183
3. unknown - addons/ulib/lua/ulib/shared/commands.lua:1294
4. unknown - lua/includes/modules/concommand.lua:69
--- End quote ---
The updated script by lynx results in the same error pants got, even after taking out the lua comments from the table.
--- Quote ---[ERROR] lua/autorun/cooldown.lua:19: '}' expected (to close '{' at line 18) near '='
1. unknown - lua/autorun/cooldown.lua:0
--- End quote ---
funkster:
Hi total noob here, where do I paste this script? Does it go into the garrysmod/lua/autorun folder?
edit: +1 to the previous commment, first script doesnt allow me to use console cmds, and second script gives that error posted even after removing comments.
funkster:
Although I have no idea about code, I think it's meant to be like this???
--- Code: -----[[----------------------------------
ULX Command Cooldown
Originally coded by: Cobalt
Updated by: lynx
Updated: March 3, 2014
----------------------------------]]--
groupcooldown = {}
--[[ Begin Configuration Section ]]--
-- groupcooldown.default
-- This sets the default cooldown for groups not listed in the grouplist.
groupcooldown.default = 15
-- groupcooldown.grouplist
-- This list defines the cooldown times for the groups. If a group is unlisted and not on the whitelist, it will default to default above.
-- This is a table. Please follow the example when adding groups.
groupcooldown.grouplist = {
["superadmin"] = 10;
["admin"] = 5;
["operator"] = 3;
}
-- groupcooldown.whitelist
-- Groups and Steam ID's defined in this list are exempt from the command cooldown regardless if their group is listed above.
groupcooldown.whitelist = { "owner", "developer", "superadmin", "STEAM_0:0:0", "STEAM_0:0:29798183" }
-- groupcooldown.message
-- This is the message dispalyed to the user. A second message will inform them of the time they have remaining to wait.
groupcooldown.message = "You are not allowed to do that right now."
--[[ End Configuration. Please do not modify anything below this line otherwise stuff will break. ]]--
function CmdCooldown(ply, cmd, args)
if table.HasValue( groupcooldown.whitelist, ply:SteamID() ) or table.HasValue( groupcooldown.whitelist, ply:GetUserGroup() ) then
return
end
if not ply.NextCommand or ply.NextCommand <= CurTime() then
ply.NextCommand = CurTime() + ( groupcooldown.grouplist[ply:GetUserGroup()] or groupcooldown.default )
end
if ply.NextCommand > CurTime() then
local nextCmd = ply.NextCommand - CurTime()
ULib.tsay( ply, groupcooldown.message )
ULib.tsay( ply, string.format( "You have %s seconds to wait before you can use a command again.", math.floor(nextCmd) ) )
return false
end
end
timer.Simple( 3, function()
hook.Add( "ULibCommandCalled", "CheckCommands", CmdCooldown )
end )
--- End code ---
It doesn't work even though it doesn't give any errors. It doesn't allow any commands at all, just displays wait times and you can't do this command.
Navigation
[0] Message Index
[*] Previous page
Go to full version