ULX

Author Topic: restricted banning by group  (Read 3516 times)

0 Members and 1 Guest are viewing this topic.

Offline blacksythe

  • Newbie
  • *
  • Posts: 38
  • Karma: -1
restricted banning by group
« on: December 02, 2007, 12:54:14 PM »
I would like to see the ability to give out restricted time bans based on a group for example.

Operators can ban for up to 3 days maximum,
Moderators can ban for upto 1 week maximum
admins 1 month/ perma
Sadmins perma ban

Or if someone can give me some code so i can implement this myself I would much appreciate because soon i am moving onto a multi server administration and would like moderators to head servers admins to head all servers etc.


Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: restricted banning by group
« Reply #1 on: December 02, 2007, 03:57:16 PM »
I think this is a good idea. Something for a module, for sure.

As for implementation... you could copy and paste the code for the ulx ban command and throw in a couple of lines of code that checks the time parameter and only goes through it if is within a certain range like...

if (time <= 4320) and (time > 0)
{
Ban Function
}
else
{
Echo to the screen that the time does not meet the requirement
}

You could then call it something like... mban (moderator ban) or oban (operator ban)

**That is not lua btw.. I'm not good with lua syntax unfortunately.**

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: restricted banning by group
« Reply #2 on: December 05, 2007, 12:48:14 AM »
Here you go.

Code: [Select]
function ulx.cc_ban2( ply, command, argv, args )
if #argv < 1 then
ULib.tsay( ply, ulx.LOW_ARGS, true )
return
end

local target, err = ULib.getUser( argv[ 1 ], _, ply )
if not target then
ULib.tsay( ply, err, true )
return
end

local bantime = tonumber( argv[ 2 ] ) or 0

if bantime == 0 then
ULib.tsay( ply, "This ban is not allowed to ban perminently", true )
return
end

if bantime > 4320 then
ULib.tsay( ply, "This ban is not allowed to ban for longer than 3 days", true )
return
end

local dummy, dummy, reason = args:find( "^\"*" .. ULib.makePatternSafe( argv[ 1 ] ) .. "\"*%s+" .. ULib.makePatternSafe( argv[ 2 ] ) .. "%s+(.*)$" )
reason = reason or "" -- Make sure it has a value

local time = "for " .. bantime .. " minute(s)"
if reason ~= "" then reason = "(" .. reason .. ")" end
ulx.logUserAct( ply, target, "#A banned #T " .. time .. " " .. reason )

ULib.kickban( target, bantime, reason, ply )
end
ulx.concommand( "ban2", ulx.cc_ban2, "<user> [<time>] [<reason>] - Bans a user for x minutes, Must be less than 4320 minutes(3 Days).", ULib.ACCESS_ADMIN, "!ban2", _, ulx.ID_PLAYER_HELP )

All I did was add 2 time checks =)

ulx ban2 <user> <time> <reason> (!ban2)
This ban can not ban for 0 minutes (perminently).. if you try it will tell you you cant and exit the function
This ban can not ban for more than 3 days.. if you try it will tell you it cant, and exit the function.


If you want to call it something else.. like aban or oban.. or whatever.. just open the lua file in notepad and replace all 4 instances of ban2 with whatever you want it to be called. The Find and Replace function under Edit works wonders for this! =)

Download below..


oh btw.. drop this in Addons/ULX/Lua/ULX/Modules
« Last Edit: December 05, 2007, 12:50:27 AM by zakap »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: restricted banning by group
« Reply #3 on: December 05, 2007, 07:43:07 AM »
Don't burn yourself out Zakap! ;)
Experiencing God's grace one day at a time.

Offline blacksythe

  • Newbie
  • *
  • Posts: 38
  • Karma: -1
Re: restricted banning by group
« Reply #4 on: December 05, 2007, 09:13:28 AM »
wow cheers looks greatand works great too

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: restricted banning by group
« Reply #5 on: December 05, 2007, 02:06:38 PM »
Don't burn yourself out Zakap! ;)

lol, Meg. You have no idea how much I've always wanted to do.. but was always too afraid to do it because I was scared of lua Syntax... =)