06.01.2013, 17:48
As title say's i did jail command with unjail timer all is saved. Problem is after i jail for test 1 minute timer wont unjail me.
And when player connects again timer is started again
So how to fix the timer so it release jailed player when jail time is done...
pawn Код:
YCMD:jail(playerid, params[],help)
{
new targetid, timer,reason[64],string[512];
if(!(PlayerInfo[playerid][pFaction] == 1)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You are not authorized to use this command!");
if(!(IsPlayerInRangeOfPoint(playerid, 15.0, 1492.7723,-1763.2980,3285.2859))) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You must be in LSPD cell area to jail somewone!");
if(playerid == targetid) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot jail yourself!");
{
if(sscanf(params, "uds[64]",targetid, timer, reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /jail [ID] [Minutes] [Reason]");
{
new str[512];
format(str,sizeof str,"You were jailed by: %s for: %i minute(s), reason: %s",GetName(playerid),timer,reason);
SendClientMessage(targetid,COLOR_RED,str);
format(str,sizeof str,"You jailed : %s for: %i minute(s), reason: %s",GetName(targetid),timer,reason);
SendClientMessage(playerid,COLOR_BLUE,str);
ResetPlayerWeapons(targetid);
GivePlayerMoney(targetid, -5000);
GivePlayerMoney(playerid, 5000);
format(string, sizeof(string), "You have earned $5000 for your hard work.",string);
ShowDescriptionText(playerid, string);
PlayerInfo[targetid][pJailed] = 1;
PlayerInfo[targetid][pJailTime] = timer*1000;
unjailtimer[targetid]= SetTimerEx("UnJail",PlayerInfo[targetid][pJailTime]*60,false,"d",targetid);
SavePlayer(targetid);
return 1;
}
}
}
forward UnJail(playerid);
public UnJail(playerid)
{
if(PlayerInfo[playerid][pJailTime] == 0)
{
KillTimer(unjailtimer[playerid]);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(playerid, 1552.6873,-1673.5428,16.1953);
SendClientMessage(playerid, 0xFF0000AA, "You Have Been Released From Jail!");
PlayerInfo[playerid][pJailed] = 0;
PlayerInfo[playerid][pJailTime] = 0;
SavePlayer(playerid);
}
return 1;
}
pawn Код:
if(PlayerInfo[playerid][pJailed] == 1)
{
new string[512];
unjailtimer[playerid]= SetTimerEx("UnJail",PlayerInfo[playerid][pJailTime]*60,false,"d",playerid);
format(string, sizeof(string), "You didn't serve your sentence.Returning you back to the jail.",string);
ShowDescriptionText(playerid, string);
}