18.05.2011, 01:04
you'd need to set a new global variable such as
that's just a rough example, don't copy/paste it.
and with loops this is what happens
for(new i; i < MAX_PLAYERS; i++)
new i;
creates a new variable called 'i', this variable is 0 by default,
i < MAX_PLAYERS;
while i is less than MAX_PLAYERS do what ever you want in the brackets
i++
and then after you've done stuff in the brackets increase i by 1.
so this creates a loop from 0 - MAX_PLAYERS which is all the playerids on the server
pawn Код:
new isTotalled[MAX_PLAYERS];
pawn Код:
OnVehicleDamageStatusUpdate(vehicleid,playerid)
{
new Float:VehHealth;
new PlayerVehicle;
GetVehicleHealth(vehicleid, VehHealth);
if(VehHealth < 350 && isTotalled[playerid] == 0)
{
SetVehicleParamsEx(PlayerVehicle, false, true, true, true, false, false, false);
TogglePlayerControllable(i,0);
SendClientMessage(playerid, orange, "Your engine died. Please call a repairsman to repair it");
SetVehicleHealth(vehicleid, 349);
isTotalled[playerid] = 1;
return 1;
} else if(VehHealth > 998) {
SetVehicleParamsEx(vehicleid, true, false, false, false, false, false, false);
TogglePlayerControllable(playerid, 1);
SendClientMessage(playerid, orange, "Your engine have been fixed.");
SendClientMessage(playerid, orange, "You gave the repairsman 500$.");
return 1;
}
}
and with loops this is what happens
for(new i; i < MAX_PLAYERS; i++)
new i;
creates a new variable called 'i', this variable is 0 by default,
i < MAX_PLAYERS;
while i is less than MAX_PLAYERS do what ever you want in the brackets
i++
and then after you've done stuff in the brackets increase i by 1.
so this creates a loop from 0 - MAX_PLAYERS which is all the playerids on the server