16.08.2014, 06:11
Here is my code to reduce the players wanted level every 5 minutes (if they have stars and are not near a cop)
It did work at once point, but either i changed the code or something out of the ordinary is happening
Even if no cops are connect it still doesnt remove a star
The message "You should have lost a star" does appear in game but stars are not removed
It did work at once point, but either i changed the code or something out of the ordinary is happening
Even if no cops are connect it still doesnt remove a star
pawn Код:
forward WantedLevelReduce();
pawn Код:
public OnGameModeInit()
{
SetTimer("WantedLevelReduce",300_000, true);
pawn Код:
public WantedLevelReduce()
{
new string[100];
for(new i = 0; i < MAX_PLAYERS; i++)
{
new cop = Info[i][Team] == BP;
new plwl = GetPlayerWantedLevel(i);
if(Info[i][Team] != BP) return SendClientMessageToAll(COLOR_GREEN, "You should have lost a star"); //Just for debug to see if the star was supposed to be removed
if(plwl <= 0)
{
return 0;
}
if(plwl >= 1)
{
if(GetDistanceBetweenPlayers(i,cop) >= 80 || !IsPlayerConnected(cop))
{
SetPlayerWantedLevel(i, plwl -1);
plwl = GetPlayerWantedLevel(i);
format(string, sizeof(string), "Wanted Level Decreased To: %d",plwl);
SendClientMessage(i, GetPlayerColor(i), string);
}
}
}
return 1;
}