Question - 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: Question (
/showthread.php?tid=278329)
Question -
Tanush123 - 21.08.2011
How can i make if someone enters the zone
pawn Code:
Aztec = GangZoneCreate(1695.218, -1958.204, 1820.712, -1863.458);
It will show, "You have enter Varrios Los Aztecas Territory"
Re: Question -
Darnell - 21.08.2011
https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
pawn Code:
if(IsPlayerInRangeOfPoint(playerid, 1.0,1695.218, -1958.204, 1820.712, -1863.458))
{
SendClientMessage(playerid,0xFFFFFFFF,"You have enter Varrios Los Aztecas Territory.");
}
Re: Question -
Tanush123 - 21.08.2011
Where do i add that xD??
Re: Question -
Darnell - 21.08.2011
https://sampwiki.blast.hk/wiki/Areacheck
Re: Question -
dowster - 21.08.2011
Quote:
Originally Posted by Darnell
|
wouldnt that just be a circle?
Edit: Nvm just saw your areacheck post, that is the way to check for a square/rectangle area.
Re: Question -
Tanush123 - 21.08.2011
I get a spam full of you have enter varios terriotorY**
pawn Code:
forward isPlayerInArea();
public isPlayerInArea()
{
for(new i=0; i < MAX_PLAYERS; i++) //This line defines a name for all player, the name is "i"
{
GetPlayerPos(i,X,Y,Z);
if(X <= 2725 && X >= -1662 && Y <= 2858 && Y >= -1500)
{
SendClientMessage(i,orange,"You have entered Varrios Los Aztecas Territory");
}
}
return 1;
}
OnGameModeInIt
pawn Code:
SetTimer("isPlayerInArea", 1000, 1);
Re: Question -
Improvement™ - 21.08.2011
This is how I would do it.
pawn Code:
//Somewhere on top of your script
new bool:IsPlayerInLosAztTer[MAX_PLAYERS];
//Somewhere in the middle between the Callbacks (public's)
forward isPlayerInArea();
public isPlayerInArea()
{
for(new i=0; i < MAX_PLAYERS; i++) //This line defines a name for all player, the name is "i"
{
new Float:Pos_X, Float:Pos_Y, Float:Pos_Z);
GetPlayerPos(i , Pos_X, Pos_Y, Pos_Z);
if(Pos_X <= 2725 && Pos_X >= -1662 && Pos_Y <= 2858 && Pos_Y >= -1500)
{
if(IsPlayerInLosAztTer[i]) return 1;
if(!IsPlayerInLosAztTer[i])
{
SendClientMessage(i,orange,"You have entered the Varrios Los Aztecas Territory");
IsPlayerInLosAztTer[i] = true;
return 1;
}
}
else
{
if(!IsPlayerInLosAztTer[i]) return 1;
if(IsPlayerInLosAztTer[i])
{
SendClientMessage(i, orange, "You have left the Varrios Los Aztecas Territory");
IsPlayerInLosAztTer[i] = false;
return 1;
}
}
}
return 1;
}
FIRST EDIT: Just editted everything into foreach, sorry didn't saw it earlier.
If you would like me to //comment everything and explain it all for you, just reply to this topic

.
I hope this helps.
Kind Regards,
Improvement™
Re: Question -
dowster - 21.08.2011
Quote:
Originally Posted by Improvement™
This is how I would do it.
pawn Code:
//Somewhere on top of your script new bool:IsPlayerInLosAztTer[MAX_PLAYERS];
//Somewhere in the middle between the Callbacks (public's) forward isPlayerInArea(); public isPlayerInArea() { for(new i=0; i < MAX_PLAYERS; i++) //This line defines a name for all player, the name is "i" { new Float:Pos_X, Float:Pos_Y, Float:Pos_Z); GetPlayerPos(i , Pos_X, Pos_Y, Pos_Z); if(Pos_X <= 2725 && Pos_X >= -1662 && Pos_Y <= 2858 && Pos_Y >= -1500) { if(IsPlayerInLosAztTer[i]) return 1; if(!IsPlayerInLosAztTer[i]) { SendClientMessage(i,orange,"You have entered the Varrios Los Aztecas Territory"); IsPlayerInLosAztTer[i] = true; return 1; } } else { if(!IsPlayerInLosAztTer[i]) return 1; if(IsPlayerInLosAztTer[i]) { SendClientMessage(i, orange, "You have left the Varrios Los Aztecas Territory"); IsPlayerInLosAztTer[i] = false; return 1; } } } return 1; }
FIRST EDIT: Just editted everything into foreach, sorry didn't saw it earlier.
If you would like me to //comment everything and explain it all for you, just reply to this topic  .
I hope this helps.
Kind Regards,
Improvement™
|
Also, if you have multiple areas instead of making a who bunch of boolean values you could have a variable store the id of the area they are in.
Re: Question -
Tanush123 - 22.08.2011
Dude when i connect to server i get a message saying i enter and when i spawn it says i leave
Re: Question -
Improvement™ - 22.08.2011
Quote:
Originally Posted by Tanush123
Dude when i connect to server i get a message saying i enter and when i spawn it says i leave
|
Do you have any such player variables compared to these?:
pawn Code:
new bool:IsPlayerSpawned[MAX_PLAYERS];
new bool:IsPlayerLogged[MAX_PLAYERS];
new gPlayerSpawned[MAX_PLAYERS];
new gPlayerLogged[MAX_PLAYERS];
If so then please post them, I will fix this issue.