PDA

View Full Version : Easiest way to implement car godmode and unlimmited nitro?


Piooo
09/11/2017, 11:03 AM
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!

Sithis
09/11/2017, 12:24 PM
You can simply set the vehicle health to a value higher than 1000 (http://wiki.sa-mp.com/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 http://wiki.sa-mp.com/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

Lucases
09/11/2017, 12:59 PM
Add a variable to your vehicles info enum. ( If you got one )


enum vInfo
{
// ....
vGodMode,

// ...
}
new VehicleInfo[MAX_VEHICLES][vInfo];


You need to reset godmode variable. Under the function you load vehicles:


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:


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.

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:


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