Auto jail issue, when reconnects [Simple]
#1

I have a jail system, it cannot be evaded even if a player quits and come back. Theres a timer added under ongamemodeinit and it calls in every second to see if the player jailed variable is set 0 and if it is 0, the player will be released from the jail. The script is set to jail the player when they spawn after the quit and join back [anti evade]. But the problem here is when someone quits and connect back, the variable is set to 0 on OnPlayerConnect [remember the timer is running every second], until they login and within seconds it calls that the player isnt in jail with the varible set as 0 as they connect. Heres the code so that you would understand it much better

pawn Код:
//Ongamemodeinit
SetTimer("AutoUnjail",1020,1);


//AutoJail as this calls in every second
public AutoUnjail(player1){
    if(PlayerInfo[player1][Jailed] == 1){
        if (PlayerInfo[player1][LJailTime] > 0){
            PlayerInfo[player1][LJailTime] --;
            new jtime;
            new string[128];
            jtime = (PlayerInfo[player1][LJailTime]);
            format(string, sizeof(string), "~w~JAILTIME..~n~ %d",jtime);
            GameTextForPlayer(player1, string, 3000,6);
            JailTimeServed[player1] ++;}
        if (PlayerInfo[player1][LJailTime] == 0){
            new pname[24];
            GetPlayerName(player1, pname, 24);
            new string[128];
            SetPlayerInterior(player1,3);
            SetPlayerPos(player1,210.5272,146.3341,1003.0234);
            SetPlayerFacingAngle(player1,179.4662);
            SetCameraBehindPlayer(player1);
            cannotescapejail[player1] =0;
            SendClientMessage(player1,0x00C7FFAA,"You have been released from jail. You are free to leave the area.");
            format(string, sizeof(string), "%s(%d) has been released from jail. JailTime Served: %d Seconds",pname,player1,JailTimeServed[player1]);
            SendClientMessageToAll(0x00C7FFAA, string);
            PlayerInfo[player1][Jailed] = 0;
            JailTimer[player1] = -1;
            JailTimeServed[player1] =0;}}}
I cant think of anything to fix this, any ideas to how to fix it would be appreciated
Reply
#2

Try this:

Код:
new bool:IsLoggedIn[MAX_PLAYERS];

forward AutoUnjail();

//OnGameModeInit
SetTimer("AutoUnjail", 1020, 1);

//OnPlayerDissconnect
IsLoggedIn[playerid] = false;

// when player successfully logs in
IsLoggedIn[playerid] = true;

//AutoJail as this calls in every second
public AutoUnjail()
{
    for(new i;i<MAX_PLAYERS;i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsLoggedIn[i])
            {
                if(PlayerInfo[i][Jailed] == 1)
                {
		    if(PlayerInfo[i][LJailTime] > 0)
                    {
                        new string[24];
        		format(string, sizeof(string), "~w~JAILTIME..~n~ %d",PlayerInfo[i][LJailTime]);
			GameTextForPlayer(i, string, 1000, 6);
			//------------------------------------------------------
			PlayerInfo[i][LJailTime] --;
			JailTimeServed[i] ++;
                    }
		    else if(PlayerInfo[i][LJailTime] == 0)
		    {
		        new pname[MAX_PLAYER_NAME], string[97];
		 	GetPlayerName(i, pname, MAX_PLAYER_NAME);
                        format(string, sizeof(string), "%s (%d) has been released from jail. JailTime Served: %d Seconds", pname, i, JailTimeServed[i]);
  			SendClientMessageToAll(0x00C7FFAA, string);
  			SendClientMessage(i,0x00C7FFAA,"You have been released from jail. You are free to leave the area.");
                        //------------------------------------------------------
			SetPlayerInterior(i,3);
			SetPlayerPos(i,210.5272,146.3341,1003.0234);
			SetPlayerFacingAngle(i,179.4662);
			SetCameraBehindPlayer(i);
			cannotescapejail[i] = 0;
		        PlayerInfo[i][Jailed] = 0;
			JailTimer[i] = -1;
			JailTimeServed[i] =0;
                    }
                }
            }	
        }
    }
    return 1;
}
Reply
#3

does the player's jail state have a saver?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)