• Print

Author Topic: ULX Jail save  (Read 6349 times)

0 Members and 1 Guest are viewing this topic.

Offline Scozor

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
ULX Jail save
« on: February 16, 2015, 05:52:21 am »
Hello, here is it possible that someone JAIL when I save it prevents the player disconnects and reconnects and is no longer in jail?

I am a strict administrator and wish to put heavy penalty as long enough jails.

Thank you for your response, I grieve French and I use google translation.

Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: ULX Jail save
« Reply #1 on: February 16, 2015, 08:14:41 pm »
No. You can't have it prevent a player from disconnecting. If you want it so they get added to like a jail table so they stay jailed for (x) time and when they connect they get rejailed then that's different.
Once you get to know me, you'll find you'll have never met me at all.

Offline jakej78b

  • Newbie
  • *
  • Posts: 26
  • Karma: 4
Re: ULX Jail save
« Reply #2 on: February 16, 2015, 08:24:24 pm »
I'm pretty sure that's what he's asking. Not to prevent disconnects, but to make it so they get rejailed if they disconnect and reconnect. Keep in mind he used google translate so the english is most likely flawed. Your best option would be to modify the jail or write your own custom command that saves the time and steamid so that when they rejoin it will force them to serve the remainder of their time.

Offline Scozor

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: ULX Jail save
« Reply #3 on: February 17, 2015, 04:03:34 am »
Hi, yes sorry google translation is not perfect.

The problem that I really struggle with programming in lua, is there a pay system scriptfodder?

Yes I just want the player back to jail if he did not finish his time.
I know to program in C ++ and JavaScript but I find the different lua and I'm struggling.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: ULX Jail save
« Reply #4 on: February 19, 2015, 03:44:45 am »
Oddly enough, this is one of the most difficult things I ever tried to do in my life. I can't seem to even do this myself. I'll look more into this.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: ULX Jail save
« Reply #5 on: February 19, 2015, 04:02:31 pm »
Is it really that difficult?

Just save the player's location and time, assuming the map doesn't change, and just put him back there and run the jail function.
Out of the Garry's Mod business.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: ULX Jail save
« Reply #6 on: February 19, 2015, 11:49:03 pm »
Is it really that difficult?

Just save the player's location and time, assuming the map doesn't change, and just put him back there and run the jail function.

That's not how ulx jail works. It uses curtime to determine it. Think of it this way.

Lets say I jail PLAYER1 for 60 seconds. He leaves at 30 seconds, so there is 30 seconds remaining, the way ULX jail is, there is just the number of how many seconds he was jailed for, then a curtime t determine when we'll get out.

So we need to determine how much time is left using CurTime, which is not hard and is completed, my issue is to set time back to zero if player left and rejoined, then when time was still counting, there seems to be a glitch with it, causing my reset to reset at the start, and I do not know why, because according to ULX, it should only be ran once.. but it is not.

Though at the same time, ulx enjoys being complicated when it comes down to it.

If you want to see my code, here, I give up:
Jail Code:
Code: Lua
  1. ------------------------------ Jail ------------------------------
  2. local doJail
  3. local jailableArea
  4. function ulx.jail( calling_ply, target_plys, seconds, should_unjail )
  5.         local affected_plys = {}
  6.         for i=1, #target_plys do
  7.                 local v = target_plys[ i ]
  8.  
  9.                 if not should_unjail then
  10.                         if ulx.getExclusive( v, calling_ply ) then
  11.                                 ULib.tsayError( calling_ply, ulx.getExclusive( v, calling_ply ), true )
  12.                         elseif not jailableArea( v:GetPos() ) then
  13.                                 ULib.tsayError( calling_ply, v:Nick() .. " is not in an area where a jail can be placed!", true )
  14.                         else
  15.                                 doJail( v, seconds )
  16.                                 v:SetPData("UlxDBJail",seconds)
  17.                                 v:SetPData("UlxDBJailCurTime",math.Round(CurTime()))
  18.                                 table.insert( affected_plys, v )
  19.                         end
  20.                 elseif v.jail then
  21.                         v.jail.unjail()
  22.                         v.jail = nil
  23.                         table.insert( affected_plys, v )
  24.                 end
  25.         end
  26.  
  27.         if not should_unjail then
  28.                 local str = "#A jailed #T"
  29.                 if seconds > 0 then
  30.                         str = str .. " for #i seconds"
  31.                 end
  32.                 ulx.fancyLogAdmin( calling_ply, str, affected_plys, seconds )
  33.         else
  34.                 ulx.fancyLogAdmin( calling_ply, "#A unjailed #T", affected_plys )
  35.         end
  36. end
  37. local jail = ulx.command( CATEGORY_NAME, "ulx jail", ulx.jail, "!jail" )
  38. jail:addParam{ type=ULib.cmds.PlayersArg }
  39. jail:addParam{ type=ULib.cmds.NumArg, min=0, default=0, hint="seconds, 0 is forever", ULib.cmds.round, ULib.cmds.optional }
  40. jail:addParam{ type=ULib.cmds.BoolArg, invisible=true }
  41. jail:defaultAccess( ULib.ACCESS_ADMIN )
  42. jail:help( "Jails target(s)." )
  43. jail:setOpposite( "ulx unjail", {_, _, _, true}, "!unjail" )

Other Codes (The initial spawn was created, the disconnected one was already there, so make sure to replace it and not make another disconnect or errors will occur)
Code: Lua
  1. local function jailDisconnectedCheck( ply )
  2. local OldCurentTime = tonumber(ply:GetPData("UlxDBJailCurTime"))
  3. local TotoalJailTime = tonumber(ply:GetPData("UlxDBJail"))
  4. --if OldCurentTime == nil || TotoalJailTime == nil then return end
  5. local RemaingTime = (math.Round(CurTime()) - OldCurentTime)
  6. if TotoalJailTime > RemaingTime then
  7. local NewJailTime = (TotoalJailTime - RemaingTime)
  8. ply:SetPData("UlxDBJail",tonumber(NewJailTime))
  9. ply:SetPData("UlxDBJailCurTime",math.Round(CurTime()))
  10. MsgN(NewJailTime)
  11. end
  12.  
  13.         if ply.jail then
  14.                 ply.jail.unjail()
  15.         end
  16. end
  17. hook.Add( "PlayerDisconnected", "ULXJailDisconnectedCheck", jailDisconnectedCheck )
  18.  
  19. function CheckULXJailAgain(ply)
  20.         timer.Simple(3,function()
  21.                 local WhatTheTime = tonumber(ply:GetPData("UlxDBJail"))
  22.                 if WhatTheTime == nil then return end
  23.                 MsgN(WhatTheTime)
  24.                         if WhatTheTime == 0 then
  25.                                 return
  26.                         elseif WhatTheTime > 0 then
  27.                                 doJail(ply, WhatTheTime)
  28.                         end
  29.         end)
  30. end
  31. hook.Add( "PlayerInitialSpawn", "CheckULXJailAgain", CheckULXJailAgain )
« Last Edit: February 20, 2015, 12:17:19 am by Bite That Apple »
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline BobTheDuck69

  • Newbie
  • *
  • Posts: 33
  • Karma: 1
Re: ULX Jail save
« Reply #7 on: March 12, 2015, 11:27:17 am »
I tried it and the jails broke are you perhaps missing anything? the code looks ok but is slightly broken on my server where i was messing with it.
~The friendly neighborhood duckie~

  • Print