[HELP!!] Auto car fixing / Nitrous with hotkey
#2

Next time try searching harder, it will save you time. Below code is made by ♣ ⓐⓢⓢ it will set your vehicle health to 1000 if it falls below 300.

Auto repair
Quote:
Originally Posted by ♣ ⓐⓢⓢ
Quote:
Originally Posted by Weirdosport
(plus you can make sure the player is the driver rather than the passenger)
OnPlayerEnterVehicle dedects in which seats the player enters...

@topic
first of all, use [pawn][/pawn] tags

pawn Код:
new AutoRepairTimer[MAX_PLAYERS] = {-1, ...};
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
        switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
        {
            case 425, 447, 476, 520: {} //do nothing
            default:
            {
                if(AutoRepairTimer[playerid] != -1) KillTimer(AutoRepairTimer[playerid]);
                AutoRepairTimer[playerid] = SetTimerEx("AutoRepair", 1000, true, "d", playerid);
            }
        }
}
pawn Код:
forward AutoRepair(playerid);
public AutoRepair(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new
            Float:health;
            vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleHealth(vehicleid, health);
        if(health <= 300.0)
        {
            SetVehicleHealth(vehicleid, 1000.0);
            GameTextForPlayer(playerid, "~g~Car Auto-Repaired!", 5000, 5);
            PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
        }
    }
    else    KillTimer(AutoRepairTimer[playerid]), //kills the timer if the exist the vehicle or disconnects!
        AutoRepairTimer[playerid] = -1;
}
That code is better because the timer isnt the whole time active like in your code
Below is the HOTKEY button for nitrous by Daren_Jacobson. I think this one is when you press the CTRL button. Might not be safe and might cause crashes.

Quote:
Originally Posted by Daren_Jacobson
/NoS - Gives You Unlimited Nitro + a CTRL Key To Stop It !
pawn Код:
OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if ((newkeys & KEY_SUBMISSION) == (KEY_SUBMISSION) && (IsPlayerInAnyVehicle(playerid)))//not sure if that is how you do it
{
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
return 1;
}
return 0;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)