Loading business pickups.
#1

Hey guys, when my i load my businesses the pickups don't load, here the function here.

pawn Код:
Create LoadBusiness()
{
    new string[156];
    CreateDynamic3DTextLabel(string ,COLOR_BLUE,1788.5947,-1297.0627,14, 50, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0,-1,-1,-1,50);
    for(new i; i < MAX_BUSINESSES; i++)
    {
        format(string, sizeof(string), "SELECT * FROM businesses WHERE Id = %d", i);
        mysql_query(string);
        mysql_store_result();
        if(!mysql_num_rows())
        {
            mysql_free_result();
        }
        else
        {
            new Query[100];
            if(mysql_fetch_row(Query,"|"))
            {
                sscanf(Query, "p<|>e<iis[30]iiiii>", Business[i]);
            }
            if(Business[i][bLevel] == 1)
            {
                Business[i][bPrice] = 100000;
                Business[i][bPay] = 5000;
            }
                         //some more levels here.
            if(!strmatch(Business[i][bOwner], "None"))
            {
                BusinessPickups[i] = CreateDynamicPickup(1274, 23, Business[i][bX], Business[i][bY], Business[i][bZ], -1 , -1, -1, 200);
                format(string, sizeof(string), "Business is owned by:\n%s",Business[i][bOwner]);
                CreateDynamic3DTextLabel(string ,COLOR_BLUE,Business[i][bX], Business[i][bY], Business[i][bZ]+0.5, 50, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0,-1,-1,-1,50);
            }
            else
            {
                CreateDynamicMapIcon(Business[i][bX], Business[i][bY], Business[i][bZ], 52, 0, -1, -1, -1, 200);
                BusinessPickups[i] = CreateDynamicPickup(1274, 23, Business[i][bX], Business[i][bY], Business[i][bZ], -1 , -1, -1, 200);
                format(string, sizeof(string), "Business Price: $%d\n/Buybusiness to purchase it!",Business[i][bPrice]);
                CreateDynamic3DTextLabel(string ,COLOR_BLUE,Business[i][bX], Business[i][bY], Business[i][bZ]+0.5, 50, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0,-1,-1,-1,50);
            }
        }
    }
}
I also have a house system which all the pickups load for that.
i can post some other code if you need it.
Cheers, and thanks in advance.
Reply
#2

Is strmatch a SA-MP native? I can't find it anywhere... Anyways 3DTextLabels load normally?
Reply
#3

Na it's not, and nothing eles loads for them.well you can still /buybusiness and /sellbusiness at the location were i created it so they like load, but don't show up.

pawn Код:
stock strmatch(const String1[], const String2[])
{
    if ((strcmp(String1, String2, true, strlen(String2)) == 0) && (strlen(String2) == strlen(String1)))
    {
        return true;
    }
    else
    {
        return false;
    }
}

Also for some reason a checkpoint displays.

pawn Код:
command(createbusiness,playerid, params[])
{
    if(GetPlayerAdmin(playerid) < 5) return 0;
    {
        new level;
        if(sscanf(params, "i", level)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /createbusiness Level(1-7)");
        else
        {
            new string[200], Float:POS[3];
            GetPlayerPos(playerid, POS[0], POS[1], POS[2]);
            format(string, sizeof(string), "INSERT INTO `businesses` (`Id`, `bOwner`, `bLevel`, `bX`, `bY`, `bZ`) VALUES (NULL, 'None', '%d', '%f', '%f', '%f');",level, POS[0], POS[1], POS[2]);
            mysql_query(string);
            CreateDynamicMapIcon(POS[0], POS[1], POS[2], 31, 0, -1, -1, -1, 200);
            LoadBusiness();
        }
    }
    return 1;
}
Reply
#4

Dunno, try adding a variable to check if the business is owned or not, like:

pawn Код:
if(Business[i][bOwned] == 1)
                {
                    //blablabla
                }
                else if(Business[i][bOwned] == 0)
                {
                    //blablabla
                }
and if it works, it's something wrong with strmatch, however your code seems good, I can't find anything wrong with it.

Edit: The checkpoint thing is weird.

Edit again:

pawn Код:
command(createbusiness,playerid, params[])
{
    if(GetPlayerAdmin(playerid) < 5) return 0;
    {
        new level;
        if(sscanf(params, "i", level)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /createbusiness Level(1-7)");
        else
        {
            new string[200], Float:POS[3];
            GetPlayerPos(playerid, POS[0], POS[1], POS[2]);
            format(string, sizeof(string), "INSERT INTO `businesses` (`Id`, `bOwner`, `bLevel`, `bX`, `bY`, `bZ`) VALUES (NULL, 'None', '%d', '%f', '%f', '%f');",level, POS[0], POS[1], POS[2]);
            mysql_query(string);
            CreateDynamicMapIcon(POS[0], POS[1], POS[2], 31, 0, -1, -1, -1, 200);
            LoadBusiness(); //I don't think re-loading all business again is good.Make a stock function like AddBiz and add the new variables to the biz
        }
    }
    return 1;
}
Reply
#5

well yeh, the strmatch is the same as a varabile. i use the same format for my housing system also so. no idea really :/. Cheers for trying anyways
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)