If Is Player In Gangzone... How to create a function like that ??
#1

Hi guys...

And I want to show other players if another player comes into their gangzone

Would this work --->

Код:
grovezone = GangZoneCreate(1923.388, -1930.57, 2847.478, -1492.37);

new Float: x, Float y;
GetPlayerPos(x,y,z,rotation);
GetPlayerName(name,sizeof(name));

if(x < 2847.478 && x > 1923.388 && y < -1492.37 && x > -1930.57)
{
format(string,sizeof(string),"%s Is In Grove Street Families Territority!",name);
SendClientMessageToAll(COLOR-PURPLE,string);
}
Could someone help me ?

Bearfist

Reply
#2

You can use the IsPlayerInZone.... then just use a timer....

pawn Код:
stock IsPlayerInZone( playerid, Float:XMin, Float:YMin, Float:XMax, Float:YMax )
{
    new RetValue = 0;
    new Float: PosX, Float: PosY, Float: PosZ;
    GetPlayerPos( playerid, PosX, PosY, PosZ );

    if( PosX >= XMin && PosY >= YMin && PosX < XMax && PosY < YMax )
    {
      RetValue = 1;
    }
    return RetValue;
}
Reply
#3

Now my code looks like this:

Код:
stock IsPlayerInZone( playerid, Float:XMin, Float:YMin, Float:XMax, Float:YMax )
{
	new RetValue = 0;
	new Float: PosX, Float: PosY, Float: PosZ;
	GetPlayerPos( playerid, PosX, PosY, PosZ );

	if( PosX >= XMin && PosY >= YMin && PosX < XMax && PosY < YMax )
	{
	  RetValue = 1;
	}
	return RetValue;
}

public GangAlarm(playerid)
{
	  for (new i=0;i < MAX_PLAYERS;i++)
	  {
	  
			if(IsPlayerConnected(i) == 1)
			{
			GetPlayerName(playerid,name,sizeof(name));
	    new EnterGZ[MAX_PLAYERS];
	    new Float:XMin, Float:YMin, Float:XMax, Float: YMax;
			IsPlayerInZone(playerid, Float:XMin, Float:YMin, Float:XMax, Float:YMax);
				//GROVEZONE
	    if(XMax < 2847.478 && XMin > 1923.388 && YMax < -1492.37 && YMin > -1930.57)
	    {
      format(string,sizeof(string),"%s Is In Grove Street Family Street Territority!",name);
	    SendClientMessageToAll(COLOR_GREEN,string);
	    EnterGZ[playerid] = 1;
	    }
	    //BALLASZONE
      if(XMax < 2261.841 && XMin > 1611.556 && YMax < -1006.798 && XMin > -1496.318)
      {
      format(string,sizeof(string),"%s Is In Ballas Territority!",name);
	    SendClientMessageToAll(COLOR_GREEN,string);
	    EnterGZ[playerid] = 1;
      }
      //VAGOSZONE
      if(XMax < 2893.112 && XMin > 2280.885 && YMin < -1077.857 && YMax > -1484.475)
      {
      format(string,sizeof(string),"%s Is In LS Vagos Territority!",name);
	    SendClientMessageToAll(COLOR_GREEN,string);
	    EnterGZ[playerid] = 1;
      }
	    //AZTECASZONE
      if(XMax < 1908.177 && XMin > 1349.16 && YMax < -1504.214 && YMin > -2041.106)
      {
      format(string,sizeof(string),"%s Is In Varios Los Aztecas Territority!",name);
	    SendClientMessageToAll(COLOR_GREEN,string);
	    EnterGZ[playerid] = 1;
      }
	    //PUNKZONE
      if(XMax < 1622.964 && XMin > 927.0455 && YMax < -967.3207 && YMin > -1504.214)
      {
      format(string,sizeof(string),"%s Is In Punk's Territority!",name);
	    SendClientMessageToAll(COLOR_GREEN,string);
	    EnterGZ[playerid] = 1;
			}
			}
    }
}
PS: There are no warnings an errors ... but it doesn't works =(
Help...

Bearfist
Reply
#4

put a timer in OnGamemodeInit....

pawn Код:
SetTimer("GangAlarm" 1000, 1); // update on every second
Reply
#5

I have it
Код:
GangA = SetTimer("GangAlarm",5000,1);
defined too^^

But it doesn't work -_-
Reply
#6

Just put without anything before....

pawn Код:
SetTimer("GangAlarm",5000,1);
Reply
#7

Alright I try...

I changed the code to this
Код:
stock IsPlayerInZone( playerid, Float:XMin, Float:YMin, Float:XMax, Float:YMax )
{
	new RetValue = 0;
	new Float: PosX, Float: PosY, Float: PosZ;
	GetPlayerPos( playerid, PosX, PosY, PosZ );
	GetPlayerName(playerid,name,sizeof(name));
	new EnterGZ[MAX_PLAYERS];

	if( PosX >= XMin && PosY >= YMin && PosX < XMax && PosY < YMax )
	{
      //GROVEZONE
	    if(PosX >= 1923.388 && PosY >= -1930.57 && PosX < 2847.478 && PosY < -1492.37)
	    {
      format(string,sizeof(string),"%s Is In Grove Street Family Street Territority!",name);
	    SendClientMessageToAll(COLOR_GREEN,string);
	    EnterGZ[playerid] = 1;
	    }

	    //BALLASZONE
      if(PosX >= 1611.556 && PosY >= -1496.318 && PosX < 2261.841 && PosY < -1006.798)
      {
      format(string,sizeof(string),"%s Is In Ballas Territority!",name);
	    SendClientMessageToAll(COLOR_GREEN,string);
	    EnterGZ[playerid] = 1;
      }
      //VAGOSZONE
      if(PosX >= 2280.885 && PosY >= -1484.475 && PosX < 2893.112 && PosY < -1077.857)
      {
      format(string,sizeof(string),"%s Is In LS Vagos Territority!",name);
	    SendClientMessageToAll(COLOR_GREEN,string);
	    EnterGZ[playerid] = 1;
      }
	    //AZTECASZONE
      if(PosX >= 1349.16 && PosY >= -2041.106 && PosX < 1908.177 && PosY < -1504.214 )
      {
      format(string,sizeof(string),"%s Is In Varios Los Aztecas Territority!",name);
	    SendClientMessageToAll(COLOR_GREEN,string);
	    EnterGZ[playerid] = 1;
      }
	    //PUNKZONE
      if(PosX >= 927.0455 && PosY >= -1504.214 && PosX < 1622.964 && PosY < -967.3207 )
      {
      format(string,sizeof(string),"%s Is In Punk's Territority!",name);
	    SendClientMessageToAll(COLOR_GREEN,string);
	    EnterGZ[playerid] = 1;
			}
	    RetValue = 1;
	}
	return RetValue;
}

public GangAlarm(playerid)
{
	 for (new i=1;i < MAX_PLAYERS;i++)
	 {
	  
			if(IsPlayerConnected(i) == 1)
			{
			new Float:XMin,Float:YMin,Float:XMax,Float:YMax;
			IsPlayerInZone(playerid, Float:XMin, Float:YMin, Float:XMax, Float:YMax);
			}
   }
}
BEFORE:
Код:
if(XMax < 2847.478 && XMin > 1923.388 && YMax < -1492.37 && YMin > -1930.57)
AFTER
Код:
if(PosX >= 1923.388 && PosY >= -1930.57 && PosX < 2847.478 && PosY < -1492.37)
and I do not change GangA to SetPlayerTimer, because I need It to Kill the Timer On game mode exit ^^

Bearfist
Reply
#8

You also can IsPlayerInArea.
Reply
#9

What Is the difference between IsPlayerInArea and IsPlayerInZone
??

..now I know the difference ^^
IsPlayerIn Area works xDD
joke...it's more easy to handle with

Thanks for all helpers =)

Bearfist
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)