I don't find a autofix for vehicles
#7

TESTED AND WORKING

Way 1:
pawn Код:
//OnGameModeInit
SetTimer("Timer", 1000, true);
pawn Код:
new bool:AutoFix[MAX_PLAYERS];
pawn Код:
if(!strcmp("/afix", cmdtext, true))
{
    if(AutoFix[playerid])
    {
        AutoFix[playerid] = false;
        return SendClientMessage(playerid, COLOR, "Autofix stopped");
    }
    else
    {
        if(!IsPlayerInAnyVehicle(i)) return SendClientMessage(playerid, COLOR, "You need to be in a vehicle to start autofix");
        AutoFix[playerid] = true;
        return SendClientMessage(playerid, COLOR, "Autofix started");
    }
    return 1;
}
pawn Код:
forward Timer();
public Timer()
{
    new Float:health, var1;
    for(new i = 0, m = GetMaxPlayers(); i < m; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(AutoFix[i] && IsPlayerInAnyVehicle(i))
        {
            var1 = GetPlayerVehicleID(i);
            GetVehicleHealth(var1 , health);
            if(health < 500) SetVehicleHealth(var1, 1000.0);
        }
    }
}
Way 2:
pawn Код:
new AutoFixTimer[MAX_PLAYERS];
pawn Код:
if(!strcmp("/afix", cmdtext, true))
{
    if(AutoFixTimer[playerid])
    {
        KillTimer(AutoFixTimer[playerid]);
        AutoFixTimer[playerid] = false;
        return SendClientMessage(playerid, COLOR, "Autofix stoped");
    }
    else
    {
        if(!IsPlayerInAnyVehicle(i)) return SendClientMessage(playerid, COLOR, "You need to be in a vehicle to start autofix");
        AutoFixTimer[playerid] = SetTimerEx("AutoFix", 1000, true, "i", playerid);
        return SendClientMessage(playerid, COLOR, "Autofix started");
    }
    return 1;
}
pawn Код:
forward AutoFix(playerid);
public AutoFix(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vid = GetPlayerVehicleID(playerid), Float:health;
        GetVehicleHealth(vid , health);
        if(health < 500) SetVehicleHealth(vid , 1000.0);
    }
}
Reply


Messages In This Thread
I don't find a autofix for vehicles - by JEkvall95 - 28.09.2012, 17:43
Re: I don't find a autofix for vehicles - by zDevon - 28.09.2012, 17:47
Re: I don't find a autofix for vehicles - by Xtreme Brotherz - 28.09.2012, 18:44
Re: I don't find a autofix for vehicles - by zDevon - 28.09.2012, 18:47
Re: I don't find a autofix for vehicles - by JEkvall95 - 28.09.2012, 18:55
Re: I don't find a autofix for vehicles - by JEkvall95 - 28.09.2012, 19:04
Re: I don't find a autofix for vehicles - by Xtreme Brotherz - 28.09.2012, 19:07
Re: I don't find a autofix for vehicles - by stabker - 28.09.2012, 22:27
Re: I don't find a autofix for vehicles - by Beljulji - 29.09.2012, 02:31
Re: I don't find a autofix for vehicles - by OnlyOne - 29.09.2012, 02:59

Forum Jump:


Users browsing this thread: 2 Guest(s)