24.03.2014, 20:04
If you keep this in OnGameModeInit/OnFilterScriptInit:
then change to:
Else you'd have to set the timer when a player joins the derby:
and use it as you have it but keep in mind to store the timer ID in an array and when a player leaves derby to destroy the timer.
pawn Код:
SetTimer("DerbySys",1000,1);
pawn Код:
forward DerbySys();
public DerbySys()
{
for (new playerid; playerid != MAX_PLAYERS; ++playerid)
{
if (!IsPlayerConnected(playerid) || !IsPlayerInRangeOfPoint(playerid, 500, -1364,1004.5,1220)) continue;
if (!IsPlayerInAnyVehicle(playerid))
{
GetDerbyCar(playerid);
continue;
}
if (IsPlayerInVehicle(playerid,RandDerbyCar[playerid]))
{
new Float:Vhealth;
GetVehicleHealth(RandDerbyCar[playerid],Vhealth);
if (Vhealth <= 250)
{
DestroyVehicle(RandDerbyCar[playerid]);
SendClientMessage(playerid,0xFFFFFFFF,"Vehicle was destroyed. New vehicle created.");
}
}
}
}
pawn Код:
SetTimerEx("DerbySys", 1000, true, "i", playerid);