inventoryselect

AnnieRuru

~~Cute~Cute~Scripter~~
Messages
1,677
Points
0
Location
your next door ~
Discord
AnnieRuru#1609
Github
AnnieRuru
Emulator
Client Version
2019-05-30aRagexeRE
Credit to Epoque for the idea

Download : 1.4
plugin

while reading the description,

*inventoryselect();
Opens a prompt window which display a configurable list of items which may be selected (as shown in the screenshots).
allow list all the items in your inventory, or only show part of it

with version 1.2 onwards, now can list out only certain types of items

for example inventoryselect(ITF_WEAPON|ITF_ARMOR) only shows equipments available in your inventory

and inventoryselect(ITF_CARD) only shows card available in your inventory

no, don't do stuffs like adding item temporary, player can find ways to dup item

tested with

function script F_display_inventoryselect {
mes @iselect_id +" -> "+ F_MesItemInfo(@iselect_id);
mes getitemname2(@iselect_id, @iselect_identify, @iselect_refine, @iselect_attribute, @iselect_card1, @iselect_card2, @iselect_card3, @iselect_card4);
for (.@i = 0; .@i < 5; ++.@i) {
.@opt_id[.@i] = getd("@iselect_opt_id"+(.@i +1));
.@opt_value[.@i] = getd("@iselect_opt_val"+(.@i +1));
.@opt_param[.@i] = getd("@iselect_opt_param"+(.@i +1));
}
mes F_ITEML(@iselect_id, @iselect_refine, @iselect_card1, @iselect_card2, @iselect_card3, @iselect_card4, .@opt_id, .@opt_value, .@opt_param);
dispbottom F_ITEML(@iselect_id, @iselect_refine, @iselect_card1, @iselect_card2, @iselect_card3, @iselect_card4, .@opt_id, .@opt_value, .@opt_param);
return;
}

prontera,150,185,5 script test_1 1_F_MARIA,{
mes "select an item";
next;
.@s = inventoryselect; // select all inventory items
if (.@s == -1) {
mes "Cancel";
close;
}
dispbottom .@s +""; // return inventory index
F_display_inventoryselect;
close;
}

prontera,153,185,5 script test_2 1_F_MARIA,{
mes "select an item";
next;
.@s = inventoryselect(ITF_WEAPON|ITF_ARMOR); // select only equipments available on player's inventory
if (.@s == -1) {
mes "Cancel";
close;
}
dispbottom .@s +""; // return inventory index
F_display_inventoryselect;
close;
}

prontera,156,185,5 script test_3 1_F_MARIA,{
mes "select an item";
next;
.@s = inventoryselect(ITF_ALL, .orbs); // select only orbs from .orbs array that available on player's inventory
if (.@s == -1) {
mes "Cancel";
close;
}
dispbottom .@s +""; // return inventory index
F_display_inventoryselect;
close;
OnInit:
query_sql "SELECT `id` FROM `item_db` WHERE `type` = 6 AND RIGHT(`name_japanese`, 4) != 'card'", .orbs;
end;
}

prontera,158,185,5 script djk2sfhsd 1_F_MARIA,{
getitem Spectacles, 1;
getitem2 1501, 1, 0,0,0, 0,0,0,0;
getitem2 1502, 1,1,0,0, 4001,4002,4003,4005;
equip 1502;
setequipoption EQI_HAND_R, 1, 1, 100;
equip 1502;
setequipoption EQI_HAND_R, 2, 2, 100;
equip 1502;
setequipoption EQI_HAND_R, 3, VAR_STRAMOUNT, 100;
close;
}

screen2019Hercules038.jpg


1.0 - plugin

1.0a
- fix struct player_data twice

1.1 - plugin
- fix server crash when using magnifier

1.2 - plugin

- add ITF_ type to only shows that item type in the inventory list menu

1.3 - plugin

- add ITF_ALL flag for 2nd argument expansion

- allow to use any array of your choice to only show items only allow on that array

1.4 - plugin

- fix sample 3 always throw "Target argument is not a variable!" by changing script_isstringtype into script_isstring

- add script->reportdata whenever necessary

 
Last edited by a moderator:
1.2 - plugin

- add ITF_ type to only shows that item type in the inventory list menu

 
ok 1 more try

1.3 - plugin

- add ITF_ALL flag for 2nd argument expansion

- allow to use any array of your choice to only show items only allow on that array

and of course this time I setup my own test server on google cloud with centos myself, hopefully in this future no more error like above shows up

 
1.4 - plugin

- fix sample 3 always throw "Target argument is not a variable!" by changing script_isstringtype into script_isstring

- add script->reportdata whenever necessary

 
is it possible also to modify
callshop .shop_npc_name$,2; to just show a specific type of item to be sold?
well yes, almost same concept here
this is rip from clif.c

Code:
/// Presents list of items, that can be sold to an NPC shop (ZC_PC_SELL_ITEMLIST).
/// 00c7 <packet len>.W { <index>.W <price>.L <overcharge price>.L }*
static void clif_selllist(struct map_session_data *sd)
{
	int c = 0, val;

	nullpo_retv(sd);

	int fd = sd->fd;
	WFIFOHEAD(fd, sd->status.inventorySize * 10 + 4);
	WFIFOW(fd,0)=0xc7;
	for (int i = 0; i < sd->status.inventorySize; i++)
	{
		if( sd->status.inventory[i].nameid > 0 && sd->inventory_data[i] )
		{
			if( !itemdb_cansell(&sd->status.inventory[i], pc_get_group_level(sd)) )
				continue;

			if (sd->status.inventory[i].favorite != 0)
				continue; // Cannot Sell Favorite item

			if( sd->status.inventory[i].expire_time )
				continue; // Cannot Sell Rental Items

			if( sd->status.inventory[i].bound && !pc_can_give_bound_items(sd))
				continue; // Don't allow sale of bound items

			val=sd->inventory_data[i]->value_sell;
			if( val < 0 )
				continue;
			WFIFOW(fd,4+c*10)=i+2;
			WFIFOL(fd,6+c*10)=val;
			WFIFOL(fd,10+c*10)=pc->modifysellvalue(sd,val);
			c++;
		}
	}
	WFIFOW(fd,2)=c*10+4;
	WFIFOSET(fd,WFIFOW(fd,2));
}
 
Back
Top