mybag / inventory help
#1

i have a problem with /mybag command, when i type it, it should be saying the name of the Item, however, no matter what item i put in the slot, when i type /mybag it says slot:1 mybag when it should say slot:1 [itemname].

pawn Код:
#define MAX_ITEMS 10
#define BAGCOUNT 5
#define EMPTY_BAGSPACE -1
#define ecard 1
#define smedal 2
#define gmedal 3
#define mayorsig 4
#define swatsig 5
#define sdoc1 6
#define sdoc2 7
#define sdoc3 8
#define sdoc4 9
#define sdocfull 10

new Bags[MAX_PLAYERS][BAGCOUNT];
new ItemNames[MAX_ITEMS][32] =
{
{"Electing Card"},
{"Silver Medal"},
{"Gold Medal"},
{"Mayor Signature"},
{"Swat Signature"},
{"Secret Document 1"},
{"Secret Document 2"},
{"Secret Document 3"},
{"Secret Document 4"},
{"Secret Document Full"}
};
pawn Код:
dcmd_mybag(playerid, params[])
{
    #pragma unused params
    new bagitem[128], bagitem2[128], bagitem3[128], bagitem4[128], bagitem5[128];
    SendClientMessage(playerid, COLOR_YELLOW, "-----------------------------------------------");
    SendClientMessage(playerid, COLOR_YELLOW, "      Your Bag");
    SendClientMessage(playerid, COLOR_YELLOW, "-----------------------------------------------");
    for (new i = 0; i < BAGCOUNT; i++)
    {
        if (Bags[playerid][0] == EMPTY_BAGSPACE) format(bagitem, sizeof(bagitem), "Slot:1 ", i + 1);
        else format(bagitem, sizeof(bagitem), "Slot:1 %s", i + 1, ItemNames[Bags[playerid][i] - 1]);
        SendClientMessage(playerid, COLOR_WHITE, bagitem);
        if (Bags[playerid][1] == EMPTY_BAGSPACE) format(bagitem2, sizeof(bagitem2), "Slot:2 ", i + 1);
        else format(bagitem2, sizeof(bagitem2), "Slot:2 %s", i + 1, ItemNames[Bags[playerid][i] - 1]);
        SendClientMessage(playerid, COLOR_WHITE, bagitem2);
        if (Bags[playerid][2] == EMPTY_BAGSPACE) format(bagitem3, sizeof(bagitem3), "Slot:3 ", i + 1);
        else format(bagitem3, sizeof(bagitem3), "Slot:3 %s", i + 1, ItemNames[Bags[playerid][i] - 1]);
        SendClientMessage(playerid, COLOR_WHITE, bagitem3);
        if (Bags[playerid][3] == EMPTY_BAGSPACE) format(bagitem4, sizeof(bagitem4), "Slot:4 ", i + 1);
        else format(bagitem4, sizeof(bagitem4), "Slot:4 %s", i + 1, ItemNames[Bags[playerid][i] - 1]);
        SendClientMessage(playerid, COLOR_WHITE, bagitem4);
        if (Bags[playerid][4] == EMPTY_BAGSPACE) format(bagitem5, sizeof(bagitem5), "Slot:5 ", i + 1);
        else format(bagitem5, sizeof(bagitem5), "Slot:5 %s", i + 1, ItemNames[Bags[playerid][i] - 1]);
        SendClientMessage(playerid, COLOR_WHITE, bagitem5);
        return 1;
    }
    SendClientMessage(playerid, COLOR_YELLOW, "-----------------------------------------------");
    return 1;
}
Reply
#2

nobody can help?
Reply
#3

Quote:

format(bagitem1, sizeof(bagitem1), "Slot:1 ", i + 1);
format(bagitem2, sizeof(bagitem2), "Slot:2 ", i + 1);
format(bagitem3, sizeof(bagitem3), "Slot:3 ", i + 1);
format(bagitem4, sizeof(bagitem4), "Slot:4 ", i + 1);
format(bagitem5, sizeof(bagitem5), "Slot:5 ", i + 1);

Why the "i + 1"?
Reply
#4

im not sure, i was learning this from another post, i just tried it without the +1 though and nothing would show up in the bag
Reply
#5

Oh nvm, you are right, i just realized that in the tutorial there was a %d there in those string and i removed it, thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)