SA-MP Forums Archive
Auto Vehicle Repair - 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: Auto Vehicle Repair (/showthread.php?tid=352824)



Auto Vehicle Repair - kbalor - 21.06.2012

I know many server has this script. and i want to know how to make this.

Auto repair vehicle when damage.

No need typing /repair


Re: Auto Vehicle Repair - Zerberus - 21.06.2012

Just make a timer, that calls every second and set the VehicleHealth of every car on the server to 1000.


Re: Auto Vehicle Repair - [MM]RoXoR[FS] - 21.06.2012

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetTimerEx("VRepair",500,true,"i",playerid);
    return 1;
}

forward VRepair(playerid);
public VRepair(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
        RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}



Re: Auto Vehicle Repair - Skaizo - 21.06.2012

i think it is
pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    RepairVehicle(vehicleid);
    return 1;
}



Re: Auto Vehicle Repair - [MM]RoXoR[FS] - 21.06.2012

Quote:
Originally Posted by Skaizo
Посмотреть сообщение
i think it is
pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    RepairVehicle(vehicleid);
    return 1;
}
Wiki says
Note: This does not include vehicle health changes


Re: Auto Vehicle Repair - kbalor - 21.06.2012

Quote:
Originally Posted by [MM]RoXoR[FS]
Посмотреть сообщение
pawn Код:
public OnPlayerSpawn(playerid)
{
    SetTimerEx("VRepair",500,true,"i",playerid);
    return 1;
}

forward VRepair(playerid);
public VRepair(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
        RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}
how about OnplayerExitVehicle? do i need to kill the timer?? thanks to your reply.


Re: Auto Vehicle Repair - Zerberus - 21.06.2012

Quote:
Originally Posted by [MM]RoXoR[FS]
Посмотреть сообщение
Wiki says
Note: This does not include vehicle health changes
Yes, it does only work, when vehicle elements are damaged ( oors, tires, panels, or lights)


Re: Auto Vehicle Repair - kbalor - 21.06.2012

HEHE! i found the solution and more updated.

Quote:

public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
#pragma unused playerid

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
SetVehicleHealth(vehicleid,1000.0);
UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
return 1;
}

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 << | (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 << | (driver_door << 16) | (passenger_door << 24);
}
encode_lights(light1, light2, light3, light4)
{
return light1 | (light2 << 1) | (light3 << 2) | (light4 << 3);
}
// end of it!

Thanks guys!


Re: Auto Vehicle Repair - [MM]RoXoR[FS] - 21.06.2012

Quote:
Originally Posted by kbalor
Посмотреть сообщение
how about OnplayerExitVehicle? do i need to kill the timer?? thanks to your reply.
Only on player death