Text shown when enering a teritory
#1

Hi, lets say I want to make a gang zone, And I want that, when you enter the teritory of the gang zone it would write something...

So lets say that I have the teritory assaigned like that...:
stock IsGangzone(Float,Float:y){
if(y < 2252.83 && y > 2213.796 && x < -2422.32 && x > -2496.709) return true;
return false; }

When I enter that square It should write :
SendClientMessage(playerid,COLOR," Be aware ! GANG ZONE ! stop! don't go further !");

I hope you understud what im asking for...
Maybe something like OnPlayerEnterGangzone Im just a begginer in the scripting stuff... Thanks verry much
Reply
#2

Anybody ?
Reply
#3

https://sampwiki.blast.hk/wiki/Areacheck
https://sampwiki.blast.hk/wiki/Useful_Fu...IsPlayerInArea

i believe this is what you want

pawn Код:
forward isPlayerInArea();
pawn Код:
public OnGameModeInit()
{
    SetTimer("isPlayerInArea",1000, 1);
    return 1;
}
pawn Код:
public isPlayerInArea()
{
    new Float:X, Float:Y, Float:Z;

    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if (X <= 1489.5120 && X >= 1467.5144 && Y <= -1680.2880 && Y >= -1715.6841) // Biggest x, Smallest x, Biggest y, Smallest y
        {
            GameTextForPlayer(i, "~w~You In An Area", 3000, 5);
            //SendClientMessage(playerid,COLOR," Be aware ! GANG ZONE ! stop! don't go further !");

        }
    }
}
Reply
#4

God Bless you.
My biggest respect for you for finding the time to answer and help me.
Everything works fine helped me a lot
Reply
#5

Well. Now I have another problem with the timer.
I started it. and when I enter the zone it spams the same text again and again.
I know that I can Kill it... thet its ok... But how to start it again after I leave the zone ?
I need it to write me just once when I enter the zone. When I leave the zone the timer should work again.
How can I do that ?
I believe it something in gamemode init... If !playerinzone = settimer.... else killtimer... But that would not work either... because when it would kill the timer it would not know when i leave the zone... So as a begginer I have no Idea what to do
Reply
#6

HELP please !
Reply
#7

Quote:
Originally Posted by mdaniel
HELP please !
Increase SetTimer time, last number in SetTimer- thing. Put it example 30000, so it shows it every 30 seconds
Reply
#8

pawn Код:
new InArea[MAX_PLAYERS];
forward CheckArea();

public OnGameModeInit()
{
    SetTimer("CheckArea",1000, 1);
    return 1;
}


public CheckArea()
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerInArea(i, 1467.5144, 1489.5120, -1715.6841, -1680.2880) && InArea[i] == 0)
        {
            GameTextForPlayer(i, "~w~You In An Area", 3000, 5);
            //SendClientMessage(playerid,COLOR," Be aware ! GANG ZONE ! stop! don't go further !");
            InArea[i] = 1;

        }
        else if (!IsPlayerInArea(i, 1467.5144, 1489.5120, -1715.6841, -1680.2880))
        {
            InArea[i] = 0;
        }
    }
}

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)