SA-MP Forums Archive
Help with detecting vehicle damage - 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: Help with detecting vehicle damage (/showthread.php?tid=375367)



Help with detecting vehicle damage - spudi - 06.09.2012

Hi, I have a problem. I want to do something when player damage vehicle. For test I want to SetPlayerMessage.

Top in my script:
Код:
new Float:dhp[MAX_PLAYERS];
public OnGameModeInit:
Код:
SetTimer("DamageUpdate", 1000, true);
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger):
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
		new vehiclepid;
		vehiclepid = GetPlayerVehicleID(playerid);
                dhp[playerid] = GetVehicleHealth(vehiclepid, dhp[playerid]);
		return 1;
}
Down in my script:
Код:
forward DamageUpdate(playerid);
public DamageUpdate(playerid)
{
		new vehicleid;
		vehicleid = GetPlayerVehicleID(playerid);
		new Float:nhp;
		nhp = GetVehicleHealth(vehicleid, nhp);
		if(nhp != dhp[playerid]) SendClientMessage(playerid,-1,"{FFFFFF}Damage"), dhp[playerid] = nhp;

}
It show message only when I get in/out vehicle. But I want to show when I damage a vehicle.
Sorry for my bad english. ; <


Re: Help with detecting vehicle damage - CROSS_Hunter - 06.09.2012

Change This:
pawn Код:
public DamageUpdate(playerid)
{
        new vehicleid;
        vehicleid = GetPlayerVehicleID(playerid);
        new Float:nhp;
        nhp = GetVehicleHealth(vehicleid, nhp);
        if(nhp != dhp[playerid]) SendClientMessage(playerid,-1,"{FFFFFF}Damage"), dhp[playerid] = nhp;

}
To This:
pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
new vehicleid;
        vehicleid = GetPlayerVehicleID(playerid);
        new Float:nhp;
        nhp = GetVehicleHealth(vehicleid, nhp);
        if(nhp != dhp[playerid]) SendClientMessage(playerid,-1,"{FFFFFF}Damage"), dhp[playerid] = nhp;
          return 1;
}
EDIT: and delete
pawn Код:
forward DamageUpdate(playerid);



Re: Help with detecting vehicle damage - Kirollos - 06.09.2012

huh why you write like that
Код:
dhp[playerid] = GetVehicleHealth(vehiclepid, dhp[playerid]);
and
Код:
nhp = GetVehicleHealth(vehicleid, nhp);
?

only should be like that

Код:
GetVehicleHealth(vehiclepid, dhp[playerid]);
and
Код:
GetVehicleHealth(vehicleid, nhp);



Re: Help with detecting vehicle damage - HuSs3n - 06.09.2012

why you dont just use this
https://sampwiki.blast.hk/wiki/OnVehicleDamageStatusUpdate


Re: Help with detecting vehicle damage - spudi - 06.09.2012

Okey, thanks guys. I use OnVehicleDamageStatusUpdate and all it's working, THANKS!