SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 24/06/2012, 07:15 PM   #1
jeffery30162
Big Clucker
 
Join Date: Jun 2012
Posts: 129
Reputation: 0
Default [help] PPC_Business || PPC_Housing

solved.. but ima having another problem...

here

http://forum.sa-mp.com/showthread.ph...51#post1947951

Last edited by jeffery30162; 26/06/2012 at 09:22 PM.
jeffery30162 is offline   Reply With Quote
Old 24/06/2012, 10:41 PM   #2
Badger(new)
Huge Clucker
 
Badger(new)'s Avatar
 
Join Date: May 2008
Posts: 430
Reputation: 4
Default Re: [help] PPC_Business

Hello.

If you want all players to be able to enter, then you don't need to check what businesses the player owns.

pawn Code:
COMMAND:enter(playerid, params[])
{
    // If a player hasn't logged in properly, he cannot use this command
    if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;

    // Setup local variables
    new BusID, BusType;

    // Make sure the player isn't inside a vehicle
    if (GetPlayerVehicleSeat(playerid) == -1)
//end of start
First off, I'd recommend using "if(! GetPlayerVehicleID(playerid) )" to check if the player is in a vehicle.
This basically checks if the vehicle ID for that player is 0 (the ! means the condition after it must be FALSE or 0).

Now.
pawn Code:
//continued from above
        // Loop through all player-owned businesses
        for (new BusSlot; BusSlot < MAX_BUSINESSPERPLAYER; BusSlot++)
        {
            // Get the business-id at the selected slot from the player
            BusID = APlayerData[playerid][Business][BusSlot];

            // Check if the player has a business in this slot
            if (BusID != 0)
            {
Here you should instead be looping through all the businesses on the server, rather than every business slot the player has.
Example:
pawn Code:
for(new BID; BID < sizeof(ABusinessData); BID++)
Here, we will use:
"BID" for the ID of the business that the loop is on
"sizeof(ABusinessData)" to work out how many businesses the loop will need to go through (if you have a function/variable that can find the exact number of businesses in the server, use that instead)

And then basically you can continue with the code:
pawn Code:
//continue from "end of start" above
        for(new BID; BID < sizeof(ABusinessData); BID++)
        {
            if (IsPlayerInRangeOfPoint(playerid, 2.5, ABusinessData[BID][BusinessX], ABusinessData[BID][BusinessY], ABusinessData[BID][BusinessZ]))
            {
                // Get the business-type
                BusType = ABusinessData[BID][BusinessType];

                // Set the worldid so other players cannot see him anymore
                SetPlayerVirtualWorld(playerid, 2000 + BID);
                // Set the player inside the interior of the business
                SetPlayerInterior(playerid, ABusinessInteriors[BusType][InteriorID]);
                // Set the position of the player at the spawn-location of the business's interior
                SetPlayerPos(playerid, ABusinessInteriors[BusType][IntX], ABusinessInteriors[BusType][IntY], ABusinessInteriors[BusType][IntZ]);

                // Also set a tracking-variable to enable /busmenu to track in which business the player is
                APlayerData[playerid][CurrentBusiness] = BID;
                // Also let the player know he can use /busmenu to control his business
                SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Use {FFFF00}/busmenu{00FF00} to change options for your business");
   
                // Exit the function
                return 1;
            }
        }

Now I did fragment your code a lot, so here is the final outcome (make sure to read everything above so you can understand the errors I have pointed out):
pawn Code:
COMMAND:enter(playerid, params[])
{
    // If a player hasn't logged in properly, he cannot use this command
    if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
   
    // Setup local variables
    new BusType;//Removed BusID
   
    // Make sure the player isn't inside a vehicle
    if (! GetPlayerVehicleID(playerid) )
    {
        // Loop through all player-owned businesses
        for(new BID; BID < sizeof(ABusinessData); BID++)
        {
            if (IsPlayerInRangeOfPoint(playerid, 2.5, ABusinessData[BusID][BusinessX], ABusinessData[BusID][BusinessY], ABusinessData[BusID][BusinessZ]))
            {
                // Get the business-type
                BusType = ABusinessData[BusID][BusinessType];

                // Set the worldid so other players cannot see him anymore
                SetPlayerVirtualWorld(playerid, 2000 + BusID);
                // Set the player inside the interior of the business
                SetPlayerInterior(playerid, ABusinessInteriors[BusType][InteriorID]);
                // Set the position of the player at the spawn-location of the business's interior
                SetPlayerPos(playerid, ABusinessInteriors[BusType][IntX], ABusinessInteriors[BusType][IntY], ABusinessInteriors[BusType][IntZ]);

                // Also set a tracking-variable to enable /busmenu to track in which business the player is
                APlayerData[playerid][CurrentBusiness] = BusID;
                // Also let the player know he can use /busmenu to control his business
                SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Use {FFFF00}/busmenu{00FF00} to change options for your business");
   
                // Exit the function
                return 1;
            }
        }
    }

    // If no business was in range, allow other scripts to use the same command (like the housing-script)
    return 0;
}
__________________
New profile- http://forum.sa-mp.com/member.php?u=170114
Badger(new) is offline   Reply With Quote
Old 24/06/2012, 10:56 PM   #3
jeffery30162
Big Clucker
 
Join Date: Jun 2012
Posts: 129
Reputation: 0
Default Re: [help] PPC_Business

omfg your amazing. ima test this out right now TTTHHAAANNNKKK YYYOOUU
jeffery30162 is offline   Reply With Quote
Old 26/06/2012, 09:21 PM   #4
jeffery30162
Big Clucker
 
Join Date: Jun 2012
Posts: 129
Reputation: 0
Default Re: [help] PPC_Business

I have another problem that I can't seem to figure out. please help me.

http://forum.sa-mp.com/showthread.ph...51#post1947951
jeffery30162 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] PPC_Business PowerPC603 Filterscripts 62 29/06/2014 05:41 PM
PPC_Business Sami Ham Scripting Help 6 04/02/2013 03:53 AM


All times are GMT. The time now is 03:42 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.