Dynamic Business system
#1

im trying to make a business system, but for some reason, the business doesnt load, it doesnt save like its supposed to. In the .ini, it registers properly, but ONLY THE FIRST BIZ CREATED, every other business you create shows the ID in the business folder, but the files are blank. Every address also comes up as 78 and price 1, but that is not the variable set.

pawn Код:
enum bInfo
{
    bType,
    bName[58],
    bOwner[MAX_PLAYER_NAME],
    bCreated,
    bLocked,
    bWorld,
    bOwned,
    bPrice,
    bTill,
    bAddress,
    Float:bExtX,
    Float:bExtY,
    Float:bExtZ,
    Float:bExtA,
    Float:bIntX,
    Float:bIntY,
    Float:bIntZ,
    Float:bIntA,
};
under ongamemodeinit
pawn Код:
new str[40];
    for(new bizid = 1; bizid < sizeof(BizInfo); bizid++)
    {
        new bstr[100];
        format(str, sizeof(str), BPATH, bizid);
        format(bstr, sizeof(bstr), "%s\nAddress:%d\nPrice:%d", BizInfo[bizid][bName], BizInfo[bizid][bAddress], BizInfo[bizid][bPrice]);
        INI_ParseFile(str, "loadbiz_%d", .bExtra = true, .extra = bizid );
        Create3DTextLabel(bstr, COLBLUE, BizInfo[bizid][bExtX], BizInfo[bizid][bExtY], BizInfo[bizid][bExtZ], 5, 0, true);
    }
    SetTimer("updatebiz", 500, true);
    SetTimer("savebiz", 600000, true);
Note: updatebiz does work as it is supposed to.

pawn Код:
public OnGameModeExit()
    {
    new str[40];
    for(new bizid = 1; bizid < sizeof(BizInfo); bizid++)
        {
        format(str, sizeof(str), BPATH, bizid);
        SaveBusiness(bizid);
        return 1;
        }
    printf("All businesses saved!");
    return 1;
    }
   
   
forward savebiz();
public savebiz()
    {
    new str[40];
    for(new bizid = 1; bizid < sizeof(BizInfo); bizid++)
        {
        format(str, sizeof(str), BPATH, bizid);
        SaveBusiness(bizid);
        return 1;
        }
    printf("All businesses saved!");
    return 1;
    }
pawn Код:
forward loadbiz_data(bizid, name[], value[]);
public loadbiz_data(bizid, name[], value[])
{
    INI_Int("Type", BizInfo[bizid][bType]);
    INI_ParseFile("Name", BizInfo[bizid][bName]);
    INI_ParseFile("Owner", BizInfo[bizid][bOwner]);
    INI_Int("Created", BizInfo[bizid][bCreated]);
    INI_Int("Locked", BizInfo[bizid][bLocked]);
    INI_Int("World", BizInfo[bizid][bWorld]);
    INI_Int("Owned", BizInfo[bizid][bOwned]);
    INI_Int("Price", BizInfo[bizid][bPrice]);
    INI_Int("Till", BizInfo[bizid][bTill]);
    INI_Int("Address", BizInfo[bizid][bAddress]);
    INI_Float("Ext: X", BizInfo[bizid][bExtX]);
    INI_Float("Ext: Y", BizInfo[bizid][bExtY]);
    INI_Float("Ext: Z", BizInfo[bizid][bExtZ]);
    INI_Float("Ext: A", BizInfo[bizid][bExtA]);
    INI_Float("Int: X", BizInfo[bizid][bIntX]);
    INI_Float("Int: Y", BizInfo[bizid][bIntY]);
    INI_Float("Int: Z", BizInfo[bizid][bIntZ]);
    INI_Float("Int: A", BizInfo[bizid][bIntA]);
    return 1;
}
pawn Код:
stock SaveBusiness(bizid)
{
    new file1[40];
    format(file1, sizeof(file1), BPATH, bizid);
    new INI:File = INI_Open(file1);
    INI_WriteInt(File, "Type", BizInfo[bizid][bType]);
    INI_WriteString(File, "Name", BizInfo[bizid][bName]);
    INI_WriteString(File, "Owner", BizInfo[bizid][bOwner]);
    INI_WriteInt(File, "Created", BizInfo[bizid][bCreated]);
    INI_WriteInt(File, "Locked", BizInfo[bizid][bLocked]);
    INI_WriteInt(File, "World", BizInfo[bizid][bWorld]);
    INI_WriteInt(File, "Owned", BizInfo[bizid][bOwned]);
    INI_WriteInt(File, "Price", BizInfo[bizid][bPrice]);
    INI_WriteInt(File, "Till", BizInfo[bizid][bTill]);
    INI_WriteInt(File, "Address", BizInfo[bizid][bAddress]);
    INI_WriteFloat(File, "Ext: X", BizInfo[bizid][bExtX]);
    INI_WriteFloat(File, "Ext: Y", BizInfo[bizid][bExtY]);
    INI_WriteFloat(File, "Ext: Z", BizInfo[bizid][bExtZ]);
    INI_WriteFloat(File, "Ext: A", BizInfo[bizid][bExtA]);
    INI_WriteFloat(File, "Int: X", BizInfo[bizid][bIntX]);
    INI_WriteFloat(File, "Int: Y", BizInfo[bizid][bIntY]);
    INI_WriteFloat(File, "Int: Z", BizInfo[bizid][bIntZ]);
    INI_WriteFloat(File, "Int: A", BizInfo[bizid][bIntA]);
    INI_Close(File);
    return 1;
}
and finally, the command

pawn Код:
CMD:createbiz(playerid, params[])
    {
    new bizid;
    for(new h = 1;h < sizeof(BizInfo);h++)
    {
     bizid = h;
     break;
    }
   
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(pid, X, Y, Z);
    new string[255];
    format(string, sizeof(string), "None");
    BizInfo[bizid][bType] = 1;
    strmid(BizInfo[bizid][bName], string, 0, strlen(string), 255);
    strmid(BizInfo[bizid][bOwner], string, 0, strlen(string), 255);
    BizInfo[bizid][bCreated] = 1;
    BizInfo[bizid][bLocked] = 0;
    BizInfo[bizid][bWorld] = 0;
    BizInfo[bizid][bOwned] = 0;
    BizInfo[bizid][bPrice] = 0;
    BizInfo[bizid][bTill] = 0;
    BizInfo[bizid][bAddress] = bizid;
    BizInfo[bizid][bExtX] = X;
    BizInfo[bizid][bExtY] = Y;
    BizInfo[bizid][bExtZ] = Z;
    BizInfo[bizid][bExtA] = 0;
    BizInfo[bizid][bIntX] = 0;
    BizInfo[bizid][bIntY] = 0;
    BizInfo[bizid][bIntZ] = 0;
    BizInfo[bizid][bIntA] = 0;
    new file1[40];
    format(file1, sizeof(file1), BPATH, bizid);
    new INI:File = INI_Open(file1);
    INI_SetTag(File, "Business Info");
    INI_WriteInt(File, "Type", BizInfo[bizid][bType]);
    INI_WriteString(File, "Name", BizInfo[bizid][bName]);
    INI_WriteString(File, "Owner", BizInfo[bizid][bOwner]);
    INI_WriteInt(File, "Locked", BizInfo[bizid][bLocked]);
    INI_WriteInt(File, "World", BizInfo[bizid][bWorld]);
    INI_WriteInt(File, "Owned", BizInfo[bizid][bOwned]);
    INI_WriteInt(File, "Price", BizInfo[bizid][bPrice]);
    INI_WriteInt(File, "Till", BizInfo[bizid][bTill]);
    INI_WriteInt(File, "Address", BizInfo[bizid][bAddress]);
    INI_WriteFloat(File, "Ext: X", BizInfo[bizid][bExtX]);
    INI_WriteFloat(File, "Ext: Y", BizInfo[bizid][bExtY]);
    INI_WriteFloat(File, "Ext: Z", BizInfo[bizid][bExtZ]);
    INI_WriteFloat(File, "Ext: A", BizInfo[bizid][bExtA]);
    INI_WriteFloat(File, "Int: X", BizInfo[bizid][bIntX]);
    INI_WriteFloat(File, "Int: Y", BizInfo[bizid][bIntY]);
    INI_WriteFloat(File, "Int: Z", BizInfo[bizid][bIntZ]);
    INI_WriteFloat(File, "Int: A", BizInfo[bizid][bIntA]);
    INI_Close(File);
    SCM(pid, COLGREEN, "Server: {F0F0F0}Biz created.");
    return 1;
    }
And a screen of what I see:



Side note: I'll rep you if you help me, even if it dont fix the problem, and the reason for the difference in title and textdraw is because i changed the name and didnt update the SCM yet.
Reply
#2

That is because when you are loading the name and address you are using INI_Int instead of INI_String.

Edit: Also noticed some other mistakes.
When you are formatting the 3d text label, you are using %d specifier for strings, when you must use %s.
The address seems to be string type, but at your enum it is integer.
Reply
#3

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
That is because when you are loading the name and address you are using INI_Int instead of INI_String.

Edit: Also noticed some other mistakes.
When you are formatting the 3d text label, you are using %d specifier for strings, when you mist use %d.
The address seems to be string type, but at your enum it is integer.
INI_ParseFile("Name", BizInfo[bizid][bName]);

And the address is an integer, therefore should be INI_INT
Reply
#4

Why parsefile Dude parsefile is way advanced an you are using it wrong.
Replace with INI_String("Name", bizinfo[blabla], sizeof(bizinfo[blabla]));
Reply
#5

INI string was giving me an error though :S
Reply
#6

Then you have to show the error so we can help.
Reply
#7

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
Then you have to show the error so we can help.
But it saves the business owner and name? Also, I looked it up, and it said to do it like that, so I did :P

error 017: undefined symbol "INI_String"
INI_String("Name", BizInfo[bizid][bName]);

If it was an issue with the way I entered it, it would give an error of tag mismatch or something like that

EDIT:
INI_String("Name", BizInfo[bizid][bName], 30);

It makes sense to have the sizeof in there, but idk why it would give unidentified error :S
Reply
#8

Ok I see you got another error, but is it the same as the first one?
Reply
#9

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
Ok I see you got another error, but is it the same as the first one?
I got no errors, I fixed the issue, as said above. But what I need to know is why its always saying ID 78, but the business is ID 1, and it says ID 1 in the .ini.
Reply
#10

Hmm, what exactly is the business ID, the Type? And where does it show that, at the label or elsewhere?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)