IsPlayerInArea Help
#1

Код:
stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    return minx < x < maxx && miny < y < maxy;
}
If player is in area 
i want the game to send a client message
idk how
can someone show me please?!
Reply
#2

Create a timer.
Example :
pawn Код:
forward CheckArea();
public CheckArea()
{
     if(IsPlayerInArea(Coordinates here))
     {
            //Do your stuff here.
     }
     return 1;
}
Then call the timer for example, every two seconds under on game mode init.
pawn Код:
// Under on game mode init
SetTimer("CheckArea",2000,1);
Reply
#3

pawn Код:
// somewhere in a callback
if( IsPlayerInArea( playerid, minx, maxx, miny, maxy ) )
{
    SendClientMessage( playerid, 1, "you're in area X." );
}
Reply
#4

pawn Код:
stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(minx < x < maxx && miny < y < maxy) return true;
    return false;
}
Example of it's use in a command:
pawn Код:
CMD:area(playerid,params[])
{
    #pragma unused params
    if(IsPlayerInArea(playerid, 400.5, 900.2, 134.223, 198.54523))
    {
        SendClientMessage(playerid, 0x00FF00FF, "You are in the right area!!");
    }
    else return SendClientMessage(playerid, 0xFF0000FF, "You're not in the right area -____-.");
    return 1;
}
Reply
#5

gamemodeint
SetTimer("CheckArea",2000,1);


stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
new Float, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
return minx < x < maxx && miny < y < maxy;
}

forward CheckArea(playerid);
public CheckArea(playerid)
{
if(IsPlayerInArea(playerid,2424,-1758,2640,-1620))
{
SendClientMessage(playerid,COLOR_GREEN,"Your on Property of GS Watch Your back");
}
return 1;
}
it still doesnt work i used
http://gtaforum.hu/index.php?PHPSESS...&page=gangzone
to get the zones and all iz failing me
Reply
#6

all those things are buggy it keeps telling me im not in area
Reply
#7

add this after the if(IsPlayerInArea

pawn Код:
else if(!IsPlayerInArea(playerid,2424,-1758,2640,-1620))
{
}
Reply
#8

Use this:
pawn Код:
stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(minx < x < maxx && miny < y < maxy) return true;
    return false;
}
Reply
#9

Romel i get error if i put else if in the checkarea ummmmmmm still getting nothing
Код:
stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(minx < x < maxx && miny < y < maxy) return true;
    return false;
}

forward CheckArea(playerid);
public CheckArea(playerid)
{
 if(IsPlayerInArea(playerid,2424,-1758,2640,-1620))
 {
  SendClientMessage(playerid,COLOR_GREEN,"Your on Property of GS Watch Your back");
 }
 else if(!IsPlayerInArea(playerid,2424,-1758,2640,-1620))
 {
 SendClientMessage(playerid,COLOR_GREEN,"Your on Property of GS Watch Your back");
 }
 return 1;
}
Reply
#10

This should work:
pawn Код:
public OnPlayerSpawn(playerid)
{
    SetTimerEx("CheckArea", 1000, true, "i", playerid);
    return 1;
}
   
forward CheckArea(playerid);
public CheckArea(playerid)
{
    if(IsPlayerInArea(playerid,2424,-1758,2640,-1620))
    {
        SendClientMessage(playerid,COLOR_GREEN,"Your on Property of GS Watch Your back");
    }
    else
    {
       SendClientMessage(playerid, COLOR_RED,"You're not on Property of GS.");
    }
    return 1;
}

stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(minx < x < maxx && miny < y < maxy) return true;
    return false;
}
NOTE: This WILL spam the player with messages once they spawn, it would be better to assign it to a command rather than a timer.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)