SA-MP Forums Archive
Pickups. - 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: Pickups. (/showthread.php?tid=350470)



Pickups. - iGetty - 12.06.2012

I have a problem with my pickups.

The house pickups show perfectly, but when it comes to business pickups, they don't work at all.

Can anyone help me please? Code is below.

pawn Код:
public PickupMessages(playerid)
{
    new string[512];
    for(new h = 1; h < MAX_HOUSES; h++)
    {
        if(IsPlayerInAnyVehicle(playerid)) return 1;
        if(IsPlayerInRangeOfPoint(playerid, 2.0, Houses[h][HouseExteriorX], Houses[h][HouseExteriorY], Houses[h][HouseExteriorZ]))
        {
            if(GetPlayerVirtualWorld(playerid) == 0)
            {
                if(strmatch(Houses[h][HouseOwner], "Nobody"))
                {
                    if(Player[playerid][AdminLevel] == 10)
                    {
                        format(string, sizeof(string), "~w~House %d~n~~b~%s~n~~w~Use ~b~/buyhouse~w~ to~n~buy this house~n~for ~g~$%d.", h, Houses[h][HouseName], Houses[h][HousePrice]);
                    }
                    else
                    {
                        format(string, sizeof(string), "~b~%s~n~~w~Use ~b~/buyhouse~w~ to~n~buy this house~n~for ~g~$%d.", Houses[h][HouseName], Houses[h][HousePrice]);
                    }
                }
                else
                {
                    if(Player[playerid][AdminLevel] == 10)
                    {
                        format(string, sizeof(string), "~w~House %d~n~~b~%s~n~~w~Owner:~g~ %s", h, Houses[h][HouseName], Houses[h][HouseOwner]);
                    }
                    else
                    {
                        format(string, sizeof(string), "~b~%s~n~~w~Owner:~g~ %s", Houses[h][HouseName], Houses[h][HouseOwner]);
                    }
                }
            }
        }
    }
    for(new b = 1; b < MAX_BUSINESS; b++)
    {
        if(IsPlayerInAnyVehicle(playerid)) return 1;
        if(IsPlayerInRangeOfPoint(playerid, 2.0, Business[b][BusinessExteriorX], Business[b][BusinessExteriorY], Business[b][BusinessExteriorZ]))
        {
            if(GetPlayerVirtualWorld(playerid) == 0)
            {
                if(Player[playerid][AdminLevel] == 10)
                {
                    format(string, sizeof(string), "~w~Business %d~n~~b~%s~n~~w~~n~Owner:~g~ %s~n~~w~Enter Fee: ~g~$%d~n~~w~~n~Type /enter to go inside", b, Business[b][BusinessName], Business[b][BusinessOwner], Business[b][BusinessEnterFee]);
                }
                else
                {
                    format(string, sizeof(string), "~w~Business~n~~b~%s~n~~w~~n~Owner:~g~ %s~n~~w~Enter Fee: ~g~$%d~n~~w~~n~Type /enter to go inside", Business[b][BusinessName], Business[b][BusinessOwner], Business[b][BusinessEnterFee]);
                }
            }
        }
    }
    GameTextForPlayer(playerid, string, 3000, 5);
    return 1;
}
Thanks!


Re: Pickups. - iggy1 - 12.06.2012

Have you added some prints to see where it stops working?


Re: Pickups. - iGetty - 12.06.2012

I'll do that now and edit this.


Re: Pickups. - iGetty - 12.06.2012

I added prints and it seems to stop on the line:

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 2.0, Business[b][BusinessExteriorX], Business[b][BusinessExteriorY], Business[b][BusinessExteriorZ]))
Even though I'm in range of it.


Re: Pickups. - iggy1 - 12.06.2012

There must be a problem with the co-ordinates saved in the "Business" var.

A quick way to test is to teleport yourself to that location, that way you know instantly if your co-ordinates are mixed up.


Re: Pickups. - iGetty - 12.06.2012

How could I do that? Like, create a /gotobusiness command with the business ID in sscanf?

Then, check if it's letting me go to it? :3


Re: Pickups. - WillyP - 12.06.2012

Quote:
Originally Posted by iGetty
Посмотреть сообщение
How could I do that? Like, create a /gotobusiness command with the business ID in sscanf?

Then, check if it's letting me go to it? :3
Use the co-ordinates from the Business file, and IG teleport yourself to those exact co-ordinates to see if they are accurate.


Re: Pickups. - iggy1 - 12.06.2012

Params is the index for your buisness.

pawn Код:
COMMAND:tp(playerid, params[])
{
    new idx = strval(params);
   
    if( idx > -1 && idx < sizeof(Business) )
    {
        SetPlayerPos(playerid, Business[idx][BusinessExteriorX], Business[idx][BusinessExteriorY], Business[idx][BusinessExteriorZ]);
    }
    return 1;
}



Re: Pickups. - iGetty - 12.06.2012

Found the problem.. It seems to only let me go to ID 1..

No more than 1, or I'm falling in blueberry... What's wrong?

Here's my LoadBusinesses();

pawn Код:
stock LoadBusinesses()
{
    new
        Str[128],
        string[512],
        bID,
        bName[128],
        bOwner[24],
        Float:ExtX,
        Float:ExtY,
        Float:ExtZ,
        Float:IntX,
        Float:IntY,
        Float:IntZ,
        Price,
        Enterable,
        IntID,
        Fee,
        PayOut,
        Locked,
        World;

    mysql_query("SELECT * FROM `Businesses`");
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(Str))
        {
            sscanf(Str, "p<|>is[128]s[24]ffffffiiiiiii", bID, bName, bOwner, ExtX, ExtY, ExtZ, IntX, IntY, IntZ, IntID, Price, Enterable, Fee, PayOut, Locked, World);
            BusinessPickup[bID] = CreatePickup(1272, 1, ExtX, ExtY, ExtZ, 0);
            new i = 1;
            Business[i][BusinessExteriorX] = ExtX;
            Business[i][BusinessExteriorY] = ExtY;
            Business[i][BusinessExteriorZ] = ExtZ;
            Business[i][BusinessInteriorX] = IntX;
            Business[i][BusinessInteriorY] = IntY;
            Business[i][BusinessInteriorZ] = IntZ;
            Business[i][BusinessInteriorID] = IntID;
            Business[i][BusinessPrice] = Price;
            Business[i][BusinessEnterable] = Enterable;
            Business[i][BusinessEnterFee] = Fee;
            Business[i][BusinessPayout] = PayOut;
            Business[i][BusinessLocked] = Locked;
            Business[i][BusinessWorld] = World;
            format(Business[i][BusinessName], 128, "%s", bName);
            format(Business[i][BusinessOwner], 24, "%s", bOwner);
            if(Enterable == 0)
            {
                format(string, sizeof(string), "{FF0000}%s\nOwner:{FFFFFF}%s\n{FF0000}Payout: {FFFFFF}$%d", bName, bOwner, PayOut);
            }
            else
            {
                format(string, sizeof(string), "{33FF33}%s\nEntrance Fee: {FFFFFF}$%d{33FF33}\nOwner: {FFFFFF}%s\n{33FF33}Payout: {FFFFFF}$%d", bName, Fee, bOwner,PayOut);
            }
            BusinessLabel[i] = Create3DTextLabel(string, BLUE, ExtX, ExtY, ExtZ, 7.0, 0, 1);
            i++;
            bTotal++;
        }
    }
    mysql_free_result();
    printf("%i businesses loaded from the MySQL Database.", bTotal);
}
It works for my houses, but not businesses.. It's also creating the business pickup and label in the correct place.


Re: Pickups. - iggy1 - 12.06.2012

pawn Код:
new i = 1;
Your resetting the index var to 1 every loop.