09.04.2013, 14:06
Quote:
Where exactly do I place this?
Float:distanceP2P(playerid, toplayerid) { new Float ![]() GetPlayerPos(playerid, p1pos[0], p1pos[1], p1pos[2]); GetPlayerPos(playerid, p2pos[0], p2pos[1], p2pos[2]); return float(floatround(floatsqroot( ((p1pos[0] - p2pos[0]) ^2) + ((p1pos[1] - p2pos[1]) ^ 2) + ((p1pos[2] - p2pos[2]) ^ 2)))); } GetClosestPlayer(toplayerid) { new cur = INVALID_PLAYER_ID, Float: distance = 99999.99; for(new i = 0; i < MAX_PLAYERS; i++) { if( (distanceP2P(toplayerid, i) < distancetmp) && (i != toplayerid) && (i != INVALID_PLAYER_ID) ) cur = i; } return cur; } |
Place these two functions anywhere on your script that is OUTSIDE of any other callback.