SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 02/09/2011, 04:15 PM   #1
Phanto90
Huge Clucker
 
Phanto90's Avatar
 
Join Date: Mar 2011
Location: Milan, Italy
Posts: 352
Reputation: 31
Default PInventory

PInventory.inc 1.1
PInclude is a library that allows you to include in your gamemode an advanced inventory system.
• Players can hold a maxiumum of 10 different items in their inventory
• Texdraw's box change dinamically (based on the number of item in the inventory)
• 4 textdraw used for all players

Fuctions

• Create_Item(item_name[], max = 20)
Creates an item that can be added to a player’s inventory.
item_name: the item’s name that will be showed in the inventory. (You can use textdraw’s color to colorize item’s name)
max: Set the maximum amount of items of this type that a player can hold. If not specified it will be 20.
Returns: the id of the created item.

Examples:
Code:
new cigarettes_id = Create_Item(“Cigarettes”);
Code:
new lighter_id = Create_Item(“Lighter”, 1);
• Get_Max_Amount(item_id)
Returns: the maximum amount of items that a player can hold for the specified id.

• Set_Max_Amount(item_id)
Set the maximum amount of item that a player can hold for the specified id.

• Add_Item(playerid, item_id, amount = 1)
Add an item to a player’s inventory.
playerid: the id of the player.
item_id: the id of item to remove add.
amount: the amount of item to add. If not specified its value will be 1.
Returns:
- ERROR_INVALID_ITEM : the item’s id specified is not valid (or amount is less or equal to 0).
- SUCCESFULLY_ADDED_REMOVED : the item has been added successfully to player’s inventory.
- ERROR_FULL_INVENTORY : Cannot add item because the player’s inventory is full.
- ERROR_TOO_MANY_ITEMS : Player has overreached the item’s limit for this item_id. (items will not be added)

Examples:
Code:
new lighter_id = Create_Item("Lighter", 1); //Somewhere processed
Add_Item(playerid, lighter_id); //In a function with playerid defined
Code:
new cigarettes_id = Create_Item("Cigarettes"); //Somewhere processed
Add_Item(playerid, cigarettes_id, 10); //In a function with playerid defined
• Remove_Item(playerid, item_id, amount = 1)
Remove an item from a player’s inventory.
playerid: the id of the player.
item_id: the id of the item to remove.
amount: the number of item to remove.
Returns:
-ERROR_INVALID_ITEM : the item’s id specified is not valid (or amount is less or equal to 0).
-SUCCESFULLY_ADDED_REMOVED : the item has been removed successfully from player’s inventory.
-ERROR_NO_ITEM : player hasn’t that item in the inventory.
-ERROR_NOT_ENOUGH_ITEMS : player hasn’t that amount of items in the inventory.

Examples:
Code:
new lighter_id = Create_Item("Lighter", 1); //Somewhere processed
Remove_Item(playerid, lighter_id); //In a function with playerid defined
Code:
new cigarettes_id = Create_Item("Cigarettes"); //Somewhere processed
Remove_Item(playerid, cigarettes_id, 2); //In a function with playerid defined
• Check_Amount(playerid, item_id)
Returns the number of items (for the specified id) that a player have in his inventory.

Example:
Code:
new cigarettes_id = Create_Item(“Cigarettes”); //Somewhere processed
if(!Check_Amount(playerid, cigarettes_id)) return SendClientMessage(playerid, -1, "ERROR: You have no cigarettes!");
else
{
//Something, maybe set player special action to smoke and remove a cigarette with Remove_Item
}
• Show_Inventory(playerid)
Shows inventory to a player.

• Hide_Inventory(playerid)
Hide inventory for a player.
Note: It is automatically called when a player connects

• Reset_Inventory(playerid)
Reset inventory for a player.
Note: It is automatically called when a player connects.

• PInventory_DebugMode(bool:mode)
Handles the debug mode of PInventory.
true: activate debug mode
false: deactivate

General Considerations
Althought PInventory offers to you an advanced item management system, there is something to say:
  • The system is based on the enumeration of player's items just to be more efficient and not on a string comparison system.
  • It is still impossibile to fit every user save needs by releasing a universal and efficient item save-system. If your looking to save items for every player, you can use player vars and save each item in an array stored somewhere (database, .txt or .ini file or elsewhere)


Screens




Download
PInventory 1.1 (pastebin)
PInventory 1.1 (soldifiles)
//Sorry for my awful english :P
Attached Images
File Type: jpg sa-mp-086.jpg (198.6 KB, 1372 views)
File Type: jpg sa-mp-087.jpg (197.9 KB, 1296 views)
File Type: jpg sa-mp-088.jpg (197.7 KB, 1292 views)
File Type: jpg sa-mp-089.jpg (197.3 KB, 1288 views)
File Type: png PInventory.png (28.7 KB, 1169 views)
__________________


Latest Releases
FilterscriptsIncludesMaps
PRaceSystem v1.3 PBlock v1.1Electronic Shop
PVotekick v1.1PInventory v1.1
________________________
I don't script for money, stop asking for it.


Last edited by Phanto90; 10/12/2011 at 07:30 PM.
Phanto90 is offline   Reply With Quote
Old 02/09/2011, 04:16 PM   #2
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 4,122
Reputation: 928
Default Re: PInventory

Pastebin link doesn't work

Looks awesome, It saves right?
__________________

192.169.82.202:7777 - An awesome CnR server consisting of doozy features! Come, we have players!


Lorenc_ is offline   Reply With Quote
Old 02/09/2011, 04:18 PM   #3
AndreT
High-roller
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 1,027
Reputation: 402
Default Re: PInventory

Quote:
Originally Posted by Lorenc_ View Post
Pastebin link doesn't work

Looks awesome, It saves right?
You have to copy the link properly. It doesn't save.
AndreT is offline   Reply With Quote
Old 02/09/2011, 04:25 PM   #4
Phanto90
Huge Clucker
 
Phanto90's Avatar
 
Join Date: Mar 2011
Location: Milan, Italy
Posts: 352
Reputation: 31
Default Re: PInventory

Sorry, my fault. Check out now
__________________


Latest Releases
FilterscriptsIncludesMaps
PRaceSystem v1.3 PBlock v1.1Electronic Shop
PVotekick v1.1PInventory v1.1
________________________
I don't script for money, stop asking for it.

Phanto90 is offline   Reply With Quote
Old 02/09/2011, 04:31 PM   #5
Rapgangsta
Huge Clucker
 
Join Date: Sep 2009
Location: Italy
Posts: 229
Reputation: 25
Default Re: PInventory

[ita] Un sistema simile che salva i dati sarebbe perfetto si potrebbero creare sistemi come AddItem(playerid,adminlevel,1) ecct ovviamente non deve apparire il menu[ita]
Rapgangsta is offline   Reply With Quote
Old 02/09/2011, 04:34 PM   #6
Darnell
Gangsta
 
Darnell's Avatar
 
Join Date: Jul 2010
Posts: 870
Reputation: 34
Default Re: PInventory

Seems very nice, problem it doesnt save ;\.
Darnell is offline   Reply With Quote
Old 02/09/2011, 04:39 PM   #7
Phanto90
Huge Clucker
 
Phanto90's Avatar
 
Join Date: Mar 2011
Location: Milan, Italy
Posts: 352
Reputation: 31
Default Re: PInventory

Quote:
Originally Posted by Darnell View Post
Seems very nice, problem it doesnt save ;\.
It is technically impossible to make a script that would fit for every end-user needs.

If somebody wants to save the items, he can use :
Code:
player_inventory[playerid][slot][id_inventory_item] //id of the item in the slot
player_inventory[playerid][slot][p_amount] //the amount of item in the slot
It would be simply to implement in a registration system, i suppose.
__________________


Latest Releases
FilterscriptsIncludesMaps
PRaceSystem v1.3 PBlock v1.1Electronic Shop
PVotekick v1.1PInventory v1.1
________________________
I don't script for money, stop asking for it.

Phanto90 is offline   Reply With Quote
Old 02/09/2011, 05:41 PM   #8
elledioi90
Little Clucker
 
Join Date: Jul 2009
Posts: 15
Reputation: 0
Default Re: PInventory

Nice :P
elledioi90 is offline   Reply With Quote
Old 02/09/2011, 09:01 PM   #9
Naruto_Emilio
High-roller
 
Naruto_Emilio's Avatar
 
Join Date: Apr 2011
Location: I really don't know
Posts: 1,845
Reputation: 313
Default Re : PInventory

Good job i will go try it now.
__________________

Naruto_Emilio is offline   Reply With Quote
Old 02/09/2011, 11:28 PM   #10
=WoR=G4M3Ov3r
High-roller
 
Join Date: Nov 2010
Location: www.Ambrosia-Servers.com
Posts: 1,855
Reputation: 327
Default Re: PInventory

Nice job, i may use this.
=WoR=G4M3Ov3r is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 12:20 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.