[Help] Vehicle Autofix/repair in ZCMD?
#1

Has anyone know Vehicle Autofix/repair in ZCMD?

I got the non autofix/repair and flip code here..
pawn Код:
CMD:fix(playerid, params[])
{
    if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_RED,"[Error]: You didn't spawn yet!");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED,"[Error]: You are not in a vehicle!");
    if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, COLOR_RED,"[Error]: You are not in the driver seat!");
    RepairVehicle(GetPlayerVehicleID(playerid));
    SendClientMessage(playerid, COLOR_GREEN, "[Fix/Repair]: Your vehicle has been sucessfully repaired!");
    return 1;
}

CMD:repair(playerid, params[]) return cmd_fix(playerid, params);

CMD:flip(playerid, params[])
{
  if(IsPlayerInAnyVehicle(playerid))
    {
    new currentveh;
    new Float:angle;
    currentveh = GetPlayerVehicleID(playerid);
    GetVehicleZAngle(currentveh, angle);
    SetVehicleZAngle(currentveh, angle);
    SendClientMessage(playerid, COLOR_GREEN, "[Flip]: Your vehicle has been sucessfully flipped!");
    return 1;
    }
        else
    {
    if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_RED,"[Error]: You didn't spawn yet!");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED,"[Error]: You are not in a vehicle!");
    if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, COLOR_RED,"[Error]: You are not in the driver seat!");
    return 1;
    }
}
I don't know how to make the autofix/repair script in ZCMD.
Reply
#2

What do you mean? Autofix as in, you type a command, and from then it fixes your car every time it drops below 999?
Reply
#3

when the vehicle is burning, it will be fixed.. like that.

and it can be turned on/off by "/autofix" zcmd
Reply
#4

Give me a few seconds, ill make one up for you, test it too, if someone already has one, feel free to help.
Reply
#5

pawn Код:
COMMAND:autofix(playerid,params[])
{
    new Float:h;
    new vehicleid = GetPlayerVehicleID(playerid);
    SetTimerEx("autofix",10000,false,"i",playerid);
    GetVehicleHealth(vehicleid,h);
    if(h < 300)
    {
         SetVehicleHealth(vehicleid, 305);
    }
    return 1;
}
forward autofix(playerid);
public autofix(playerid)
{
    RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}
Tested it now, it works if your vehicle health is below 300 when you enter /fix. it'll set it to 305. Only i'm not too sure what health it blows up at so you may have to edit it to what you like hope it helped.
Reply
#6

thanks!
Reply
#7

put this

pawn Код:
new AutoFix[MAX_PLAYERS];
pawn Код:
public OnPlayerConnect(playerid)
{
 AutoFix[playerid] = 0
 return 1;
}
pawn Код:
COMMAND:autofix(playerid,params[])
{
 AutoFix[playerid] = 1
 SendClientMessage(playerid,-1,"You Just Turned On AutoFix");
 return 1;
}

pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
 if(AutoFix[playerid] == 1)
  {
    new panels, doors, lights, tires;
    GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
    tires = encode_tires(0, 0, 0, 0); // fix all tires
    panels = encode_panels(0, 0, 0, 0, 0, 0, 0); // fix all panels //fell off - (3, 3, 3, 3, 3, 3, 3)
    doors = encode_doors(0, 0, 0, 0, 0, 0); // fix all doors //fell off - (4, 4, 4, 4, 0, 0)
    lights = encode_lights(0, 0, 0, 0); // fix all lights
    RepairVehicle(vehicleid);
    }
 return 1;
}
sorry if its not working
Reply
#8

2nd Thanks! [Guest123]

EDIT: Got an error then i fixed some line by adding ; at the end of line

EDIT2: Oh no.. got these error

(16830) : error 017: undefined symbol "encode_tires"
(16831) : error 017: undefined symbol "encode_panels"
(16832) : error 017: undefined symbol "encode_doors"
(16833) : error 017: undefined symbol "encode_lights"

I think you forgot to define them..

EDIT3: FIXED! I added these on last and it work.
pawn Код:
encode_tires(tire1, tire2, tire3, tire4) return tire1 | (tire2 << 1) | (tire3 << 2) | (tire4 << 3);
encode_panels(flp, frp, rlp, rrp, windshield, front_bumper, rear_bumper)
{
    return flp | (frp << 4) | (rlp << 8) | (rrp << 12) | (windshield << 16) | (front_bumper << 20) | (rear_bumper << 24);
}
encode_doors(bonnet, boot, driver_door, passenger_door, behind_driver_door, behind_passenger_door)
{
    #pragma unused behind_driver_door
    #pragma unused behind_passenger_door
    return bonnet | (boot << 8) | (driver_door << 16) | (passenger_door << 24);
}
encode_lights(light1, light2, light3, light4)
{
    return light1 | (light2 << 1) | (light3 << 2) | (light4 << 3);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)