Troubles with AreaCheck
#1

Hey,

I created some beds in my script, and when a player is on the bed, it should say 'Bed 1: *name*' or 'Bed 2: *name' etc.
I already made this:
Код:
forward IsPlayerInArea();
Under OnPlayerSpawn:
Код:
SetTimer("IsPlayerInArea", 1000, 1);
Bottom of script:
Код:
public IsPlayerInArea()
{
	new Float:x,Float:y,Float:z;
	for(new i=0;i<MAX_PLAYERS;i++)
	{
	  GetPlayerPos(i,x,y,z);
	  if(x >= 238.6068 && x <= 240.6635 && y >= 2066.3640 && y <= 2068.2859 && z <=23.7469) //bed 1
	  {
	    SendClientMessage(i,COLOR_RED,"Bed #1: Menace");
	    continue;
		}
		if(x >=238.5978 && x <=240.6654 && y >= 2063.0134 && y <= 2064.9238 && z <=23.7469) //bed 2
		{
		  SendClientMessage(i,COLOR_RED,"Bed #2: VonLeeuwen");
		  continue;
		}
	}
	return 1;
}
But the result is, nothing happens when I stand on the bed.

BTW: These are the coordinates:
Код:
238.6068,2066.3640,17.6406 // bed1 1st corner 
240.6635,2068.2859,17.6406 //bed1 2nd corner
238.5978,2063.0134,17.6406 // bed2 1st corner
240.6654,2064.9238,17.6406 // bed2 2nd corner
What can I do to fix it?
Reply
#2

That looks fine.
May be the coordinates are off, try outputting your coordinates, so you can make sure they are in the range as you step on the bed

Код:
public IsPlayerInArea()
{
	new Float:x,Float:y,Float:z;
	for(new i=0;i<MAX_PLAYERS;i++)
	{
	  GetPlayerPos(i,x,y,z);
	  new msg[128];
	  format(msg, sizeof(msg), "Coordinates: %f, %f, %f", x, y, z);
	  SendClientMessage(i,COLOR_RED,"Bed #1: Menace");
	  if(x >= 238.6068 && x <= 240.6635 && y >= 2066.3640 && y <= 2068.2859 && z <=23.7469) //bed 1
	  {
	    SendClientMessage(i,COLOR_RED,"Bed #1: Menace");
	    continue;
		}
		if(x >=238.5978 && x <=240.6654 && y >= 2063.0134 && y <= 2064.9238 && z <=23.7469) //bed 2
		{
		  SendClientMessage(i,COLOR_RED,"Bed #2: VonLeeuwen");
		  continue;
		}
	}
	return 1;
}
Oh and if you want an area check system that has full functionality see sig V
Reply
#3

I see, thanks a lot!
Reply
#4

So does your coordinates check suggest you are within the area given for bed1 bed2?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)