SA-MP Forums Archive
Text shown when enering a teritory - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Text shown when enering a teritory (/showthread.php?tid=84675)



Text shown when enering a teritory - mdaniel - 02.07.2009

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


Re: Text shown when enering a teritory - mdaniel - 07.07.2009

Anybody ?


Re: Text shown when enering a teritory - happyface - 07.07.2009

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 !");

        }
    }
}



Re: Text shown when enering a teritory - mdaniel - 08.07.2009

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


Re: Text shown when enering a teritory - mdaniel - 08.07.2009

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


Re: Text shown when enering a teritory - mdaniel - 08.07.2009

HELP please !


Re: Text shown when enering a teritory - Jakku - 21.07.2009

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


Re: Text shown when enering a teritory - MadeMan - 21.07.2009

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