How to show the bag? -
mirkoiz - 31.08.2009
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;
}
Re: Another Problem: How to show the bag? -
mirkoiz - 31.08.2009
[Push] can anyone help me?
Re: How to show the bag? -
mirkoiz - 31.08.2009
Push again..
sorry but i need really help
Re: How to show the bag? -
Clavius - 31.08.2009
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!
Re: How to show the bag? -
mirkoiz - 31.08.2009
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)
Re: How to show the bag? -
Clavius - 31.08.2009
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;
}
Re: How to show the bag? -
Clavius - 31.08.2009
I just realized there are 5 "unit spaces", I thought there are 5 different bags
In this case, use Seif's method!
Re: How to show the bag? -
coole210 - 31.08.2009
....
Re: How to show the bag? -
mirkoiz - 01.09.2009
[Push]
Re: How to show the bag? -
coole210 - 01.09.2009
....