Help for My DarkRP Server

I’m building a darkrp server.I want players to spend some time becoming a job.
For Example;
a player must spend at least 3 hours on the server to become a Cop.
How could i do?

Programm .

13 Likes

thanks mark

If you’ve got Utime installed on your server you can use player:GetUTimeTotalTime() in your job’s customCheck function (Or the playerCanChangeTeam hook if you want it to apply to every police job) and check if the resulting number is equal or greater than 10800 (3 hours in minutes)

Examples on how to implement customCheck can be found on the DarkRP wiki.

Can you show an example on this:

TEAM_POLIC = DarkRP.createJob(“Police Officer”, {
color = Color(42, 147, 194, 255),
model = {
“models/humans/nypd1940/male_01.mdl”
},
description = [[dscp]],
weapons = {“tfa_doim1911”, “weapon_r_handcuffs”, “arrest_baton”},
command = “polism”,
max = 6,
salary = 3000,
admin = 0,
vote = false,
hasLicense = true,
candemote = true,
category = “Government”
})

So if you have uTime installed, you can check time with this:

ply:GetUTimeTotalTime() >= <number in seconds>

example for 1 hour:

ply:GetUTimeTotalTime() >= 3600

And here is your example Police job, where only people who played >1h can play it:

TEAM_POLICE = DarkRP.createJob("Police Officer", {
    color = Color(42, 147, 194, 255),
    model = {
        "models/humans/nypd1940/male_01.mdl"
    },
    description = [[dscp]],
    weapons = {"tfa_doim1911", "weapon_r_handcuffs", "arrest_baton"},
    command = "polism",
    max = 6,
    salary = 3000,
    admin = 0,
    vote = false,
    hasLicense = true,
    candemote = true,
    category = "Government",
    customCheck = function(ply) 
        return (ply:GetUTimeTotalTime() >= 3600) // 3600 seconds = 60 mins = 1 hour
    end,
    CustomCheckFailMsg = "You haven't played an hour yet, so you can't get this job!",
})
2 Likes

thx pal