18.01.2014, 21:29
i wonder why is this not working !!!
when a cop kills a wanted player, the player will go to jail and will appear to him a clock time of how much time remaining till he released from jail.
everything is working but the time is moving quickly, not "seconds" ...here is the code: do i miss returns or something?!
Note: i tested this on /arrest command and worked perfect, but it's not working on "OnPlayerDeath"
when a cop kills a wanted player, the player will go to jail and will appear to him a clock time of how much time remaining till he released from jail.
everything is working but the time is moving quickly, not "seconds" ...here is the code: do i miss returns or something?!
Note: i tested this on /arrest command and worked perfect, but it's not working on "OnPlayerDeath"
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(LawEnforcementMode[killerid] == true) //check if the killer is a cop or law enforcement
{
if(PlayerTeam[playerid] != TEAM_CIV || PlayerTeam[playerid] == TEAM_CIV && GetPlayerWantedLevel(playerid)<=3)
{ //if the player that has been killed is not civilian or civilian and his wanted level is less than 3
DecreaseScore(killerid, 1); // it will decrease the killerid score by 1
SendDeathMessage(killerid, playerid, reason);
}
else
{ //else if he is civilian and his wanted level is greater than 3
PlayerInfo[playerid][pJailTime] = (GetPlayerWantedLevel(playerid)*60)/4;
PutPlayerInJail(playerid); //will put the playerid in jail as a takendown (arrest)
IncreaseScore(killerid, 1);
SendDeathMessage(killerid, playerid, reason);
}
}
return 1;
}
public PutPlayerInJail(playerid)
{
new Random = random(sizeof(RandomJail));
SetPlayerInterior(playerid,3);
SetPlayerVirtualWorld(playerid,1);
SetPlayerPos(playerid, RandomJail[Random][0], RandomJail[Random][1], RandomJail[Random][2]);
SetPlayerFacingAngle(playerid, RandomJail[Random][3]);
SetCameraBehindPlayer(playerid);
SetPlayerWantedLevel(playerid, 0);
SetPlayerHealth(playerid, 100);
JailTimer[playerid] = SetTimerEx("UpdateJailSystem", 1000, true, "i", playerid);
//jail timer is for showing the clock textdraw (how much time is remaining till release from jail)
return 1;
}
public UpdateJailSystem(playerid)
{
if(PlayerInfo[playerid][pJailTime] > 0)
{
new string[128], gseconds, gminutes;
gseconds = PlayerInfo[playerid][pJailTime] % 60;
gminutes = (PlayerInfo[playerid][pJailTime] - gseconds) / 60;
PlayerInfo[playerid][pJailTime] --;
format(string, sizeof string, "%d:%02d", gminutes, gseconds);
TextDrawSetString(JailTimeClock[playerid], string);
TextDrawShowForPlayer(playerid, JailTimeClock[playerid]);
}
else
{
ReleasePlayerFromJail(playerid);
}
return 1;
}