Author Topic: ULX Jail with reasons (Im making it worse!)  (Read 1975 times)

0 Members and 1 Guest are viewing this topic.

Offline BobTheDuck

  • Newbie
  • *
  • Posts: 5
  • Karma: -2
ULX Jail with reasons (Im making it worse!)
« on: February 18, 2016, 04:20:12 PM »
Ok so Unjail functions as jail and reasons wont work... Im attempting to make modification of this code but dont know where to start...


Code: [Select]
        ------------------------------ Jail ------------------------------
        local doJail
        local jailableArea
        function ulx.jail( calling_ply, target_plys, seconds, reason, should_unjail )
        local affected_plys = {}
        for i=1, #target_plys do
        local v = target_plys[ i ]
         
        if not should_unjail then
        if ulx.getExclusive( v, calling_ply ) then
        ULib.tsayError( calling_ply, ulx.getExclusive( v, calling_ply ), true )
        elseif not jailableArea( v:GetPos() ) then
        ULib.tsayError( calling_ply, v:Nick() .. " is not in an area where a jail can be placed!", true )
        else
        doJail( v, seconds )
         
        table.insert( affected_plys, v )
        end
        elseif v.jail then
        v.jail.unjail()
        v.jail = nil
        table.insert( affected_plys, v )
        end
        end
         
        if not should_unjail then
        local str = "#A jailed #T (#s)"
        if seconds > 0 then
        str = str .. " for #i seconds. (#s)"
        end
        ulx.fancyLogAdmin( calling_ply, str, affected_plys, seconds, reason )
        else
        ulx.fancyLogAdmin( calling_ply, "#A unjailed #T", affected_plys )
        end
        end
        local jail = ulx.command( CATEGORY_NAME, "ulx jail", ulx.jail, "!jail" )
        jail:addParam{ type=ULib.cmds.PlayersArg }
        jail:addParam{ type=ULib.cmds.NumArg, min=0, default=0, hint="seconds, 0 is forever", ULib.cmds.round, ULib.cmds.optional }
        jail:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine }
        jail:addParam{ type=ULib.cmds.BoolArg, invisible=true }
        jail:defaultAccess( ULib.ACCESS_ADMIN )
        jail:help( "Jails target(s)." )
        jail:setOpposite( "ulx unjail", {_, _, _, true}, "!unjail" )
         

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: ULX Jail with reasons (Im making it worse!)
« Reply #1 on: February 18, 2016, 04:42:27 PM »
Define "don't work".

Does it do anything?
Do you get any Lua errors when attempting to run it?
Where did you drop this code? What folder, what file name?
bw81@ulysses-forums ~ % whoami
Homepage

Offline BobTheDuck

  • Newbie
  • *
  • Posts: 5
  • Karma: -2
Re: ULX Jail with reasons (Im making it worse!)
« Reply #2 on: February 19, 2016, 08:28:03 AM »
Well for starters unjail now functions as jail... and the reason wont show up period...

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX Jail with reasons (Im making it worse!)
« Reply #3 on: February 19, 2016, 03:12:07 PM »
Bob, you can't just insert a text field variable without heavily modifying the text parser below or the ulx command object being passed to it/
'should_unjail' expects true or false. If it's anything but boolean 'true', well, that makes it 'false' and jails target.
My bet is you're not encapsulating "reason" in a single variable, so the say command is passing multiple word vars.

In the example below, #4 is expected to be true or false 'should_unjail'

1 2 3 4 5 6 7
jail target reason words go here true
would still jail a person because word 4 is 'go' and not a boolean.

I don't have the say command in front of me, and you didn't post what you're now using, but that's my recollection.

"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX Jail with reasons (Im making it worse!)
« Reply #4 on: February 22, 2016, 03:37:44 PM »
Found this while searching for something else.
Amazing what our search box will find, right?
https://forums.ulyssesmod.net/index.php/topic,6598.0.html
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming