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;
}
JailTimer[playerid] = SetTimerEx("UpdateJailSystem", 1000, true, "i", playerid);
JailTimer[playerid] = SetTimerEx("UpdateJailSystem", 100, true, "i", playerid);
You sould kill the timer, otherwise you will have the same timer executing over and over.
|
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; KillTimer(JailTimer[playerid]); PutPlayerInJail(playerid); //will put the playerid in jail as a takendown (arrest) IncreaseScore(killerid, 1); SendDeathMessage(killerid, playerid, reason); } } return 1; }
worked, i killed it on OnPlayerDeath,, but why it worked ? o,o |