[DarkRP] Need Lua Help

So I’m creating a script in which removes the possibility of someone leaving during being arrested. Now, they can leave… However, when they join back they’ll be arrested.

So, I have the following in my cl_aap.lua:

if ply:isArrested()
		net.Start( "isArrested" )

Here is what is in my sv_aap.lua:

net.Receive( "isArrested", function GM:PlayerDisconnected( ply )


end )

What would I put in the Player Disconnected function on the server side? I mean how would I go about doing this? Would I put a GM:PlayerConnect function nesting within the PlayerDisconnected function? I mean I’m so lost.

Please help, thanks :slight_smile:

Wait, so do you want them to be un-arrested when they join back on or something?

No, I want them to be arrested when they join back.

-snip wasnt reading right-

Also, this:

net.Receive( "isArrested", function GM:PlayerDisconnected( ply )

Is a very bad idea in my opinion and I’m surprised if that even works

dammit automerge

Why is it a bad idea?

that’s not a valid function declaration,
I think what you’re looking for is
hook.Call(“PlayerDisconnected”, net.ReadEntity())

net.Receive("isArrested" function()
 hook.Call("PlayerDisconnected", net.ReadEntity())

Also in the OP you’re missing a “then” after “isArrested”

now this doesn’t really solve your problem, what you need to do is unfortunately, scrap this code altogether and make all of this serverside. No net messages or anything.

local arrested_players = {} -- declare table of arrested players

-- You need to hook or at least set up your arrest function so that it inserts each arrested player into the table, and then after each player's arrest timer is up it removes them from that table.
-- Don't use these functions, just add what I've added
function ply:Arrest()
table.insert(arrested_players, self)

function ply:Unarrest()
table.remove(arrested_players, self)

-- then you need to hook to initialspawn, to check if a currently arrested player is rejoining the server
local function checkingPlayersforArrests(ply)
if table.HasValue(arrested_players, ply) then
-- do shit
hook.Add("PlayerInitialSpawn", "kwnfldsknfdklsfn", checkingPlayersforArrests )

^ this is a gist of how DarkRP handles it.

Hmmmm… Then why does it show this in the wiki:

function GM:PlayerDisconnected( ply )
	 PrintMessage( HUD_PRINTTALK, ply:Name().. " has left the server." )

I’m so confused :(… I’m new to Lua, so sorry for my ignorance in GLua.

Also, thanks for pointing that out. If statements are my worst enemy. I always forget the “then”. I also forget the “do” when I create my loops lmao.

That’s alright, I edited my post with more information related to your issue, but you didn’t give me much information about your arrest system so that’s all the help i can give you

Thanks bro, so is that how DarkRP handles arrested players?

DarkRP already does this if you’re using the latest version: source

DarkRP already keeps a player arrested on disconnect, and it’s been like that for a long ass time.

Hmmm, I guess I fucked something up. It doesn’t on my server.

EDIT: I fixed it. Yeah, I had to delete a couple addons.