SA-MP Forums Archive
If Is Player In Gangzone... How to create a function like that ?? - 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: If Is Player In Gangzone... How to create a function like that ?? (/showthread.php?tid=75044)



If Is Player In Gangzone... How to create a function like that ?? - Bearfist - 28.04.2009

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




Re: If Is Player In Gangzone... How to create a function like that ?? - Mike-Chip - 28.04.2009

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



Re: If Is Player In Gangzone... How to create a function like that ?? - Bearfist - 28.04.2009

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


Re: If Is Player In Gangzone... How to create a function like that ?? - Mike-Chip - 28.04.2009

put a timer in OnGamemodeInit....

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



Re: If Is Player In Gangzone... How to create a function like that ?? - Bearfist - 28.04.2009

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

But it doesn't work -_-


Re: If Is Player In Gangzone... How to create a function like that ?? - Mike-Chip - 28.04.2009

Just put without anything before....

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



Re: If Is Player In Gangzone... How to create a function like that ?? - Bearfist - 28.04.2009

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


Re: If Is Player In Gangzone... How to create a function like that ?? - MenaceX^ - 28.04.2009

You also can IsPlayerInArea.


Re: If Is Player In Gangzone... How to create a function like that ?? - Bearfist - 28.04.2009

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