SA-MP Forums Archive
format() crashes my server - 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: format() crashes my server (/showthread.php?tid=353767)



format() crashes my server - Makaveli93 - 24.06.2012

Well, I used print() to debug my code and find the reason why my server is crashing, and it turns out that it gets stuck at the format line.

pawn Код:
format(string, sizeof(string), "[CHECKOUT:] You have purchased %s (%d) for $%d.", AttachmentObjects[listitem][attachname], AttachmentObjects[listitem][attachmodel], AttachmentObjects[listitem][attachprice]);
These are the enums associated with this line of code:

pawn Код:
enum AttachmentEnum
{
    attachmodel,
    attachname[24],
    attachprice
}

new AttachmentObjects[][AttachmentEnum] = {
{19006, "Glasses 1", 40},
{19007, "Glasses 2", 40},
{19008, "Glasses 3", 40},
{19009, "Glasses 4", 40},
{18891, "Bandana", 50},
{18911, "Mask", 70},
{18921, "Beret", 60},
{18926, "Hat", 40},
{18936, "Helmet", 80},
{18944, "Boater", 80},
{18962, "Boater", 80}
};
What am I doing wrong here?


Re: format() crashes my server - HuSs3n - 24.06.2012

pawn Код:
AttachmentObjects[listitem][attachname]
make sure that listitem isnt bigger than the maximum size of AttachmentObjects (not bigger than 10)


Re: format() crashes my server - Makaveli93 - 24.06.2012

Hmm, well it shouldn't be. I'm using a loop to form a dialog string.

pawn Код:
new string2[4000+1];
        for(new x;x<sizeof(AttachmentObjects);x++)
        {
            format(string2, sizeof(string2), "%s%s - $%d\n", string2, AttachmentObjects[x][attachname], AttachmentObjects[x][attachprice]);
        }
        ShowPlayerDialog(playerid,71, DIALOG_STYLE_LIST, \
        "{FF0000}Select an item to purchase.", string2, "Buy", "Cancel");



Re: format() crashes my server - Finn - 24.06.2012

Does it crash when you press "Buy" or when you press "Cancel"