So, I have a thought. Is there anyway to have ULX automatically jail a player if they relog?
[QUOTE=Rocket;51707601]Perhaps if someone keeps disconnecting to get out of jail, you should just ban them.[/QUOTE]
Well yeah, but when things are getting crazy and people quickly rejoin to mass rdm itd be handy to have this feature.
Just keep a server table with jailed steam IDs, and check on player initial join if their steam ID is in said table.
[QUOTE=Nookyava;51708256]Just keep a server table with jailed steam IDs, and check on player initial join if their steam ID is in said table.[/QUOTE]
How would one do that? ( I realize you explained it pretty clearly, though I'm new and not very good with Lua )
Easier than keeping track of who was jailed is just ban people who leave during jail. Add a hook to PlayerDisconnect and check if they were jailed during disconnect. If so, ban them. Maybe modify the jail function to add a notice that they will be banned if they leave while jailed.
Try something like this, did this on my tablet so cant test so it may error please let me know if it does.
[LUA]
//CONFIG//
local returnToPos = true
//CONFIG//
local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
table.insert(jailedPlayers, {id = ply:SteamID64(), pos = ply:GetPos()})
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
for k, v in pairs(jailedPlayers) do
if v.id == ply:SteamID64() then
if returnToPos then
ply:SetPos(v.pos)
ply:SetLocalVelocity(Vector(0, 0, 0))
end
game.ConsoleCommand("ulx jail \""..ply:Nick().."\"\n")
end
end
end)
[/LUA]
Edit:
Its serverside
[QUOTE=rtm516;51713703]Try something like this, did this on my tablet so cant test so it may error please let me know if it does.
[LUA]
//CONFIG//
local returnToPos = true
//CONFIG//
local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
table.insert(jailedPlayers, {id = ply:SteamID64(), pos = ply:GetPos()})
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
for k, v in pairs(jailedPlayers) do
if v.id == ply:SteamID64() then
if returnToPos then
ply:SetPos(v.pos)
ply:SetLocalVelocity(Vector(0, 0, 0))
end
game.ConsoleCommand("ulx jail \""..ply:Nick().."\"\n")
end
end
end)
[/LUA]
Edit:
Its serverside[/QUOTE]
Alright, Placed this in lua\autorun\server\jail_dc.lua
I jailed myself, disconnected & rejoined. Doesn't seem to be working.
[QUOTE=LOT;52072086]Alright, Placed this in lua\autorun\server\jail_dc.lua
I jailed myself, disconnected & rejoined. Doesn't seem to be working.[/QUOTE]
WELL OBVIOUSLY IT WONT WORK IN SINGLE PLAYER AS VARIABLES IN THE CODE ABOVE ONLY EXIST IN MEMORY FOR AS LONG AS THE SERVER / GAME IS RUNNING. IF YOU WANT TO FAIL-PROOF SOLUTION, STORE IT IN A FILE USING FILE.WRITE.
[highlight](User was banned for this post ("Why reply - WHY ARE WE SHOUTING, LOUD NOISES" - Reagy))[/highlight]
[QUOTE=rtm516;51713703]Try something like this, did this on my tablet so cant test so it may error please let me know if it does.
[LUA]
//CONFIG//
local returnToPos = true
//CONFIG//
local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
table.insert(jailedPlayers, {id = ply:SteamID64(), pos = ply:GetPos()})
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
for k, v in pairs(jailedPlayers) do
if v.id == ply:SteamID64() then
if returnToPos then
ply:SetPos(v.pos)
ply:SetLocalVelocity(Vector(0, 0, 0))
end
game.ConsoleCommand("ulx jail \""..ply:Nick().."\"\n")
end
end
end)
[/LUA]
Edit:
Its serverside[/QUOTE]
my name is actually ";ulx ban *;echo "
[QUOTE=MeepDarknessM;52072763]my name is actually ";ulx ban *;echo "[/QUOTE]
I'm pretty confused still
[QUOTE=LOT;52072831]I'm pretty confused still[/QUOTE]
It would ban everyone.
A better solution would be "ulx jail $steamid", where steamid is replaced with the player's steamid.
[QUOTE=maksimiljan;52072862]It would ban everyone.
A better solution would be "ulx jail $steamid", where steamid is replaced with the player's steamid.[/QUOTE]
No, I got that but the script itself doesn't work.
[lua]
//CONFIG//
local returnToPos = true
//CONFIG//
local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
table.insert(jailedPlayers, {id = ply:SteamID64(), pos = ply:GetPos()})
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
for k, v in pairs(jailedPlayers) do
if v.id == ply:SteamID64() then
if returnToPos then
ply:SetPos(v.pos)
ply:SetLocalVelocity(Vector(0, 0, 0))
end
game.ConsoleCommand( "ulx jail ""..ply:SteamID().."\"\n")
end
end
end)
[/lua]
[QUOTE=LOT;52072870]No, I got that but the script itself doesn't work.
[lua]
//CONFIG//
local returnToPos = true
//CONFIG//
local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
table.insert(jailedPlayers, {id = ply:SteamID64(), pos = ply:GetPos()})
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
for k, v in pairs(jailedPlayers) do
if v.id == ply:SteamID64() then
if returnToPos then
ply:SetPos(v.pos)
ply:SetLocalVelocity(Vector(0, 0, 0))
end
game.ConsoleCommand( "ulx jail ""..ply:SteamID().."\"\n")
end
end
end)
[/lua][/QUOTE]
Use RunConsoleCommand.
[editline]7th April 2017[/editline]
[CODE]//CONFIG//
local returnToPos = true
//CONFIG//
local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
table.insert(jailedPlayers, {id = ply:SteamID(), pos = ply:GetPos()})
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
for k, v in pairs(jailedPlayers) do
if v.id == ply:SteamID() then
timer.Simple( 0, function()
if returnToPos then
ply:SetPos(v.pos)
ply:SetLocalVelocity(Vector(0, 0, 0))
end
RunConsoleCommand( "ulx", "jail", "$" .. ply:SteamID() )
end )
end
end
end)[/CODE]
To target via steamid with ulx you have to preface it with a $
IE "ulx jail $steam_0"
[QUOTE=maksimiljan;52072953]Use RunConsoleCommand.
[editline]7th April 2017[/editline]
[CODE]//CONFIG//
local returnToPos = true
//CONFIG//
local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
table.insert(jailedPlayers, {id = ply:SteamID(), pos = ply:GetPos()})
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
for k, v in pairs(jailedPlayers) do
if v.id == ply:SteamID() then
timer.Simple( 0, function()
if returnToPos then
ply:SetPos(v.pos)
ply:SetLocalVelocity(Vector(0, 0, 0))
end
RunConsoleCommand( "ulx", "jail", "$" .. ply:SteamID() )
end )
end
end
end)[/CODE][/QUOTE]
Damn, okay I wish I could say this worked but doesn't seem to be. I don't think I saw any errors either.
Tried to do it without for loops for fun maybe it'll work :
[code]local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
jailedPlayers[ply:SteamID()] = true
jailedPlayers[ply:SteamID()].pos = ply:GetPos()
else
jailedPlayers[ply:SteamID()] = nil
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
if (jailedPlayers[ply:SteamID()]) then
ply:SetPos(jailedPlayers[ply:SteamID()].pos)
ply:SetLocalVelocity(Vector(0, 0, 0))
RunConsoleCommand( "ulx", "jail", "$" .. ply:SteamID() )
end
end)[/code]
[QUOTE=bilbasio;52073197]Tried to do it without for loops for fun maybe it'll work :
[code]local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
jailedPlayers[ply:SteamID()] = true
jailedPlayers[ply:SteamID()].pos = ply:GetPos()
else
jailedPlayers[ply:SteamID()] = NULL
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
if (jailedPlayers[ply:SteamID()]) then
ply:SetPos(jailedPlayers[ply:SteamID()].pos)
ply:SetLocalVelocity(Vector(0, 0, 0))
RunConsoleCommand( "ulx", "jail", "$" .. ply:SteamID() )
end
end)[/code][/QUOTE]
Atleast this time something happened.
Anyways, joined, jailed myself & rejoined.
[IMG]https://i.gyazo.com/abbb1a3ad693c4318e085b8ef177bb88.jpg[/IMG]
[QUOTE=LOT;52073246]Atleast this time something happened.
Anyways, joined, jailed myself & rejoined.
[IMG]https://i.gyazo.com/abbb1a3ad693c4318e085b8ef177bb88.jpg[/IMG][/QUOTE]
Did you get teleported to the same place you got jailed? And did you actually get jailed after joining?
[QUOTE=bilbasio;52073277]Did you get teleported to the same place you got jailed? And did you actually get jailed after joining?[/QUOTE]
No, I didn't move from spawn when I first jailed myself. & No, it didn't jail me. Just broke DarkRP.
[IMG]https://i.gyazo.com/827dbae9a09081062b9785cb792e2ab0.jpg[/IMG]
Yeah after testing my code I realize table don't work like that let me find a solution.
well you could do this.
[code]
local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
jailedPlayers[ply:SteamID()] = ply:GetPos()
else
jailedPlayers[ply:SteamID()] = nil
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
if (jailedPlayers[ply:SteamID()]) then
ply:SetPos(jailedPlayers[ply:SteamID()])
ply:SetLocalVelocity(Vector(0, 0, 0))
RunConsoleCommand( "ulx", "jail", "$" .. ply:SteamID() )
end
end)
[/code]
[code]local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
jailedPlayers[ply:SteamID()] = true
else
jailedPlayers[ply:SteamID()] = nil
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
if (jailedPlayers[ply:SteamID()]) then
RunConsoleCommand( "ulx", "jail", "$" .. ply:SteamID() )
end
end)[/code]
This will most certainly work but it will not put them back to the same position.
[editline]8th April 2017[/editline]
[QUOTE=Defender2015;52073405]well you could do this.
[code]
snip
[/code][/QUOTE]
Yes actually this is pretty clever
[QUOTE=Defender2015;52073405]well you could do this.
[code]
local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
jailedPlayers[ply:SteamID()] = ply:GetPos()
else
jailedPlayers[ply:SteamID()] = nil
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
if (jailedPlayers[ply:SteamID()]) then
ply:SetPos(jailedPlayers[ply:SteamID()])
ply:SetLocalVelocity(Vector(0, 0, 0))
RunConsoleCommand( "ulx", "jail", "$" .. ply:SteamID() )
end
end)
[/code][/QUOTE]
didn't work :C
[editline]7th April 2017[/editline]
[QUOTE=bilbasio;52073418][code]local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
jailedPlayers[ply:SteamID()] = true
else
jailedPlayers[ply:SteamID()] = nil
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
if (jailedPlayers[ply:SteamID()]) then
RunConsoleCommand( "ulx", "jail", "$" .. ply:SteamID() )
end
end)[/code]
This will most certainly work but it will not put them back to the same position.
[editline]8th April 2017[/editline]
Yes actually this is pretty clever[/QUOTE]
Worked!!! yet, like you said, doesn't save the location of the player. ( This could cause problems when they load into spawn. It'd trap others. )
EDIT:
Also, if I jailed someone & they dc. Everytime the relog ( even if I unjail them ) they will still be jailed on join
[QUOTE=LOT;52073494]didn't work :C
[editline]7th April 2017[/editline]
Worked!!! yet, like you said, doesn't save the location of the player. ( This could cause problems when they load into spawn. It'd trap others. )
EDIT:
Also, if I jailed someone & they dc. Everytime the relog ( even if I unjail them ) they will still be jailed on join[/QUOTE]
They should'nt be jailed since if they disconnect and ply.jail is false then it deletes the jailedplayers entry. Try to print the value of ply.jail of a player when they disconnect when they are jailed and when they are unjailed.
[CODE]local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
jailedPlayers[ply:SteamID()] = ply:GetPos()
else
jailedPlayers[ply:SteamID()] = nil
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
if jailedPlayers[ply:SteamID()] then
ply:SetPos( jailedPlayers[ply:SteamID()] )
for _, v in pairs( ulx.cmdsByCategory["Fun"] ) do
if v.cmd == "ulx jail" then
v:call( false, nil, { ply }, 0, false )
end
end
end
end)[/CODE]
Works just fine on my server.
[QUOTE=maksimiljan;52075864][CODE]local jailedPlayers = {}
hook.Add("PlayerDisconnected", "JailDisconnected", function(ply)
if ply.jail then
jailedPlayers[ply:SteamID()] = ply:GetPos()
else
jailedPlayers[ply:SteamID()] = nil
end
end)
hook.Add("PlayerInitialSpawn", "JailInitialSpawn", function(ply)
if jailedPlayers[ply:SteamID()] then
ply:SetPos( jailedPlayers[ply:SteamID()] )
for _, v in pairs( ulx.cmdsByCategory["Fun"] ) do
if v.cmd == "ulx jail" then
v:call( false, nil, { ply }, 0, false )
end
end
end
end)[/CODE]
Works just fine on my server.[/QUOTE]
Hm, then I'm doing something wrong. Let me test this again and get back to you guys with my stupidity.
Okay, so I tested this code above ^ put it in lua/autorun/server/jail_dc.lua
Doest seem to work at all?
Bump
Still having problems with this
[QUOTE=LOT;51709561]How would one do that? ( I realize you explained it pretty clearly, though I'm new and not very good with Lua )[/QUOTE]
- Who am I?: [B]I'm an 20 year old Lua Developer[/B]/3D Modeler/Graphic Designer/Gamer/Streamer.
???
This is a very simple task.
bro just become police chief and slap some noobs with ur arrest baton/stick its not that hard jeez
[QUOTE=fourny;52081981]- Who am I?: [B]I'm an 20 year old Lua Developer[/B]/3D Modeler/Graphic Designer/Gamer/Streamer.
???
This is a very simple task.[/QUOTE]
Adding jobs makes you a Lua Developer, didn't you know that?
Sorry, you need to Log In to post a reply to this thread.