Confusing business system
#1

Ok i have this business system right,

pawn Код:
enum bizInfo
{
    bType,
    bStatus,
    bOwner[32],
    Float:bX,
    Float:bY,
    Float:bZ,
    bPickup,
    bMoney,
    bProducts,
    Text3D:bText,
    bSold,
    bLevel,
    bPrice,
    bAP
}
new BizInfo[MAX_BIZ][bizInfo];

stock RBT(bizid)
{
    new string[24];
    if(!BizInfo[bizid][bType]) format(string, sizeof(string), "None");
    else if(BizInfo[bizid][bType] == 1) format(string, sizeof(string), "24/7 Market");
    else if(BizInfo[bizid][bType] == 2) format(string, sizeof(string), "Clothes Shop");
    else if(BizInfo[bizid][bType] == 3) format(string, sizeof(string), "Ammunation");
    else if(BizInfo[bizid][bType] == 4) format(string, sizeof(string), "Club");
    else if(BizInfo[bizid][bType] == 5) format(string, sizeof(string), "Advertisement Agency");
    else if(BizInfo[bizid][bType] == 6) format(string, sizeof(string), "Fast Food");
    return string;
}
stock RBS(bizid)
{
    new string[16];
    if(!BizInfo[bizid][bStatus]) format(string, sizeof(string), "Closed");
    else if(BizInfo[bizid][bStatus]) format(string, sizeof(string), "Open");
    return string;
}

stock LoadBiz()
{
    if(!fexist("biz.cfg")) fcreate("biz.cfg");
    new binfo[12][32];
    new string[256];
    new File:file = fopen("biz.cfg", io_read);
    if(file)
    {
        new idx = 1;
        while(idx < MAX_BIZ)
        {
            fread(file, string);
            split(string, binfo, '|');
            BizInfo[idx][bType] = strval(binfo[0]);
            BizInfo[idx][bStatus] = strval(binfo[1]);
            format(BizInfo[idx][bOwner], 32, "%s", binfo[2]);
            BizInfo[idx][bX] = floatstr(binfo[3]);
            BizInfo[idx][bY] = floatstr(binfo[4]);
            BizInfo[idx][bZ] = floatstr(binfo[5]);
            BizInfo[idx][bMoney] = strval(binfo[6]);
            BizInfo[idx][bProducts] = strval(binfo[7]);
            BizInfo[idx][bSold] = strval(binfo[8]);
            BizInfo[idx][bLevel] = strval(binfo[9]);
            BizInfo[idx][bPrice] = strval(binfo[10]);
            BizInfo[idx][bAP] = strval(binfo[11]);
            if(BizInfo[idx][bType]) // If Business is owned
            {
                BizInfo[idx][bPickup] = CreateDynamicPickup(1272, 1, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], 0);
                if(!strcmp("The State", BizInfo[idx][bOwner])) format(string, sizeof(string), "ID: %d\n%s\nOwner: %s\nStatus: For Sale\nPrice: $%d", idx, RBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice]);
                else format(string, sizeof(string), "ID: %d\n%s\nOwner: %s\nStatus: %s", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
                BizInfo[idx][bText] = CreateDynamic3DTextLabel(string, COLOR_GREY, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]+0.3, 15);
            }
            idx++;
        }
    }
    print("Businesses loaded successfully.");
    return 1;
}

stock SaveBiz()
{
    if(!fexist("biz.cfg")) fcreate("biz.cfg");
    new idx = 1, File:file;
    new string[256];
    while(idx < MAX_BIZ)
    {
        format(string, sizeof(string), "%d|%d|%s|%f|%f|%f|%d|%d|%d|%d|%d|%d\r\n", BizInfo[idx][bType], BizInfo[idx][bStatus], BizInfo[idx][bOwner], BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], BizInfo[idx][bMoney], BizInfo[idx][bProducts], BizInfo[idx][bSold], BizInfo[idx][bLevel], BizInfo[idx][bPrice], BizInfo[idx][bAP]);
        if(idx == 1)
        {
            file = fopen("biz.cfg", io_write);
        }
        else
        {
            file = fopen("biz.cfg", io_append);
        }
        fwrite(file, string);
        fclose(file);
        idx++;
    }
    print("Businesses saved successfully.");
    return 1;
}
and when a player buys the business /buybiz it saves to their profile and everything as the business id but when the player relogs the business 3d text says its theirs but none of the commands associated with the business can be used to always returns error you do not own a business
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)