SA-MP Forums Archive
I don't find a autofix for vehicles - 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: I don't find a autofix for vehicles (/showthread.php?tid=381196)



I don't find a autofix for vehicles - JEkvall95 - 28.09.2012

Where can I find a autofix for vehicles?

you should be avaiable to type /auftofix or af to enable the command

I'll put it in the gamemode file

a CMD command


Re: I don't find a autofix for vehicles - zDevon - 28.09.2012

Post here if you're looking for someone to make something for you.


Re: I don't find a autofix for vehicles - Xtreme Brotherz - 28.09.2012

REMOVED!!


Re: I don't find a autofix for vehicles - zDevon - 28.09.2012

Quote:
Originally Posted by Xtreme Brotherz
Посмотреть сообщение
Here you go!!
Made by me now(take credits if u want :P);

pawn Код:
new autofix[MAX_PLAYERS];
new autofixtimer;

public OnPlayerConnect(playerid)
{
autofix[playerid]=0;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/autofix", cmdtext, true, 10) == 0)
    {
        if(autofix[playerid]==1);
                autofixtimer = SetTimer("vehfix", 1000, true);
                else
                KillTimer(autofixtimer);

        return 1;
    }
    return 0;
}

public vehfix(playerid)
{
 RepairVehicle(GetPlayerVehicleID(playerid));
return 1;
}
+rep me if tht helped!!
Quote:
Originally Posted by Scrpting Help Rules
8. Do not post untested code.
That won't even compile.


Re: I don't find a autofix for vehicles - JEkvall95 - 28.09.2012

doesn't work at all


Re: I don't find a autofix for vehicles - JEkvall95 - 28.09.2012

I have a /fix command which works

if it only would be possible to make an almos same but auto

pawn Код:
CMD:fix(playerid, params[])
{
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "SpyBot: You are not in a vehicle!");
    RepairVehicle(GetPlayerVehicleID(playerid));
    SendClientMessage(playerid, 0xFFFFFFFF, "SpyBot: Your vehicle has been successfully repaired!");
    return 1;
}



Re: I don't find a autofix for vehicles - Xtreme Brotherz - 28.09.2012

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);
    }
}



Re: I don't find a autofix for vehicles - stabker - 28.09.2012

pawn Код:
CMD:autofix(playerid)
{
    if(GetPVarInt(playerid,"Autofix"))
    {
        DeletePVar(playerid,"Autofix");
        SendClientMessage(playerid,-1,"Autofix disabled!");
    }
    else
    {
        SetPVarInt(playerid,"Autofix",true);
        SendClientMessage(playerid,-1,"Autofix enabled!");
    }
    return 1;
}
Into OnVehicleDamageStatusUpdate:

pawn Код:
if(GetVehicleHealth(vehicleid) < 1000) if(GetPVarInt(playerid,"Autofix")) RepairVehicle(vehicleid);



Re: I don't find a autofix for vehicles - Beljulji - 29.09.2012

Next time use Search! https://sampforum.blast.hk/showthread.php?tid=122060


Re: I don't find a autofix for vehicles - OnlyOne - 29.09.2012

Lol, alot of un required stuff. all you need do is that.

pawn Код:
new fixtimer[MAX_PLAYERS],bool:actived[MAX_PLAYERS];
CMD:autofix(playerid)
{
    if(actived[playerid]) return SendClientMessage(playerid,-1,"disabled"),KillTimer(fixtimer[playerid]),actived[playerid] = false;
    fixtimer[playerid] = SetTimerEx("fixt",1000,true,"i",playerid);
    actived[playerid] = true;
    SendClientMessage(playerid,-1,"actived")
    return 1;
}
forward fixt(playerid);
public fixt(playerid)
{
    if(!IsPlayerInAnyVehicle(playerid)) return 0;
    RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}