SA-MP Forums Archive
Inventory system - generic items - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Inventory system - generic items (/showthread.php?tid=362129)



Inventory system - generic items - Devix - 23.07.2012

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?


Re: Inventory system - generic items - Cjgogo - 23.07.2012

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.


Re: Inventory system - generic items - Vince - 23.07.2012

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


Re: Inventory system - generic items - Devix - 23.07.2012

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?.