05.12.2009, 09:18
GetPos
With this function you can simply get one coordinate of a player.
_________________________________________________
Posids:
X - 1
Y - 2
Z - 3
_________________________________________________
For example if you want get the player Z coord;
new Float: Z = GetPos(playerid,3);
_________________________________________________
GetClosestPlayer
This function returns the closest player to you, except you.
If you only want to search in a radius just set that if not just miss that. If you missed that, the function will search all of SA.
Epsilon
pawn Код:
Float:GetPos(playerid,posid)
{
new Float:id[3];
if(IsPlayerInAnyVehicle(playerid)) GetVehiclePos(GetPlayerVehicleID(playerid),id[0],id[1],id[2]);else GetPlayerPos(playerid,id[0],id[1],id[2]);
return id[posid-1];
}
_________________________________________________
Posids:
X - 1
Y - 2
Z - 3
_________________________________________________
For example if you want get the player Z coord;
new Float: Z = GetPos(playerid,3);
_________________________________________________
GetClosestPlayer
pawn Код:
GetClosestPlayer(except,Float: radius = 99999.9999)
{
new Float:dis[2],e[2];
e[0] = INVALID_PLAYER_ID;
dis[0] = radius;
for (e[1]=0;e[1]<MAX_PLAYERS;e[1]++)
if(IsPlayerConnected(e[1]) && e[1] != except)
dis[1] = floatsqroot(floatpower(floatabs(floatsub(GetPos(e[1],1),GetPos(except,1))),2)+floatpower(floatabs(floatsub(GetPos(e[1],2),GetPos(except,2))),2)+floatpower(floatabs(floatsub(GetPos(e[1],3),GetPos(except,3))),2));
if(dis[1]< dis[0])
{
dis[0] = dis[1];
e[0] = e[1];
}
return e[0];
}
If you only want to search in a radius just set that if not just miss that. If you missed that, the function will search all of SA.
Epsilon