Jump to content
  • 0

Setting Multiple Items


Question

Posted

How can i set multiple items with multiple choices?

 

for example. If player have item 501 or 502 or 503 then he can choose what he/she wants to trade with it.?

6 answers to this question

Recommended Posts

Posted

Perhaps a little more information is needed?

 

But maybe something along these lines or?

getinventorylist;
.@len = @inventorylist_count;
copyarray .@inv_list[0], @inventorylist_id[0], .@len;
setarray .@items, 501, 502, 503;
setarray .@exchange, 504, 506, 507;
.@l_2 = getarraysize(.@items);
.@l_3 = getarraysize(.@exchange);
for( .@a = 0; .@a < .@len; .@a++ ) {
	for( .@b = 0; .@b < .@l_2; .@b++ )
		if( .@inv_list[.@a] == .@items[.@b] )
			.@selection$ = .@selection$ + getitemname(.@inv_list[.@a]) + ":";
	.@selection$ = .@selection$ + ":";
}

mes "Pick from the items you'd like to exchange.";
.@menu = select(.@selection$)-1;

mes "You've selected "+getitemname(.@inv_list[.@menu])+". What would you like to exchange it with?";

for( .@a = 0; .@a < .@l_3; .@a++ )
	.@s_2$[getarraysize(.@s_2$)] = getitemname(.@exchange[.@a]);
	
.@s_3$ = implode( .@s_2$, ":" );

.@menu2 = select(.@s_3$)-1;

delitem .@inv_list[.@menu], 1;
getitem .@exchange[.@menu2], 1;
Posted

 

Perhaps a little more information is needed?

 

But maybe something along these lines or?

getinventorylist;
.@len = @inventorylist_count;
copyarray .@inv_list[0], @inventorylist_id[0], .@len;
setarray .@items, 501, 502, 503;
setarray .@exchange, 504, 506, 507;
.@l_2 = getarraysize(.@items);
.@l_3 = getarraysize(.@exchange);
for( .@a = 0; .@a < .@len; .@a++ ) {
	for( .@b = 0; .@b < .@l_2; .@b++ )
		if( .@inv_list[.@a] == .@items[.@b] )
			.@selection$ = .@selection$ + getitemname(.@inv_list[.@a]) + ":";
	.@selection$ = .@selection$ + ":";
}

mes "Pick from the items you'd like to exchange.";
.@menu = select(.@selection$)-1;

mes "You've selected "+getitemname(.@inv_list[.@menu])+". What would you like to exchange it with?";

for( .@a = 0; .@a < .@l_3; .@a++ )
	.@s_2$[getarraysize(.@s_2$)] = getitemname(.@exchange[.@a]);
	
.@s_3$ = implode( .@s_2$, ":" );

.@menu2 = select(.@s_3$)-1;

delitem .@inv_list[.@menu], 1;
getitem .@exchange[.@menu2], 1;

 

thanks it works :)

Posted

How can i fix this one?

 

 

[Error]: buildin_delitem: unknown item "0".
[Debug]: Source (NPC): Augustus at mellina (95,51)

 

I set the item and exchange into this

	setarray .@items, 20286, 20287, 20288, 20289, 20290, 20291, 20292;
	setarray .@exchange, 20286, 20287, 20288, 20289, 20290, 20291, 20292;
Posted

 

How can i fix this one?

 

 

[Error]: buildin_delitem: unknown item "0".

[Debug]: Source (NPC): Augustus at mellina (95,51)

 

I set the item and exchange into this

	setarray .@items, 20286, 20287, 20288, 20289, 20290, 20291, 20292;
	setarray .@exchange, 20286, 20287, 20288, 20289, 20290, 20291, 20292;

 

Just make sure all your items exist in your database to check use @item <item_id> if it doesn't work then they will cause that error.

Posted

 

 

How can i fix this one?

 

 

[Error]: buildin_delitem: unknown item "0".

[Debug]: Source (NPC): Augustus at mellina (95,51)

 

I set the item and exchange into this

	setarray .@items, 20286, 20287, 20288, 20289, 20290, 20291, 20292;
	setarray .@exchange, 20286, 20287, 20288, 20289, 20290, 20291, 20292;

 

Just make sure all your items exist in your database to check use @item <item_id> if it doesn't work then they will cause that error.

 

 

Yea i've check it its working but sometimes the errors shows out.

Posted

 

Yea i've check it its working but sometimes the errors shows out.

 

 

I was thinking about it and someone might be exploiting the npc by dropping or storing the items in the middle of the transaction...

 

Try this instead.

prontera,101,101,5	script	exchange_test	100,{
	getinventorylist;
	.@len = @inventorylist_count;
	copyarray .@inv_list[0], @inventorylist_id[0], .@len;
	setarray .@items, 501, 502, 503;
	setarray .@exchange, 504, 506, 507;
	.@l_2 = getarraysize(.@items);
	.@l_3 = getarraysize(.@exchange);
	for( .@a = 0; .@a < .@len; .@a++ ) {
		for( .@b = 0; .@b < .@l_2; .@b++ )
			if( .@inv_list[.@a] == .@items[.@b] )
				.@selection$ = .@selection$ + getitemname(.@inv_list[.@a]) + ":";
		.@selection$ = .@selection$ + ":";
	}

	mes "Pick from the items you'd like to exchange.";
	.@menu = select(.@selection$)-1;

	mes "You've selected "+getitemname(.@inv_list[.@menu])+". What would you like to exchange it with?";

	for( .@a = 0; .@a < .@l_3; .@a++ )
		.@s_2$[getarraysize(.@s_2$)] = getitemname(.@exchange[.@a]);
		
	.@s_3$ = implode( .@s_2$, ":" );

	.@menu2 = select(.@s_3$)-1;

	if( countitem(.@inv_list[.@menu]) >= 1 ) {
		delitem .@inv_list[.@menu], 1;
		getitem .@exchange[.@menu2], 1;
	} else
		mes "Something went wrong.";
	close;
}
  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...