Vehicle Autofix
#4

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 stoped");
    }
    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
Vehicle Autofix - by stieben - 30.10.2008, 16:26
Re: Vehicle Autofix - by Nero_3D - 30.10.2008, 16:28
Re: Vehicle Autofix - by stieben - 30.10.2008, 16:28
Re: Vehicle Autofix - by Nero_3D - 30.10.2008, 16:50
Re: Vehicle Autofix - by kaisersouse - 30.10.2008, 17:04
Re: Vehicle Autofix - by stieben - 30.10.2008, 17:48
Re: Vehicle Autofix - by XtremeTeam - 04.05.2009, 14:57
Re: Vehicle Autofix - by Bearfist - 04.05.2009, 15:05
Re: Vehicle Autofix - by CristianTdj - 07.01.2010, 07:38
Re: Vehicle Autofix - by Calon - 07.01.2010, 09:59

Forum Jump:


Users browsing this thread: 1 Guest(s)