Easiest way to implement car godmode and unlimmited nitro?
#1

My gamemode is pretty okay right now, only thing missing is godmode and unlimited nitro.
GM I'm using is based on grandlarcency gm.

What's the best way to add unlimited nitro and car godmode?
(car never takes damage, is automatically equipped with nitro, and nitro auto refills with a button like ctrl)

I have almost no experience scripting, but I would like these features.

Help would be greatly appreciated.

Thank you!
Reply
#2

You can simply set the vehicle health to a value higher than 1000 (https://sampwiki.blast.hk/wiki/SetVehicleHealth) to make it practically invincible. Make sure to reset it from time to time, to make sure it doesn't explode whenever the vehicle has received enough damage.

You can add nitro to a vehicle using https://sampwiki.blast.hk/wiki/AddVehicleComponent.

The components you want to add are as follows:

1008 nto_b_l Nitro 5 times
Most cars, Most planes and Most Helicopters

1009 nto_b_s Nitro 2 times
Most cars, Most planes and Most Helicopters

1010 nto_b_tw Nitro 10 times
Most cars, Most planes and Most Helicopters
Reply
#3

Add a variable to your vehicles info enum. ( If you got one )

pawn Код:
enum vInfo
{
        // ....
        vGodMode,

        // ...
}
new VehicleInfo[MAX_VEHICLES][vInfo];
You need to reset godmode variable. Under the function you load vehicles:

pawn Код:
VehicleInfo[vehicleid][vGodmode] = 0;
If you don't load vehicles after player login but you load all of them at Gamemode Init then do this:

pawn Код:
for(new i = 0; i<MAX_VEHICLES; i++)
{
      VehicleInfo[i][vGodMode] = 0;
}
Command to activate godmode, I guess you use ZCMD, if you don't then use it.
pawn Код:
CMD:vgod(playerid)
{
     if(!IsPlayerInAnyVehicle(playerid) return SendClientMessage(playerid, ANY_COLOR, "You aren't driving a vehicle");
     if(GetPlayerVehicleSeat != 0) return SendClientMessage(playerid, ANY_COLOR, "You aren't the driver");
     new vehicleid = GetPlayerVehicleID(playerid);
     VehicleInfo[vehicleid][vGodmode] = 1;
     SetVehicleHealth(vehicleid, 100000);
     RepairVehicle(vehicleid);
     SendClientMessage(playerid, ANY_COLOR, "You have toggled god mode on your vehicle");
     return 1;
}
Under OnVehicleDamageStatusUpdate:

pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
       if(VehicleInfo[vehicleid][vGodmode] == 1)
       {
               SetVehicleHealth(vehicleid, 100000);    
               RepairVehicle(vehicleid);                    
        }
        return 1;
}



The vehicle won't get repaired when a player shoots your vehicle. You need a global timer to reset vehicles health
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)