Author Topic: !ban name reason  (Read 5544 times)

0 Members and 1 Guest are viewing this topic.

Offline Willdy

  • Jr. Member
  • **
  • Posts: 54
  • Karma: 1
!ban name reason
« on: August 06, 2012, 12:15:48 PM »
Hey, I noticed something on our TTT server the other day, if you type:

!ban <name> <reason>
(Missing out the time)

It defaults to a permanent ban, since we have different levels of Moderators with different ban allowances this makes our life harder. Would there be a fix which means they can't forget the time?

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: !ban name reason
« Reply #1 on: August 06, 2012, 03:22:50 PM »
Completely untested.. but this "should" world...

Replace the functions for ban and banid inside of your ulx\modules\sh.lua file

Code: [Select]
function ulx.ban( calling_ply, target_ply, time, reason )
if target_ply:IsBot() then
ULib.tsayError( calling_ply, "Cannot ban a bot", true )
return
end
if time == "" then
ULib.tsayError( calling_ply, "You must enter a value for time.", true )
return
end
local minutes = ULib.stringTimeToSeconds( time )
if not minutes then
ULib.tsayError( calling_ply, "Invalid time format." )
return
end

ULib.kickban( target_ply, minutes, reason, calling_ply )

local time = "for #i minute(s)"
if minutes == 0 then time = "permanently" end
local str = "#A banned #T " .. time
if reason and reason ~= "" then str = str .. " (#s)" end
ulx.fancyLogAdmin( calling_ply, str, target_ply, minutes ~= 0 and minutes or reason, reason )
end
local ban = ulx.command( CATEGORY_NAME, "ulx ban", ulx.ban, "!ban" )
ban:addParam{ type=ULib.cmds.PlayerArg }
ban:addParam{ type=ULib.cmds.StringArg, hint="minutes, 0 for perma. 'h' for hours, 'd' for days, 'w' for weeks. EG, '2w5d' for 2 weeks 5 days", ULib.cmds.optional }
ban:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
ban:defaultAccess( ULib.ACCESS_ADMIN )
ban:help( "Bans target." )

function ulx.banid( calling_ply, steamid, time, reason )
if time == "" then
ULib.tsayError( calling_ply, "You must enter a value for time.", true )
return
end
steamid = steamid:upper()
if not ULib.isValidSteamID( steamid ) then
ULib.tsayError( calling_ply, "Invalid steamid." )
return
end
local minutes = ULib.stringTimeToSeconds( time )
if not minutes then
ULib.tsayError( calling_ply, "Invalid time format." )
return
end

local name
local plys = player.GetAll()
for i=1, #plys do
if plys[ i ]:SteamID() == steamid then
name = plys[ i ]:Nick()
break
end
end

ULib.addBan( steamid, minutes, reason, name, calling_ply )

local time = "for #i minute(s)"
if minutes == 0 then time = "permanently" end
local str = "#A banned steamid #s "
if name then
steamid = steamid .. "(" .. name .. ") "
end
str = str .. time
if reason and reason ~= "" then str = str .. " (#4s)" end
ulx.fancyLogAdmin( calling_ply, str, steamid, minutes ~= 0 and minutes or reason, reason )
end
local banid = ulx.command( CATEGORY_NAME, "ulx banid", ulx.banid )
banid:addParam{ type=ULib.cmds.StringArg, hint="steamid" }
banid:addParam{ type=ULib.cmds.StringArg, hint="minutes, 0 for perma. 'h' for hours, 'd' for days, 'w' for weeks. EG, '2w5d' for 2 weeks 5 days", ULib.cmds.optional }
banid:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
banid:defaultAccess( ULib.ACCESS_SUPERADMIN )
banid:help( "Bans steamid." )

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: !ban name reason
« Reply #2 on: August 06, 2012, 04:04:08 PM »
...Or you can just change the permissions for the moderator group so they can't ban permanently.
Experiencing God's grace one day at a time.

Offline Willdy

  • Jr. Member
  • **
  • Posts: 54
  • Karma: 1
Re: !ban name reason
« Reply #3 on: August 06, 2012, 04:08:26 PM »
...Or you can just change the permissions for the moderator group so they can't ban permanently.
If we whitelist the valid ban times, not setting a time will still perm ban. Am I missing something?
« Last Edit: August 06, 2012, 04:13:45 PM by Willdy »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: !ban name reason
« Reply #4 on: August 06, 2012, 07:38:32 PM »
If we whitelist the valid ban times, not setting a time will still perm ban. Am I missing something?

Hmm it shouldn't be doing that. This would be a bug, then. We'll look into it. :)
Experiencing God's grace one day at a time.

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: !ban name reason
« Reply #5 on: August 06, 2012, 08:40:56 PM »
Didn't happen to me:

Code: [Select]
You granted access "ulx ban" with tag "* 1:2" to group superadmin
[ULX]Stickly Man!: !ban sti
Command "ulx ban", argument #2: specified number or time string (0) was below your allowed minimum value of 1

I guess we should inform you that we changed the restriction of bans from a string (whitelist) to a number that accepts the standard 1w2y type date-strings, so you'll want to change your ulx ban restriction tags to be like the following:

ulx groupallow operator "ulx ban" "* 1:2w"   (allow banning everyone from 1 minute to 2 weeks. Don't put the 'm' to signify minutes, it doesn't like that lol)
ulx groupallow admin "ulx ban" "*1h:2y"    (allow banning everyone from 1 hour to 2 years)

etc. (Or use the XGUI permissions menu :P)

Anyways, let us know if that fixes your problem! :)
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline PAL-18

  • Full Member
  • ***
  • Posts: 142
  • Karma: 1
Re: !ban name reason
« Reply #6 on: January 16, 2013, 06:35:11 PM »
Can D be used to signify days?

I have an admin with a bad memory and he can't remember 1440 minutes = 1 day.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: !ban name reason
« Reply #7 on: January 16, 2013, 07:22:15 PM »
Yes, d is used to signify days.
Experiencing God's grace one day at a time.