25.10.2011, 16:35
Hi guys.
Im currently working on my inventory system.
It has to work like this: Every player has a bag with 5 slots (Max 5 items)
Every slot has a variable (PlayerInfo[playerid][pBagSlot1], PlayerInfo[playerid][pBagSlot2], PlayerInfo[playerid][pBagSlot3], PlayerInfo[playerid][pBagSlot4] and PlayerInfo[playerid][pBagSlot5]).
When an item is added to the bag, the item will be in slot 1. If slot 1 is occupied, the item will come in slot 2 and so on.
I made this function:
Example:
AddItemToBag(playerid, 2);
If itemid 2 is a cheque, then the player will reveive a cheque in his bag.
This function doesn't work. Hope you can help me. Thanks.
Im currently working on my inventory system.
It has to work like this: Every player has a bag with 5 slots (Max 5 items)
Every slot has a variable (PlayerInfo[playerid][pBagSlot1], PlayerInfo[playerid][pBagSlot2], PlayerInfo[playerid][pBagSlot3], PlayerInfo[playerid][pBagSlot4] and PlayerInfo[playerid][pBagSlot5]).
When an item is added to the bag, the item will be in slot 1. If slot 1 is occupied, the item will come in slot 2 and so on.
I made this function:
pawn Код:
forward AddItemToBag(playerid, itemid);
public AddItemToBag(playerid, itemid)
{
if(PlayerInfo[playerid][pBagSlot1] = 0) PlayerInfo[playerid][pBagSlot1] = itemid;
else if(PlayerInfo[playerid][pBagSlot2] = 0) PlayerInfo[playerid][pBagSlot2] = itemid;
else if(PlayerInfo[playerid][pBagSlot3] = 0) PlayerInfo[playerid][pBagSlot3] = itemid;
else if(PlayerInfo[playerid][pBagSlot4] = 0) PlayerInfo[playerid][pBagSlot4] = itemid;
else if(PlayerInfo[playerid][pBagSlot5] = 0) PlayerInfo[playerid][pBagSlot5] = itemid;
else return SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) Your Bag is full");
return 1;
}
AddItemToBag(playerid, 2);
If itemid 2 is a cheque, then the player will reveive a cheque in his bag.
This function doesn't work. Hope you can help me. Thanks.