SA-MP Forums Archive
as start the car? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: as start the car? (/showthread.php?tid=567334)



as start the car? - StarPeens - 13.03.2015

shut down:
pawn Код:
for(new i=0;i<MAX_PLAYERS;i++) {
        if (isrefuelling[i]) continue;
        new vid = GetPlayerVehicleID(i);
        if (GetPlayerVehicleSeat(i) == 0) {
            fuel[vid] = fuel[vid] -1;
            if (fuel[vid]<1)
            {
                fuel[vid] = 0;
                SetVehicleParamsEx(vid,0,0,0,0,1,1,0); //change this to watever you like
                GameTextForPlayer(i,"~b~Fuel~y~ Ende~p~d",5000,4); //show text
            }
        }
        new string[125];format(string,sizeof string,"Fuel: ~r~%i~g~",fuel[vid]);
        TextDrawSetString(td_fuel[i],string);

    }
and start the car?? +rep


Re: as start the car? - CalvinC - 13.03.2015

Use SetVehicleParamsEx to toggle engine, lights and stuff.
https://sampwiki.blast.hk/wiki/SetVehicleParamsEx


Re: as start the car? - Gammix - 13.03.2015

Look at your code, very poorly established.

Why isn't there any id's connection check. It will probabily slow down the speed.
pawn Код:
for(new i; i < MAX_PLAYERS; i++)
{
       if(IsPlayerConnected(i))
       {
       }
}
Just a tip, you can do
pawn Код:
fuel[vid] -= 1;
to reduce the value by any amount.

After the fuel limit is smaller than 1 (< 1), why havent you set isrefuelling[i] to false? This can cause problem.
pawn Код:
isrefuelling[i] = false;
Just use this to stop the engine when the vehicle start refueling.
pawn Код:
SetVehicleParamsEx(vid, 0, 0, 0, 0, 0, 0, 0);
Refer to the link provided by CalvinC.

The string size, I think 18 is enough.
pawn Код:
new string[18];
For future, use foreach for making loops life easy. And please use PlayerTextDraws for these kind of purposes.