loop [REP++]
#1

I made a business system and when the player buy items in the market, Then I want to add money to the business but how to get the file of the business that i am in ?
Reply
#2

Something like
pawn Код:
new bizID;
for(new i; i<MAX_BUSINESSES; i++)
{
    if(IsPlayerInRangeOfPoint(playerid, 5.0, bizInfo[i][xPos], bizInfo[i][yPos], bizInfo[i][zPos]))
    {
        bizID = i;
        break;
    }
}
Reply
#3

This will detect the id of the business ??
Reply
#4

You will need to define "MAX_BUSINESSES", the "bizInfo[i]"'s and such according to your script.
But other than that, it'll set "bizID" to a business if you are in range of it by 5 GTA SA Units.
Reply
#5

Guys , Wait
This is all my bisiness system the main defines
PHP код:
new InsideBiz[MAX_PLAYERS];
enum bInfo
{
    
bOwned,
    
bPrice,
    
bOwner[MAX_PLAYER_NAME],
    
bType,
    
bLocked,
    
bMoney,
    
Float:bEntranceX,
    
Float:bEntranceY,
    
Float:bEntranceZ,
    
Float:bEntranceA,
    
Float:bExitX,
    
Float:bExitY,
    
Float:bExitZ,
    
Float:bExitA,
    
bInt,
    
bWorld,
    
bInsideInt,
    
bInsideWorld,
    
bInsideIcon,
    
bOutSideIcon,
    
bName[128]
}
new 
BusinessInfo[200][bInfo];
new 
biz 0;
new 
Float:beforeEnterX[MAX_PLAYERS];
new 
Float:beforeEnterY[MAX_PLAYERS];
new 
Float:beforeEnterZ[MAX_PLAYERS]; 
Reply
#6

If you use different interior ID's for each business, you could simply do this:
pawn Код:
for(new i; i < 200; i++) // Loops through the number "200"
{
    if(GetPlayerInterior(playerid) == BusinessInfo[i][bInsideInt]) // Checks if the player's Interior ID is the same as the Business's Interior ID
    {
        InsideBiz[playerid] = i; // Sets the "InsideBiz" value to the number that he had the same interior ID as
        break; // Stops the loop once this is found
    }
}
Where "InsideBiz" will be set to the business ID the player is inside of.
I would recommend instead of using "200", that you should do this:
pawn Код:
#define MAX_BUSINESSES 200
And then change 200 in the loop, and in the enumerator
pawn Код:
for(new i; i < 200; i++)
new BusinessInfo[200][bInfo];
To MAX_BUSINESSES
pawn Код:
for(new i; i < MAX_BUSINESSES; i++)
new BusinessInfo[MAX_BUSINESSES][bInfo];
With this method, you can easily change the Businesses limit by changing the #define, otherwise you have to check through all your code for the "200"'s and change them to a new limit each time you wanna change it.
Reply
#7

Ok, But there is a common interiors so may be 50 business with the same interior
Reply
#8

In that case you will need to either change that, or find another method to see if a player is in a business.
Reply
#9

When a player enters a business. Assign the business ID in a variable.


PS: Show your enter business code.
Reply
#10

When player enters the business:
pawn Код:
SetPlayerVirtualWorld(playerid, 500 + business_id); // use your own value
And when you want to get the business ID where the player is standing:
pawn Код:
new bizzid = GetPlayerVirtualWorld(playerid) - 500;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)