I don't find a autofix for vehicles
#1

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

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

REMOVED!!
Reply
#4

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

doesn't work at all
Reply
#6

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

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);
Reply
#9

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)