SA-MP Forums Archive
loop [REP++] - 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)
+--- Thread: loop [REP++] (/showthread.php?tid=564208)



loop [REP++] - nezo2001 - 20.02.2015

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 ?


Re: loop [REP++] - Schneider - 20.02.2015

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



Re: loop [REP++] - nezo2001 - 20.02.2015

This will detect the id of the business ??


Re: loop [REP++] - CalvinC - 20.02.2015

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.


Re: loop [REP++] - nezo2001 - 20.02.2015

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



Re: loop [REP++] - CalvinC - 20.02.2015

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.


Re: loop [REP++] - nezo2001 - 20.02.2015

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


Re: loop [REP++] - CalvinC - 20.02.2015

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


Re: loop [REP++] - Beckett - 20.02.2015

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


PS: Show your enter business code.


Re: loop [REP++] - dominik523 - 20.02.2015

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;