If player in pos
#1

how do i make something so if a player is in a certain position a action will happen

explain in depth plz i am a noob
Reply
#2

you have to set a timer in nGameMdeInit
then use the PlayerToPoint function
then do your action
example
pawn Код:
public OnGameModeInit()
{
  SetTimer("MyAction", 100, true);
  return 1;
}

forward MyAction();
public MyAction()
{
  for(new i=0; i<MAX_PLAYERS; i++)
  {
    if(PlayerToPoint(Float:Radi, playerid, PosX, PosX, PosZ))
    {
      //The Action
    }
  }
}
for more info visit https://sampwiki.blast.hk/
Reply
#3

Use this function
pawn Код:
stock IsPlayerInArea(playerid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    if(X <= max_x && X >= min_x && Y <= max_y && Y >= min_y) return 1;
    return 0;
}
You do it like
pawn Код:
if(IsPlayerInArea(playerid, max x, min x, max y, min y)
and if he is in the area, the code in the if statement will execute. And as stated above, you would need a timer to check of the players in the area
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)