SA-MP Forums Archive
Problem with automatic 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: Problem with automatic repair (/showthread.php?tid=457623)



Problem with automatic repair - UnlimitedFreeroam - 12.08.2013

Hello everyone,

I'm having an issue, I've made a automatic repair timer + code, but In-game it's not working.

pawn Код:
forward AutoRepair();
pawn Код:
SetTimer("AutoRepair",500,1);
pawn Код:
public AutoRepair(){
for(new i=0; i<GetMaxPlayers(); i++)
{
  if(IsPlayerConnected(i)) if(IsPlayerInAnyVehicle(i)){
    new Float:fVehicleHealth;
    GetVehicleHealth(GetPlayerVehicleID(i),fVehicleHealth);
    if(fVehicleHealth < 900) SetVehicleHealth(GetPlayerVehicleID(i),1000.0);
  }
}
}



Re: Problem with automatic repair - JeaSon - 12.08.2013

use this under onplayerconnect
pawn Код:
SetTimerEx("Autorepair",500,true,"d",playerid);
pawn Код:
forward Autorepair(playerid);
public Autorepair(playerid)
{
  if(IsPlayerInAnyVehicle(playerid))
  {
   new Float:health,vehicleid;
   vehicleid = GetPlayerVehicleID(playerid);
   GetVehicleHealth(vehicleid,health);
   if(health <250)
   {
   SetVehicleHealth(vehicleid,1000);
   }
  }
 }
try it


Re: Problem with automatic repair - -Prodigy- - 12.08.2013

Why not use something like this:
pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    SetVehicleHealth(vehicleid, 1000.0);
    return 1;
}
No need for timers.


Re: Problem with automatic repair - UnlimitedFreeroam - 12.08.2013

Doesn't work, vehicle won't be destroyed now but the car won't heal in his view or so.