format() crashes my server
#1

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?
Reply
#2

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

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");
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)