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



help wot to get distance kill - emuk - 09.05.2010

how can i get this ?
player1 killed player2. (desert) with 60 Health (Distance: 10m)
thanks


Re: help wot to get distance kill - ¤Adas¤ - 09.05.2010

pawn Код:
stock Float:GetDistanceBetweenPoints(Float:X, Float:Y, Float:Z, Float:PointX, Float:PointY, Float:PointZ) return floatsqroot(floatadd(floatadd(floatpower(floatsub(X, PointX), 2.0), floatpower(floatsub(Y, PointY), 2.0)), floatpower(floatsub(Z, PointZ), 2.0)));

stock Float:GetDistanceBetweenPlayers(playerid, otherplayerid)
{
new Float:X[2], Float:Y[2], Float:Z[2];
GetPlayerPos(playerid, X[0], Y[0], Z[0]);
GetPlayerPos(otherplayerid, X[1], Y[1], Z[1]);
return GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1]);
}



Re: help wot to get distance kill - emuk - 09.05.2010

and how to get the message on chat ?


Re: help wot to get distance kill - ¤Adas¤ - 09.05.2010

format(string, sizeof(string), "* Player %s killed %s! Distance: %.1f", killerid_name, playerid_name, GetDistanceBetweenPlayers(playerid, killerid));

And send it


Re: help wot to get distance kill - Killa_ - 09.05.2010

pawn Код:
new WeaponNames[][20] = {
{"Unarmed"},{"Brass Knuckles"},{"Golf Club"},{"Night Stick"},{"Knife"},{"Bat"},{"Shovel"},{"Pool Cue"},{"Katana"},{"Chainsaw"},{"Dildo"},{"Vibrator1"},{"Vibrator2"},{"Vibrator3"},{"Flowers"},{"Cane"},{"Grenade"},{"Tear Gas"},{"Molotov"},{" "},{"N/A"},{" "},{"Pistol"},
{"Silencer"},{"Deagle"},{"Shotgun"},{"Sawnoff"},{"Spas12"},{"Mac-10"},{"Mp5"},{"AK-47"},{"M4"},{"Tec-9"},{"Rifle"},{"Sniper"},{"RPG"},{"HeatSeeker"},{"Flamethrower"},{"Minigun"},{"Satchel"},{"Detonator"},{"Spraycan"},{"Extinguisher"},{"Camera"},{"Nightvision"},{"Infrared"},{"Parachute"},{" "},{" "},{"Vehicle Collision"},{"HeliKill"},{"Explosion"},{" "},{" "},{"Long Fall"}};
// Top Of Your Script Out Of Any CallBack

public OnPlayerDeath(playerid,killerid,reason)
{
  new
  PlayerNick[MAX_PLAYER_NAME],
  KillerNick[MAX_PLAYER_NAME],
  Float:H,
  Float:A,
  String[128];
  GetPlayerHealth(killerid,H);GetPlayerArmour(killerid,A);
  GetPlayerName(playerid, PlayerNick, MAX_PLAYER_NAME);
  GetPlayerName(killerid, KillerNick, MAX_PLAYER_NAME);
  format(String,sizeof(String),"*** %s Killed %s (%s) (HP : %.0f) (Dist : %.2f Ft)",KillerNick,PlayerNick,WeaponNames[reason],H+A,GetDistanceBetweenPlayers(playerid,killerid));
  SendClientMessageToAll(Colour,String);
  return 1;
}



Re: help wot to get distance kill - ¤Adas¤ - 09.05.2010

Quote:
Originally Posted by Killa_
pawn Код:
new WeaponNames[][20] = {
{"Unarmed"},{"Brass Knuckles"},{"Golf Club"},{"Night Stick"},{"Knife"},{"Bat"},{"Shovel"},{"Pool Cue"},{"Katana"},{"Chainsaw"},{"Dildo"},{"Vibrator1"},{"Vibrator2"},{"Vibrator3"},{"Flowers"},{"Cane"},{"Grenade"},{"Tear Gas"},{"Molotov"},{" "},{"N/A"},{" "},{"Pistol"},
{"Silencer"},{"Deagle"},{"Shotgun"},{"Sawnoff"},{"Spas12"},{"Mac-10"},{"Mp5"},{"AK-47"},{"M4"},{"Tec-9"},{"Rifle"},{"Sniper"},{"RPG"},{"HeatSeeker"},{"Flamethrower"},{"Minigun"},{"Satchel"},{"Detonator"},{"Spraycan"},{"Extinguisher"},{"Camera"},{"Nightvision"},{"Infrared"},{"Parachute"},{" "},{" "},{"Vehicle Collision"},{"HeliKill"},{"Explosion"},{" "},{" "},{"Long Fall"}};
// Top Of Your Script Out Of Any CallBack

public OnPlayerDeath(playerid,killerid,reason)
{
  new
  PlayerNick[MAX_PLAYER_NAME],
  KillerNick[MAX_PLAYER_NAME],
  Float:H,
  Float:A,
  String[128];
  GetPlayerHealth(killerid,H);GetPlayerArmour(killerid,A);
  GetPlayerName(playerid, PlayerNick, MAX_PLAYER_NAME);
  GetPlayerName(killerid, KillerNick, MAX_PLAYER_NAME);
  format(String,sizeof(String),"*** %s Killed %s (%s) (HP : %.0f) (Dist : %.2f Ft)",KillerNick,PlayerNick,WeaponNames[reason],H+A,GetDistanceBetweenPlayers(playerid,killerid));
  SendClientMessageToAll(Colour,String);
  return 1;
}
Yes, nice example 4 him :P


Re: help wot to get distance kill - emuk - 09.05.2010

thanks mates work but:
(1069) : warning 208: function with tag result used before definition, forcing reparse

1069tock Float:GetDistanceBetweenPlayers(playerid, otherplayerid)
{
new Float:X[2], Float:Y[2], Float:Z[2];
GetPlayerPos(playerid, X[0], Y[0], Z[0]);
GetPlayerPos(otherplayerid, X[1], Y[1], Z[1]);
return GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1]);
}




Re: help wot to get distance kill - ¤Adas¤ - 09.05.2010

put stock of this function above usage


Re: help wot to get distance kill - Killa_ - 09.05.2010

pawn Код:
stock Float:GetDistanceBetweenPoints(Float:X, Float:Y, Float:Z, Float:PointX, Float:PointY, Float:PointZ) return floatsqroot(floatadd(floatadd(floatpower(floatsub(X, PointX), 2.0), floatpower(floatsub(Y, PointY), 2.0)), floatpower(floatsub(Z, PointZ), 2.0)));

stock Float:GetDistanceBetweenPlayers(playerid, otherplayerid)
{
new Float:X[2], Float:Y[2], Float:Z[2];
GetPlayerPos(playerid, X[0], Y[0], Z[0]);
GetPlayerPos(otherplayerid, X[1], Y[1], Z[1]);
return GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1]);
}
Remove this from your script which Adas posted, its not necessary


Re: help wot to get distance kill - ¤Adas¤ - 09.05.2010

It is necessary! SA-MP have not default function like that. ach..