How would I go about making a toggle for unlimited car health - 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: How would I go about making a toggle for unlimited car health (
/showthread.php?tid=462737)
How would I go about making a toggle for unlimited car health -
ExtendedCarbon - 08.09.2013
I want to make a command that can toggle your cars invincibility. So when doing /cargod it will make your car have unlimited health. And when typed again, /cargod it will disable it.
I've no idea how to do it.
Re: How would I go about making a toggle for unlimited car health -
dusk - 08.09.2013
pawn Код:
new bool:CarGodMode[MAX_PLAYERS];
CMD:cargod(playerid)
{
if(CarGodMode[playerid]) CarGodMode[playerid] = false;
else CarGodMode[playerid] = true;
return 1;
}
public OnPlayerUpdate(playerid)
{
if(CarGodMode[playerid])
{
if(IsPlayerInAnyVehicle(playerid))
{
RepairVehicle(GetPlayerVehicleID(playerid));
}
}
return 1;
}
*Note: "OnPlayerUpdate" is called many times in a second....
Re: How would I go about making a toggle for unlimited car health -
Konstantinos - 08.09.2013
pawn Код:
#define FILTERSCRIPT
#include < a_samp >
#include < zcmd >
#undef MAX_PLAYERS
#define MAX_PLAYERS (50) // CHANGE TO THE MAX PLAYERS YOU WANT!
new
bool: Toggle_Cargod[ MAX_PLAYERS ]
;
public OnPlayerConnect( playerid )
{
Toggle_Cargod[ playerid ] = false;
return 1;
}
public OnPlayerUpdate( playerid )
{
if( Toggle_Cargod[ playerid ] && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
{
SetVehicleHealth( GetPlayerVehicleID( playerid ), 95000 );
RepairVehicle( GetPlayerVehicleID( playerid ) );
}
return 1;
}
CMD:cargod( playerid, params[ ] )
{
if( !Toggle_Cargod[ playerid ] )
{
Toggle_Cargod[ playerid ] = true;
SendClientMessage( playerid, -1, "Cargod is now on!" );
}
else
{
Toggle_Cargod[ playerid ] = false;
SendClientMessage( playerid, -1, "Cargod is now off!" );
}
return 1;
}
Re: How would I go about making a toggle for unlimited car health -
Jstylezzz - 08.09.2013
It would be something like this:
pawn Код:
new cargodenabled[MAX_PLAYERS];
new cgodtimer[MAX_PLAYERS];
CMD:cargod(playerid,params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
if(cargodenabled[playerid] == 0)
{
SendClientMessage(playerid,-1,"Cargod is enabled");
cgodtimer[playerid] = SetTimerEx("CarGod",10000,1,"i",playerid);
SetVehicleHealth(vehicleid,9999);
return 1;
}
else
{
SendClientMessage(playerid,-1,"Cargod is disabled");
KillTimer(cgodtimer[playerid]);
SetVehicleHealth(vehicleid,1000);
}
return 1;
}
forward CarGod(playerid);
public CarGod(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
SetVehicleHealth(vehicleid,9999);
}
Or check the answers above, they weren't there when I wrote my reply ;P
Re: How would I go about making a toggle for unlimited car health -
Weponz - 08.09.2013
SetVehicleHealth?