SA-MP Forums Archive
help distance kill - 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: help distance kill (/showthread.php?tid=145146)



help distance kill - emuk - 01.05.2010

how do I get this?
for example:
Player2 was killed by Player1 | (M4) | Player1 Health: 80 Armour: 0 Distance: 5.41 meter
thanks


Re: help distance kill - OKStyle - 03.06.2010

smth like that:

To OnPlayerDeath:
pawn Code:
new PlayerName[MAX_PLAYER_NAME],TargetName[MAX_PLAYER_NAME],string[128],Float:HP,Float:AP,weaponName[65];
GetPlayerName(playerid,PlayerName,sizeof(PlayerName));
GetPlayerName(killerid,TargetName,sizeof(TargetName));
GetPlayerHealth(killerid,HP);
GetPlayerArmour(killerid,AP);
GetWeaponName(GetPlayerWeapon(killerid), weaponName, 64);
format(string,sizeof(string,"%s was killed by %s | (%s) | %s's Health: %f, Armour: %f Distance: %f meter",PlayerName,TargetName,TargetName,weaponName,HP,AP,GetDistancePlayertoPlayer(playerid,killerid));
SendClientMessageToAll(0xFFFF00FF,string);
To end of the mode:
pawn Code:
public Float:GetDistancePlayertoPlayer(playerid,playerid2)
{
 if(!IsPlayerConnected(playerid)) return 65000.0;
 if(!IsPlayerConnected(playerid2)) return 65000.0;
 new Float:x1, Float:y1, Float:z1;
 new Float:x2, Float:y2, Float:z2;
 GetPlayerPos(playerid,x1,y1,z1);
 GetPlayerPos(playerid2,x2,y2,z2);
 new Float:dist = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
return dist;
}