How to check if the player is in an 24/7
#1

Hi, I want to make a function that checks if the player is in an 24/7 or not?, I tried that but it didn't work :
Код:
stock IsIn247(playerid)
{
	for(new x; x<sizeof(bInfo); x++)
	{
	    if(bInfo[x][bType] == 1)
	    {
			if(IsPlayerInRangeOfPoint(playerid,15,bInfo[x][bInteriorX],bInfo[x][bInteriorY],bInfo[x][bInteriorZ]))
			{
				return 1;
			}
		}
	}
	return 0;
}
I want to create something like that above to make it more easier than using that in every command
Код:
 for(new x; x<sizeof(XXX); x++)...
Is there any way to do that?
Reply
#2

Isn't using GetPlayerInterior function easier?

https://sampwiki.blast.hk/wiki/GetPlayerInterior
Reply
#3

Quote:
Originally Posted by FailerZ
Посмотреть сообщение
Isn't using GetPlayerInterior function easier?

https://sampwiki.blast.hk/wiki/GetPlayerInterior
What ever I check it will keep showing
Код:
undefined symbol "bInfo
Reply
#4

Quote:
Originally Posted by Logan0147
Посмотреть сообщение
What ever I check it will keep showing
Код:
undefined symbol "bInfo
also what if two businesses have the same INT..
PHP код:
stock IsIn247(playerid)
{
    new 
interior GetPlayerInterior(playerid);
    if(
interior == 17 || interior == 10) return 1//Add the rest of the 24/7 interior ids check them on wiki
    
return 0;

You can combine it with virtual worlds then I guess if you are going to use same interior for other business
Reply
#5

There are various ways:
- set a variable with index playerid to the ID of the building they are in upon entering, and use the ID to get the business type (whether it is a 24/7, tattoo shop, etc.)
- check if player's x, y and z axis is within the min and max axis for the interior
- etc.

First "way" is more efficient (whether you care or just want it to work overall).
Reply
#6

I just do this.

Make a new variable called 24/7, and when he enters the 24/7 just do 24/7[playerid] == 1 and when he exits do 24/7[playerid] == 0.
Reply
#7

Why not use one variable for all buildings? It will be more efficient in the long run (as you add more businesses).

Player enters 24/7:
PHP код:
pInBusinessID[playerid] = business_id
Player leaves building:
PHP код:
pInBusinessID[playerid] = -1
Check if player is in any business:
PHP код:
if(pInBusinessID[playerid] != -1
Check if player isn't in any business:
PHP код:
if(pInBusinessID[playerid] == -1
Get the business type the player is in:
PHP код:
new business_type GetBusinessType(pInBusinessID[playerid]);
or as 
a string 
You'd just have to create GetBusinessType adapting it to your system.
Reply
#8

Thanks y'all for the ideas !
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)