SA-MP Forums Archive
[FilterScript] Simple Inventory System - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Simple Inventory System (/showthread.php?tid=611868)

Pages: 1 2


Simple Inventory System - Ivan_Ino - 11.07.2016

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


Re: Simple Inventory System - SickAttack - 11.07.2016

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!


Re: Simple Inventory System - Ivan_Ino - 11.07.2016

I try made ArrayList like in java for example, Thanks


Re: Simple Inventory System - Markdrifter18 - 11.07.2016

Hmm, looks good. Keep updating it


Re: Simple Inventory System - feheristi97 - 11.07.2016

Thank you for uploading this useful script!


Re: Simple Inventory System - bybaran - 13.07.2016

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


Re: Simple Inventory System - Ivan_Ino - 13.07.2016

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



Re: Simple Inventory System - Hunud - 13.07.2016

Onako solidno! Nice


Re: Simple Inventory System - bybaran - 13.07.2016

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?


Re: Simple Inventory System - Max_Andolini - 13.07.2016

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


Re: Simple Inventory System - Ivan_Ino - 13.07.2016

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


Re: Simple Inventory System - Crayder - 13.07.2016

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.


Re: Simple Inventory System - bybaran - 13.07.2016

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;
}



Re: Simple Inventory System - Ivan_Ino - 13.07.2016

Nice, did you test it? it works?


Re: Simple Inventory System - feheristi97 - 14.07.2016

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


Re: Simple Inventory System - Ivan_Ino - 14.07.2016

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


Re: Simple Inventory System - bybaran - 14.07.2016

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


Re: Simple Inventory System - Ivan_Ino - 14.07.2016

Nice, also add like if item amount is 0 RemoveItemFromInventory


Re: Simple Inventory System - bybaran - 15.07.2016

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


Re: Simple Inventory System - Ivan_Ino - 15.07.2016

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