forward Float:GetDistanceBetweenPlayers(playerid,targetplayerid);
public Float:GetDistanceBetweenPlayers(playerid,targetplayerid)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if(!IsPlayerConnected(playerid) || !IsPlayerConnected(targetplayerid)) {
return -1.00;
}
GetPlayerPos(playerid,x1,y1,z1);
GetPlayerPos(targetplayerid,x2,y2,z2);
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
public OnPlayerDeath(playerid, killerid, reason)
{
new string[128], player[MAX_PLAYER_NAME], killer[MAX_PLAYER_NAME];
new Float:dist = GetDistanceBetweenPlayers(playerid, killerid);
GetPlayerName(killerid, killer, sizeof(killer));
GetPlayerName(playerid, player, sizeof(player));
format(string, sizeof(string), "*Player %s has killed %s from distance: %.2f", killer, player, dist);
SendClientMessageToAll(0xFFFFFFFF, string);
return 1;
}
new Float:x;
new Float:y;
new Float:z;
new
Float: fDistance = GetPlayerDistanceFromPoint(playerid, x, y, z),
szMessage[44];
format(szMessage, sizeof(szMessage), "%s has killed %s from the distance of %0.2f", killerid, playerid, fDistance);
SendClientMessage(playerid, 0xA9C4E4FF, szMessage);
will this work
pawn Код:
|
[..] Get the position of the player who died and then use the above function for the killer and the position of the player who died. It returns the distance between the two players.
|
new Float:x, Float:y, Float:z, Float:fDistance, szMessage[44];
GetPlayerPos(playerid, x, y, z);
fDistance = GetPlayerDistanceFromPoint(killerid, x, y, z);
format(szMessage, sizeof(szMessage), "%s has killed %s from the distance of %0.2f", killerid, playerid, fDistance);
SendClientMessage(playerid, 0xA9C4E4FF, szMessage);
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
new Float:x, Float:y, Float:z, Float:fDistance, szMessage[90], szName[MAX_PLAYER_NAME];
GetPlayerPos(playerid, x, y, z);
fDistance = GetPlayerDistanceFromPoint(killerid, x, y, z);
GetPlayerName(killerid, szMessage, MAX_PLAYER_NAME);
GetPlayerName(playerid, szName, MAX_PLAYER_NAME);
format(szMessage, sizeof(szMessage), "%s has killed %s from the distance of %0.2f", szMessage, szName, fDistance);
SendClientMessage(playerid, 0xA9C4E4FF, szMessage);
// I assume you wanted a message to all?
//SendClientMessageToAll(0xA9C4E4FF, szMessage);
}
return 1;
}