SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/08/2013, 11:24 AM   #1
UnlimitedFreeroam
Big Clucker
 
Join Date: Jul 2012
Posts: 77
Reputation: 2
Default Problem with automatic repair

Hello everyone,

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

pawn Code:
forward AutoRepair();
pawn Code:
SetTimer("AutoRepair",500,1);
pawn Code:
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);
  }
}
}
UnlimitedFreeroam is offline   Reply With Quote
Old 12/08/2013, 11:37 AM   #2
JeaSon
Gangsta
 
JeaSon's Avatar
 
Join Date: Aug 2013
Location: Future
Posts: 558
Reputation: 79
Default Re: Problem with automatic repair

use this under onplayerconnect
pawn Code:
SetTimerEx("Autorepair",500,true,"d",playerid);

pawn Code:
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
__________________
Again back
JeaSon is offline   Reply With Quote
Old 12/08/2013, 11:42 AM   #3
-Prodigy-
Huge Clucker
 
Join Date: Dec 2010
Posts: 398
Reputation: 45
Default Re: Problem with automatic repair

Why not use something like this:
pawn Code:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    SetVehicleHealth(vehicleid, 1000.0);
    return 1;
}
No need for timers.
-Prodigy- is offline   Reply With Quote
Old 12/08/2013, 12:28 PM   #4
UnlimitedFreeroam
Big Clucker
 
Join Date: Jul 2012
Posts: 77
Reputation: 2
Default Re: Problem with automatic repair

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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Auto Car Repair [Full Repair] Vikshay Filterscripts 1 12/07/2013 10:11 PM
Repair Command Problem Private200 Scripting Help 9 21/01/2013 01:50 AM
Repair pickup problem joska Scripting Help 7 01/01/2013 12:23 PM
Problem with auto repair ! Unirom Shaw Scripting Help 3 24/12/2012 01:57 PM
[FilterScript] [FS] Automatic Vehicle Repair Brian_G Filterscripts 15 23/06/2010 04:13 PM


All times are GMT. The time now is 06:19 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.