02.09.2011, 16:15
(
Последний раз редактировалось Phanto90; 10.12.2011 в 18:30.
)
PInventory.inc 1.1
PInclude is a library that allows you to include in your gamemode an advanced inventory system.
• 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:
• 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:
• 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:
• Check_Amount(playerid, item_id)
Returns the number of items (for the specified id) that a player have in his inventory.
Example:
• 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:
Screens
Download
PInventory 1.1 (pastebin)
PInventory 1.1 (soldifiles)
//Sorry for my awful english :P
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 inventoryFuctions
• Texdraw's box change dinamically (based on the number of item in the inventory)
• 4 textdraw used for all players
• 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:
Код:
new cigarettes_id = Create_Item(“Cigarettes”);
Код:
new lighter_id = Create_Item(“Lighter”, 1);
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:
Код:
new lighter_id = Create_Item("Lighter", 1); //Somewhere processed Add_Item(playerid, lighter_id); //In a function with playerid defined
Код:
new cigarettes_id = Create_Item("Cigarettes"); //Somewhere processed Add_Item(playerid, cigarettes_id, 10); //In a function with playerid defined
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:
Код:
new lighter_id = Create_Item("Lighter", 1); //Somewhere processed Remove_Item(playerid, lighter_id); //In a function with playerid defined
Код:
new cigarettes_id = Create_Item("Cigarettes"); //Somewhere processed Remove_Item(playerid, cigarettes_id, 2); //In a function with playerid defined
Returns the number of items (for the specified id) that a player have in his inventory.
Example:
Код:
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 }
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
PInventory 1.1 (pastebin)
PInventory 1.1 (soldifiles)
//Sorry for my awful english :P