Jump to content

Jail for time


MarxVen

Recommended Posts

Hi. On the gamemode mta paradise I would do prison time. I would like to do in the database the "jail" (table: characters).

When the policeman enters a command /jail nickname time value in the database is changed to (for example) 30 (minutes).

Function setTimer every minute changed to the value of the one below (if a player would be in the interior of the prison.). And when was the value to 0 to automatically moved him out of prison.

function jailForTime ( thePlayer ) 
if ( getElementInterior(thePlayer) == 150 and getElementDimension(thePlayer) == 5000) then -- numbers is random 
    exports.sql:query_free( "UPDATE characters SET jail=jail-1 WHERE characterName = " .. getPlayerName( thePlayer ) ) 
end 
     
end 
setTimer ( jailForTime, 60000, 0 ) 

It will help someone to do it? I can throw into prison.

Sorry for bad english.

Link to comment

another way would be to just save the player/account name to a table of jailed players along with the jail

duration in mins then on reconnect check their name to see if it exists, if it does, rejail them.

then u just have a function looped every 1min decreasing the jailed players mins left and releasing those

who's time is up. this would save the need for mysql and be a lot quicker to make.

of course, if u stop the script, the names are lost, so i guess it depends on what u really need.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...