Jailed help?
#1

So here is my code for when a player is jailed by police:

pawn Код:
new pwl = GetPlayerWantedLevel(ID);
    if(pwl == 3)
    {
        format(string, sizeof(string), "Police Officer %s (%d) has arrested wanted suspect %s (%d).", pname, playerid, opname, ID);
        SendClientMessageToAll(COLOR_BLUE, string);
        format(string, sizeof(string), "[POLICE RADIO] Suspect %s (%d) has been sent to jail.", opname, ID);
        SendCopMessage(string);
        GivePlayerMoney(playerid, 3000);
        IncreaseScore(playerid, 2);
        SetPVarInt(ID, "JailTime", 45);
        SetPlayerInterior(ID, 10);
        new rnd = random(sizeof(PrisonSpawn));
        SetPlayerPos(ID, PrisonSpawn[rnd][0], PrisonSpawn[rnd][1], PrisonSpawn[rnd][2]);
        SendClientMessage(playerid, COLOR_GREY, "**LOS SANTOS PRISON**");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "[PRISON] You have been sent to prison. You will be released soon.");
        TogglePlayerControllable(ID, 1);
        SetPlayerWantedLevel(ID, 0);
        return 1;
    }
So on his/her screen it will show the jail time counting down. When jail time go to "0" the player in jail will be released to my desired spot. But when the player gets out of jail, the timer on the screen still say JAIL TIME -1, JAIL TIME -2, JAIL TIME -3 and it will keep on going to -9999999+ and when the player moves, he/she will be put back to the "out of jail" location and it will keep on counting down and teleporting it back to the respawn position. Can someone please help me on this or what I'm doing wrong? Thanks
Reply
#2

Can people please help? +REP
Reply
#3

When the countdown goes to 0 try this:
pawn Код:
KillTimer(your/jail/timer/name);
Reply
#4

Sorry to bump this, but I have the exact same issue, but weirdly, I'm killing the timer actually...

Код:
command(arrest, playerid, params[])
{
	if(Player[playerid][Faction] == 1)
	{
	    if(IsPlayerInRangeOfPoint(playerid, 10.0, 221.5584, 121.7303, 999.9156))
	    {
			new id, time, string[256];
			if(sscanf(params, "ui", id, time)) return SendClientMessage(playerid, WHITE, "Server: /arrest [playerid/name] [time(minutes)]");
			{
			    if(time > 60) return SendClientMessage(playerid, WHITE, "The arrest time can only be from 1 - 60 minutes.");
				if(GetDistanceBetweenPlayers(playerid, id) <= 5.0)
				{
				    ArrestTimer[playerid] = SetTimerEx("UnjailTimer", 60000, 1, "i", id);
				    format(string, sizeof(string), "You have been arrested by %s %s for %i minutes.", GetRankName(playerid), MaskOnOff(playerid), time);
					SendClientMessage(id, BLUE, string);
					Player[id][JailTime] = time;
					SetPlayerPos(id, 264.4176, 77.8930, 1001.0391);
					SetPlayerInterior(id, 6);
					format(string, sizeof(string), "You have arrested %s for %i minutes.", MaskOnOff(id), time);
					SendClientMessage(playerid, WHITE, string);
				}
				else return SendClientMessage(playerid, WHITE, "You must be near to that player.");
			}
		}
		else return SendClientMessage(playerid, WHITE, "You aren't near the Sheriff Department arresting location.");
	}
	else return SendClientMessage(playerid, WHITE, "You aren't in the correct Faction.");
	return 1;
}
StartTimer public...

Код:
if(Player[playerid][JailTime] >= 1)
		{
		    ArrestTimer[playerid] = SetTimerEx("UnjailTimer", 60000, 1, "i", playerid);
		}
		else
		{
		    KillTimer(ArrestTimer[playerid]);
		}
UnjailTimer public...

Код:
public UnjailTimer(playerid)
{
	new string[128];
	
	if(Player[playerid][JailTime] != 0)
	{
		Player[playerid][JailTime] --;
		format(string, sizeof(string), "You have %d minutes left in Jail.", Player[playerid][JailTime]);
		SendClientMessage(playerid, BLUE, string);
		SaveStats(playerid);
	}
	else
	{
		SetPlayerPos(playerid, 628.9576, -543.6878, 16.3694);
		SetPlayerInterior(playerid, 0);
		TogglePlayerControllable(playerid, 1);
		SendClientMessage(playerid, WHITE, "You have been released from prison. Be good next time!");
  		KillTimer(ArrestTimer[playerid]);
		Player[playerid][JailTime] = 0;
		SaveStats(playerid);
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)