27.05.2010, 00:06
What is the function so that if player is at a certain point, it shows them gametext. "IsPlayerInRangeOfPoint"? if so, where in the script would this go?
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;
}
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;
}

#define PlayerToPoint(%0,%1, IsPlayerInRangeOfPoint(%1,%0,
)//mostly OnGameModeInit
SetTimer("Timer", 1000, true);
forward Timer();
public Timer()
{
for(new i; i != MAX_PLAYERS; i++)
{ //loops through all players
if(IsPlayerInRangeOfPoint(playerid, 5.0, X, Y, Z))
{ //check if the player in in range of X, Y, Z
GameTextForPlayer(playerid, "Hello!", 5000, 4); //the gametext
}
}
}