Problem with automatic repair
#1

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)