DarkRP Arrest system

How do you get the remaining time of an arrest.

[editline]1st December 2016[/editline]

client side tho

Can’t get it client side. You need to set up a custom function of when a person gets arrested that counts how long that person has been arrested for.

The guy above me is correct, the work around I made was this;

if SERVER then
	hook.Add( "playerArrested", "CW_Station_sergeantTimeSet", function( ply, time, arrester )
		if not IsValid( ply ) or not time then return end

		ply:setDarkRPVar( 'CW_arrestedUntil', CurTime() + time )
	end )

Then just get the value when you need it. Probably a better way to do it

Would you also need the config time for arrest to finish the thing so it would be like

time = GM.Config.arrestspeed

Why are you doing CurTime() + time?
Wouldn’t that just be adding seconds to it? If he would want the remaining time it would have to be

if SERVER then
    hook.Add("playerArrested", "RandomName", function(ply, time)

        local timetableAS = {}
        timetableAS.starttime = CurTime()
        timetableAS.arresttime = time

        ply:setDarkRPVar("ASTimeLeft", timetableAS)


local function getTimeLeft(ply)

    local timetable = ply:getDarkRPVar("ASTimeLeft")

    return timetable.arresttime - (CurTime() - timetable.starttime)


You can use the function to get the time.
It’s up to you to make sure the guy is in jail and still has time left.

With his method you could just do

local arrestedTime = LocalPlayer():getDarkRPVar("CW_arrestedUntil") - CurTime()

Ah, I didn’t notice that. That does make more sense.

Also, I am trying to do this but apparently I have to register DarkRPVars, never done that before. Is there a guide on that anywhere? I saw the syntax for it but I don’t understand it.


Nvm, figured it out.