27.05.2010, 00:16
Код:
stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
return 0;
}
Код:
stock IsPlayerInArea(playerid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)
{
new Float:Xa, Float:Ya, Float:Za;
GetPlayerPos(playerid, Xa, Ya, Za);
if(Xa <= max_x && Xa >= min_x && Ya <= max_y && Ya >= min_y) return 1;
return 0;
}
Ex:
Код:
forward Place();
public Place()
{
for(new i=0; i<MAX_PLAYERS; i++ )
{
if(IsPlayerConnected(i) && IsPlayerInArea(i, x, y, x, y) && Place[i] == 0) // CHECK: If the player is a admin, if the player is in the area
{
SendClientMessage(i,COLOR_GREEN,"[ ! ] Welcome to Place.");
Place[i] = 1;
return 1;
}
else if(IsPlayerConnected(i) && !IsPlayerInArea(i, x, y, x, y) && Place[i] == 1)
{
SendClientMessage(i,COLOR_YELLOW,"[ ! ] You leave Place.");
Place[i] = 0;
return 1;
}
}
return 1;
}
Код:
forward Place();
public Place()
{
for(new i=0; i<MAX_PLAYERS; i++ )
{
if(IsPlayerConnected(i) && PlayerToPoint(i, x, y, z) && Place[i] == 0) // CHECK: If the player is a admin, if the player is in the area
{
SendClientMessage(i,COLOR_GREEN,"[ ! ] Welcome to Place.");
Place[i] = 1;
return 1;
}
else if(IsPlayerConnected(i) && !PlayerToPoint(i, x, y, z) && Place[i] == 1)
{
SendClientMessage(i,COLOR_YELLOW,"[ ! ] You leave Place.");
Place[i] = 0;
return 1;
}
}
return 1;
}
http://forum.sa-mp.com/index.php?topic=82857.0

