SA-MP Forums Archive
Vehicle Stall - 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: Vehicle Stall (/showthread.php?tid=558054)



Vehicle Stall - BornHuman - 16.01.2015

SO. I'M PRETTY MAD AT MYSELF RIGHT NOW.

I've scripted something that's SO easy, a toddler could do it.

pawn Код:
if(IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
                new carid = GetPlayerVehicleID(i), string[128];
                new VehHealth;
               
                if(VehHealth <= 251.0)
                {
                    SetVehicleHealth(carid, 350.0);
                    format(string, sizeof(string), "** The vehicle engine stalls (( %s )).", GetName(i));
                    NearByMessage(i, SCRIPTPURPLE, string);
                    new engine,lights,alarm,doors,bonnet,boot,objective;
                    GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                    SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                }
            }
This is supposed to STALL the vehicle, after it reaches under 251.0 health, and set it to 350.0

HOWEVER
Whenever you get into a vehicle, it automatically sets it to 350.0 but it shouldn't.
It should only do that if the health gets lower or equal to 251.0. However when it gets in it automatically sets it to 350.0?

< = less than right?

Anyway, help.

+REP


Re: Vehicle Stall - Abagail - 16.01.2015

No <= less than, or equal to. And because you dont use GetVehicleHealth or ANYTHING to change the health variable, it will never surpass 0. Therefore: you have scripted it to ALWAYS stall the engine. A simple fix would be to add GetVehicleHealth(carid, vHealth) before checking the health amount.


Re: Vehicle Stall - BornHuman - 16.01.2015

Quote:
Originally Posted by Abagail
Посмотреть сообщение
No <= less than, or equal to. And because you dont use GetVehicleHealth or ANYTHING to change the health variable, it will never surpass 0. Therefore: you have scripted it to ALWAYS stall the engine. A simple fix would be to add GetVehicleHealth(carid, vHealth) before checking the health amount.
ok evan
SO WAT SHOULD I USE?


Re: Vehicle Stall - Abagail - 16.01.2015

This should work properly.

pawn Код:
if(IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
                new carid = GetPlayerVehicleID(i), string[128];
                new VehHealth;
                GetVehicleHealth(carid, VehHealth);                

                if(VehHealth <= 251.0)
                {
                    SetVehicleHealth(carid, 350.0);
                    format(string, sizeof(string), "** The vehicle engine stalls (( %s )).", GetName(i));
                    NearByMessage(i, SCRIPTPURPLE, string);
                    new engine,lights,alarm,doors,bonnet,boot,objective;
                    GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                    SetVehicleParamsEx(carid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                }
            }



Re: Vehicle Stall - Threshold - 16.01.2015

pawn Код:
new Float:VehHealth;



Re: Vehicle Stall - Abagail - 16.01.2015

Quote:
Originally Posted by Threshold
Посмотреть сообщение
pawn Код:
new Float:VehHealth;
I didn't notice that it wasn't declared as a float: but meh another easy to fix mistake. Anyways, along with this, it should start working as you want it to, @BornHuman. Good luck!