Car engine help
#9

you'd need to set a new global variable such as
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;
            }
        }
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
Reply


Messages In This Thread
Car engine help - by Wesley221 - 17.05.2011, 15:56
Re: Car engine help - by cessil - 17.05.2011, 15:58
Re: Car engine help - by Wesley221 - 17.05.2011, 16:34
Re: Car engine help - by Swiftz - 17.05.2011, 16:41
Re: Car engine help - by cessil - 17.05.2011, 16:58
Re: Car engine help - by Wesley221 - 17.05.2011, 17:03
Re: Car engine help - by Swiftz - 17.05.2011, 17:11
Re: Car engine help - by Wesley221 - 17.05.2011, 17:18
Re: Car engine help - by cessil - 18.05.2011, 01:04
Re: Car engine help - by Wesley221 - 18.05.2011, 06:31

Forum Jump:


Users browsing this thread: 3 Guest(s)