Inventory system - generic items
#1

Hey guys!

I was wondering how I could make an inventory system that supports generic items.
Example: command: /giveitem <playerid> <itemID> <value>.

Now, let's say ID 44 is the "generic" item, meaning it can be anything the value says.
Performing the command is easy, simply /giveitem playerid 44 License.
Safing it wouldn't be a problem either, seeing I can just say
INI_WriteString(file, "GenericItem", value);

But here comes the question, how can I safe multiple generic items? Let's say I have given Joe bloggs a license, but now I want to give him a badge. If I do /giveitem <playerid> 44 badge now it will overwrite the license.
So how can I create an invent. system with multiple non-overwritable but deletable string?
Reply
#2

Assuming you DO HAVE a PlayerInfo system,then add to your enum...
pawn Code:
enum
{
  iNumber//ITEM number
};
Then the command only looks like: /giveitem <playerid> <itemID>,but when the player receives the item,at the end of command:
pawn Code:
PlayerInfo[playerid][iNumber]++;//he now has one more item
Then you do:
pawn Code:
INI_WriteString(file, "GenericItem", PlayerInfo[playerid][iNumber]);
And now you don't have to mess up with memorizing numbers,etc.
Reply
#3

I'd suggest manually opening the file through fopen with io_append and writing to the end of the file.
Reply
#4

But then how do I delete 1 generic item? Seeing I will delete all of them if I clean PlayerInfo[playerid][iNumber]; with a command?.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)