Change /Rob <ID> into /Rob (GetClosestPlayer)
#9

Quote:
Originally Posted by 15outland
Посмотреть сообщение
Where exactly do I place this?

Float:distanceP2P(playerid, toplayerid)
{
new Float1pos[3], Float: p2pos[3];
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;
}
I've fixed the code now, I've written it blindly on the forum and not in Pawno, so it was kinda difficult to find mistakes.
Place these two functions anywhere on your script that is OUTSIDE of any other callback.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)