/jail command help
#1

I quit my server when i in jail , then how to let me in jail after login
I have a login system already, how to add in
this is my jail command

PHP Code:
COMMAND:jail(playeridparams[])
    {
        if(!
IsPlayerAdmin(playerid))return 0;
        {
            new 
targetid,reason;
            if(
sscanf(params"dds"targetidsecond,reason)) return SendClientMessage(playeridCOLOR_RED,"[USAGE]:{FFFFFF}/jail [playerid][second][reason]"); //detects the wrong params and show the usage
            
if(PInfo[targetid][pJail] == 1)return SendClientMessage(playeridCOLOR_RED,"[ERROR]:{FFFFFF}This player is already in jail.");
            {
                new 
str[128];
                
format(strsizeof(str), "{FF02A7}[ADMIN]:{fFFFFF}%s has jailed %s for %d second.{00ff00}[REASON]:%s"Name(playerid), Name(targetid), second,reason); //get the admin's name, the player's and show the minutes
                
SendClientMessageToAll(COLOR_LIGHTBLUE,str); //let everybody know what you did, this will send the message to everyone
                
SetPlayerPos(targetid, -1346.5848,1323.8483,2.4516); //Sets the player's position to the jail in LS
                
PInfo[targetid][pJail] = 1//now, here we'll check, if the player's in jail, we'll set the value to "true", means that he IS in jail
                
GameTextForPlayer(targetid"~p~JAILED"50006); //this is for decorating and writing a big "JAILED" for the player
                
PlayerPlaySound(targetid,1057,0.0,0.0,0.0); //that's also a small sound, for decoration
                
SetPlayerHealth(targetid9999);
                
ResetPlayerWeapons(targetid);
                
PInfo[playerid][pJailTimer] = second;
                
JailTimer[targetid] = SetTimerEx("Unjail",second*1000false"i"playerid);
                }
        }
        return 
1;

PHP Code:
forward Unjail(playerid);
public 
Unjail(playerid//this was the name of the timer (Unjail), if you remember
{
    
SetPlayerPos(playerid, -1388.3654,1346.0662,2.7087); //we'll set the interior to "0", which means to the normal world
    
PInfo[playerid][pJail] = 0//we'll set the value of the variable to "false" here, that means he isn't in jail anymore
    
GameTextForPlayer(playerid"~g~Unjailed"10006); //this is for decoration again, will display "UNJAILED"
    
PlayerPlaySound(playerid,1057,0.0,0.0,0.0); //a smart "success-sound" again
    
SetPlayerHealth(playerid100);
    
PInfo[playerid][pJailTimer] = 0;

Reply
#2

You need to save it in the player's file and load it when he logins onto the server.
Reply
#3

pawn Code:
public OnPlayerSpawn(playerid)
{
    if(PInfo[playerid][pJail] = 1);
    {
        SetPlayerPos(playerid, -1346.5848,1323.8483,2.4516);
        SendClientMessage(playerid, -1, "You are still in Jail. You can't escape !");
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by HY
View Post
pawn Code:
public OnPlayerConnect(playerid)
{
    if(PInfo[playerid][pJail] = 1);
    {
        SetPlayerPos(playerid, -1346.5848,1323.8483,2.4516);
        SendClientMessage(playerid, -1, "You are still in Jail. You can't escape !");
    }
    return 1;
}
Wrong.

Its:
pawn Code:
public OnPlayerSpawn(playerid)
{
    if(PInfo[playerid][pJail] == 1);
    {
        SetPlayerPos(playerid, -1346.5848, 1323.8483, 2.4516);
        SendClientMessage(playerid, -1, "You are still in Jail. You can't escape!");
    }
    return 1;
}
Reply
#5

Under OnPlayerSpawn
pawn Code:
if(JailTimer[playerid] > 0) //do your jail timer here if > 0
    {
     PInfo[playerid][pJail] = 1; //send player to jail
    }
that if you already save jail timer when player quit

else

pawn Code:
if(PInfo[playerid][pJail] == 1)
{
   SetPlayerPos(playerid, -1346.5848,1323.8483,2.4516); //set player post in LS jail
   JailTimer[playerid] = SetTimerEx("Unjail",second*1000, false, "i", playerid); //start the timer to unjail
}
Don't forget to save if player jailed in OnPlayerDisconnect
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)