SA-MP Forums Archive
Distance from player - 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: Distance from player (/showthread.php?tid=415684)



Distance from player - CrazyChoco - 14.02.2013

Well yeah, I thought about if it was possible to get the distance between players, like i mean if the distance between id 0 and 1 is below 500 meters then id 1 will die .

I looked around at the wiki, but i don't think i'm looking at the right place .

Anyhow, this is which pages i already looked at:

https://sampwiki.blast.hk/wiki/GetVehicleDistanceFromPoint
________________________________________________
^^ I don't think that's soo important, but the one below this text might be?

https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint

Any solutions?


Re: Distance from player - CrazyChoco - 14.02.2013

Quote:
Originally Posted by ******
Посмотреть сообщение
If you have two functions you think are useful, why not play about with them? That is how most people learn.
Yeah, why not? Thanks tho :3


-Silly me

EDIT: I actually think it's pretty simply, by switching some functions around :3


Re: Distance from player - adsy - 14.02.2013

I built a little stock as I figured it would be useful for me, so here it is.


Код:
stock IsPlayerInRangeOfPlayer(playerid, otherplayerid, range){
    new Float:oPX, Float:oPX, Float:oPZ;
    GetPlayerPos(otherplayerid, oPX, oPY, oPZ);
    if(IsPlayerInRangeOfPoint(playerid, range, oPX, oPY, oPZ)) return 1;
    else return 0;
}
usage:
Код:
if(IsPlayerInRangeOfPoint(playerid, otherplayerid, 10.0)) //do stuff
else //do other stuff



Re: Distance from player - adsy - 14.02.2013

I have always stuck with "if" but if you think it could be helpful I can probably reduce my code in loads of places.

Can you explain a little further, i'm the old fashioned type who likes to know about ON and OFF switches