[FilterScript] Simple Inventory System
#1

Hello, I made simple inventory system with ArrayList include

This is just example small Inventory Script

If you for example have 10 items in inventory and remove item on slot 5 all the above item will be ordered


For this you need:

-- Commands --
sscanf2
zcmd

-- Another --
ArrayList - https://sampforum.blast.hk/showthread.php?tid=608635







Download: https://github.com/Ino42O/PawnArrayL...oryExample.pwn
Reply
#2

ArrayList doesn't look user friendly (some people won't be able to understand how to use it). Nonetheless, it can be done without it (same or faster, depending on the way it's done).

Good job and keep it up!
Reply
#3

I try made ArrayList like in java for example, Thanks
Reply
#4

Hmm, looks good. Keep updating it
Reply
#5

Thank you for uploading this useful script!
Reply
#6

How to get if player clicked valid item? For example; If an player clicked Medkit item, i would like give some health.
Reply
#7

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if (dialogid == INVENTORY_DIALOG)
	{
		if (response)
		{
			RemoveItemFromInventory(playerid, listitem + 1);
		}
	}
	return 1;
}
Reply
#8

Onako solidno! Nice
Reply
#9

Nice job bro thanks! But can u tell me this? I want to if players click Medkit item, give some health. How can i make this?
Reply
#10

Quote:
Originally Posted by bybaran
Посмотреть сообщение
Nice job bro thanks! But can u tell me this? I want to if players click Medkit item, give some health. How can i make this?
This is java
Reply
#11

This is just an example inventory system, not items aswell, ill make function UseItem(playerid, item) then reupload fs
Reply
#12

UseItem? I don't think you should add that. We should do our code in DialogResponse.

Perhaps you could make a dialog wrapper for items, but other than that it's fine.
Reply
#13

I did a simple UseItem function

Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if (dialogid == INVENTORY_DIALOG)
	{
	new item_name[50], get_id = -1;
		if (response)
			{
        	get_id = ArrayList::Get(InventoryList[playerid], PlayerInventory[playerid][i_item_type][listitem] - 1);
        	
		if(get_id + 1 == 1) return GivePlayerWeapon(playerid, 24, 100), SendClientMessage(playerid, -1, "You succesfully takes your weapon!"),PlayerInventory[playerid][i_item_amount][listitem] -= 1;
		if(get_id + 1 == 2) return SetPlayerHealth(playerid, 100.0), SendClientMessage(playerid, -1, "You succesfully sets your health full!"),PlayerInventory[playerid][i_item_amount][listitem] -= 1;
		if(get_id + 1 == 3) return ApplyAnimation(playerid, "FOOD", "EAT_Burger", 4.1, 0, 1, 1, 0, 0, 1), SendClientMessage(playerid, -1, "You succesfully eats your burger!"),PlayerInventory[playerid][i_item_amount][listitem] -= 1;
		get_id = -1;
			}
	}
	return 1;
}
Reply
#14

Nice, did you test it? it works?
Reply
#15

You should add a CreateItemInventory(itemobject, x, y, z, ammout).. good to create it under ongamemodeinit
Reply
#16

Sure if i update all this fs to items / inventory system, right now is just inventory xD
Reply
#17

Quote:
Originally Posted by Ivan_Ino
View Post
Nice, did you test it? it works?
Yes, it works. I captured an test video for you.

https://www.youtube.com/watch?v=-Tqv14wt38Y
Reply
#18

Nice, also add like if item amount is 0 RemoveItemFromInventory
Reply
#19

When I save and read inventory data in MYSQL, My UseItem function is bugged.
Reply
#20

Make new table just for inventory
Then on read just do AddItemInInventory
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)