Show Gametext
#1

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?
Reply
#2

Код:
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;
}
and make a timer

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;
}
If your planning on using IsPlayerInArea i recommend this:

http://forum.sa-mp.com/index.php?topic=82857.0
Reply
#3

PlayerToPoint its the same as IsPlayerInRangeOfPoint only the the new native function is faster

Here a macro for all PlayerToPoint lover
pawn Код:
#define PlayerToPoint(%0,%1, IsPlayerInRangeOfPoint(%1,%0,
And the IsPlayerInArea function only checks for an area along the x and y axes

If you search for a function with any count of corners and any shape then search for IsPlayerInPerimeter (only one result )

I think you only need IsPlayerInRangeOfPoint for it, so just create a timer (like Coole already told us)

pawn Код:
//mostly OnGameModeInit
SetTimer("Timer", 1000, true);
pawn Код:
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
        }
    }
}
(Only wrote that because your (Coole) code looks a bit glutted for me :S)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)