How would I go about making a toggle for unlimited car health
#1

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.
Reply
#2

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....
Reply
#3

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;
}
Reply
#4

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
Reply
#5

SetVehicleHealth?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)