Difference between oldand new carhealth -
Remi-X - 18.06.2009
Hi, i wanted to know the following, is it possible to check the difference between the old carhealth, and the new carhealt, like when you crash? Can someone explain that to me?
Re: Difference between oldand new carhealth -
mamorunl - 18.06.2009
Yes it is possible, run a timer which checks the new health and the old health. It has been made before, but you have to search for that one : >
Anyways, that is the basics
Re: Difference between oldand new carhealth -
Remi-X - 18.06.2009
I can't find anything, on this forum and on ******...
Re: Difference between oldand new carhealth -
mamorunl - 18.06.2009
http://forum.sa-mp.com/index.php?topic=61190.0
This is the basic idea, you just need to edit the timer a little to your needs
Re: Difference between oldand new carhealth -
Remi-X - 18.06.2009
That isn't what i mean. Even not a bit like that.
I want, if my carhealth is now exactly 1000.0, and after a crash it is 700.0, i will save those numbers in a oldcarhealth and newcarhealth. Than i can check the difference, oldcarhealth-newcarhealth = 300.0.
And, i think that isn't a scripting basic, i know the basics.
Re: Difference between oldand new carhealth -
mamorunl - 18.06.2009
I didn't mean 'basics' like scripting basics.. I meant for your timer
pawn Код:
forward CarHealthTimer();
public CarHealthTimer()
{
for (new i=0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
new Float:current[MAX_PLAYERS];
GetVehicleHealth(GetPlayerVehicleID(i),current[i]);
if(current[i] < oldhealth[i]) { // action
}
// then you overwrite your old health..
oldhealth[i] = current[i];
}
}
}
Like that..
Re: Difference between oldand new carhealth -
Remi-X - 19.06.2009
And where do i define the oldhealth? :P
Re: Difference between oldand new carhealth -
Abernethy - 19.06.2009
Quote:
Originally Posted by Remi-X
And where do i define the oldhealth? :P
|
Woah, somebody has been a little in-active?
Re: Difference between oldand new carhealth -
Remi-X - 19.06.2009
?
Re: Difference between oldand new carhealth -
Andom - 19.06.2009
pawn Код:
new oldhealth[MAX_PLAYERS];
forward CarHealthTimer();
forward OnPlayerVehicleHealthChange(playerid, vehicleid, Float:oldhealth, Float:newhealth);
public OnGameModeInit()
{
SetTimer("CarHealthTimer", 1000, true);
return 1;
}
public CarHealthTimer()
{
for (new i=0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
new Float:current;
new vehicleid = GetPlayerVehicleID(i);
GetVehicleHealth(vehicleid, current);
if(current != oldhealth[i])
{
OnPlayerVehicleHealthChange(i, vehicleid, oldhealth[i], current);
}
oldhealth[i] = current;
}
}
return 1;
}
public OnPlayerVehicleHealthChange(playerid, vehicleid, Float:oldhealth, Float:newhealth)
{
// Do something
return 1;
}