How to show the bag?
#1

Hello,
i was currently Scripting an Bag system for my new Gamemode... but i dont know, how to show the player his Items on the easy way.. the only way i knowed was

pawn Код:
if(PlayerInfo[playerid][pbag1] == 000001)
{
//Show item
}
else if(PlayerInfo[playerid][pbag1] == 000002)
{
// Show item
}
But this sux with 30> Items and 5 Bags...

how to solve this easyly?

Oh you need of course the code

pawn Код:
//======== Defines of the Account save Sys
enum pInfo
{
    pbag1,
    pbag2,
    pbag3,
    pbag4,
    pbag5,
};
new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Код:
//============ Defines of Bag IDS
#define ecard       000001
#define smedal   000002
#define gmedal   000003
#define mayorsig  000004
#define swatsig   000005
#define sdoc1    000006
#define sdoc2    000007
#define sdoc3    000008
#define sdoc4    000009
#define sdocfull  000010
pawn Код:
//========= Mybag should look like this
    if(strcmp(cmd, "/mybag", true) == 0)
    {
      SendClientMessage(playerid, YELLOW, "-----------------------------------------------");
      SendClientMessage(playerid, YELLOW, "      Your Bag");
      SendClientMessage(playerid, YELLOW, "-----------------------------------------------");
        // Show item in bag 1
        // Show item in bag 2
        // Show item in bag 3
        // Show item in bag 4
        // Show item in bag 5
      SendClientMessage(playerid, YELLOW, "-----------------------------------------------");
        return 1;
    }
Reply
#2

[Push] can anyone help me?
Reply
#3

Push again..

sorry but i need really help
Reply
#4

pawn Код:
//============ Defines of Bag IDS
#define MAX_ITEMS 10
#define BAGCOUNT 5
#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
pawn Код:
new Bags[MAX_PLAYERS][BAGCOUNT];
new ItemNames[MAX_ITEMS][32] =
{
{"Electronic Card"},
{"S Medal"},
{"G Medal"},
{"Mayor Sig"},
{"Swat Sig"},
{"S Document 1"},
{"S Document 2"},
{"S Document 3"},
{"S Document 4"},
{"S Full Document"}
};

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/mybag", true) == 0)
    {
        new bagitem[128];
        SendClientMessage(playerid, YELLOW, "-----------------------------------------------");
        SendClientMessage(playerid, YELLOW, "      Your Bag");
        SendClientMessage(playerid, YELLOW, "-----------------------------------------------");
        for (new i = 0; i < 5; i++)
        {
            if (Bags[playerid][i] == 0) format(bagitem, sizeof(bagitem), "Bag %d: empty", i);
            else
            {
                format(bagitem, sizeof(bagitem), "Bag %d: %s", i, ItemNames[Bags[playerid][i] - 1]);
                SendClientMessage(playerid, YELLOW, bagitem);
            }
        }
        SendClientMessage(playerid, YELLOW, "-----------------------------------------------");
        return 1;
    }
    return 0;
}
Untested!
Reply
#5

Quote:
Originally Posted by player007
pawn Код:
//============ Defines of Bag IDS
#define MAX_ITEMS 10
#define BAGCOUNT 5
#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
pawn Код:
new Bags[MAX_PLAYERS][BAGCOUNT];
new ItemNames[MAX_ITEMS][32] =
{
{"Electronic Card"},
{"S Medal"},
{"G Medal"},
{"Mayor Sig"},
{"Swat Sig"},
{"S Document 1"},
{"S Document 2"},
{"S Document 3"},
{"S Document 4"},
{"S Full Document"}
};

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/mybag", true) == 0)
    {
        new bagitem[128];
        SendClientMessage(playerid, YELLOW, "-----------------------------------------------");
        SendClientMessage(playerid, YELLOW, "      Your Bag");
        SendClientMessage(playerid, YELLOW, "-----------------------------------------------");
        for (new i = 0; i < 5; i++)
        {
            if (Bags[playerid][i] == 0) format(bagitem, sizeof(bagitem), "Bag %d: empty", i);
            else
            {
                format(bagitem, sizeof(bagitem), "Bag %d: %s", i, ItemNames[Bags[playerid][i] - 1]);
                SendClientMessage(playerid, YELLOW, bagitem);
            }
        }
        SendClientMessage(playerid, YELLOW, "-----------------------------------------------");
        return 1;
    }
    return 0;
}
Untested!
i didnt tested it yet.. but how to add items? o.o ( I mean how to give a player an item)
Reply
#6

You need to set the variable Bags, like if you want to add an 'ecard' to the second player's first bag, do
Bags[2][0] = ecard;
remember, counting starts from zero
Of course both the playerid, and the bag number should be dynamic.
Here's an example command that puts an 'Electronic Card' to your first bag:
pawn Код:
if(strcmp(cmdtext, "/fillbag1", true) == 0)
    {
        Bags[playerid][0] = ecard;
        new bagitem[128];
        format(bagitem, sizeof(bagitem), "You now have an %s in your first bag!", ItemNames(ecard - 1);
        SendClientMessage(playerid, YELLOW, bagitem);
        return 1;
    }
Reply
#7

I just realized there are 5 "unit spaces", I thought there are 5 different bags
In this case, use Seif's method!
Reply
#8

....
Reply
#9

[Push]
Reply
#10

....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)