Logging current vehicle health? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Logging current vehicle health? (
/showthread.php?tid=222229)
Logging current vehicle health? -
Face9000 - 06.02.2011
It's possible to set a timer of 10 seconds and log every change of the vehicle health?
Ex: Current vehiclehp of PLAYERNAME: 1000
After 10 seconds:
Current vehiclehp of PLAYERNAME: 990
Re: Logging current vehicle health? -
JaTochNietDan - 07.02.2011
Yes of course it's possible, using the functions
SetTimer and
GetVehicleHealth. Is that all you needed to know? I mean you did only ask if it's possible
Re: Logging current vehicle health? -
_Tommy - 07.02.2011
Quote:
Originally Posted by JaTochNietDan
Yes of course it's possible, using the functions SetTimer and GetVehicleHealth. Is that all you needed to know? I mean you did only ask if it's possible
|
As
JaTochNietDan has already said, all you have to do is to use the functions mantioned above.
Here is a simple code whitch prints the curren't vehicle's health (Sorry if you do not use the Zcmd include, I just think its the best way to preform commands):
pawn Код:
command(timeron, playerid, params[])
{
#pragma unused params
SetTimerEx("GetVehicleHealth1",10000,false,"i",playerid); // The timer will be called each 10000/1000 (10) seconds
return 1;
}
forward GetVehicleHealth1(playerid);
public GetVehicleHealth1(playerid)
{
new
Float:health,
veh,
string[128];
veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, health);
format(string, sizeof(string), "Your current vehicle's health (Vehicle ID: %d): %f", veh, health);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}
Ofcourse you will have to kill the timer as soona as the player leaves the vehicle.
Feel free to ask any other questions.
Re: Logging current vehicle health? -
Face9000 - 07.02.2011
K,thanks,got it.