Leaving/Entering Area -- Help
#1

Hey
Im A Beginier Scripter and i got a Question How To Do
I want to make something happend when Player Leaves / Enters Certain Area


Код:
[Coords: 276.903594, 1786.037231, 17.640625] 
[Coords: 97.394775, 1940.976806, 18.216493]
Those Are My Cordinates For my 1 Area
And I Want To Make When Player with Class Id 0 Leaves that area it will Make (setwantedlevel 6 and change player color red but i know how to make that but i dont know how to make it that it cheacks if player is in that area)

I know there will be timer -
Код:
	SetTimer("AreaChecks", 10000, 1);
and
Код:
forward AreaChecks();
public AreaChecks()
{

}
Reply
#2

pawn Код:
new PlayerInArea[MAX_PLAYERS];

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

forward AreaChecks();
public AreaChecks()
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInArea(i, 97.394775, 276.903594, 1786.037231, 1940.976806))
            {
                PlayerInArea[i] = 1;
            }
            else
            {
                if(PlayerInArea[i] == 1)
                {
                    PlayerInArea[i] = 0;
                    //player has left the area
                }
            }
        }
    }
}
Reply
#3

ok this works fine but when
i put under PlayerInArea[i] = 0;
Код:
				if(playerid,(classid != 0))
        			{
       				SetPlayerWantedLevel(playerid, 6);
        			}
it does not set wanted level 6
Reply
#4

You need to save the classid first.

pawn Код:
new PlayerClass[MAX_PLAYERS];

public OnPlayerRequestClass(playerid, classid)
{
    PlayerClass[playerid] = classid;
    return 1;
}
And then replace playerid with i.

pawn Код:
if(PlayerClass[i] == 0)
{
    SetPlayerWantedLevel(i, 6);
}
Reply
#5

Big Thanks :]]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)