Jump to content
  • 0

Setting Multiple Items


Radian

Question


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

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.?

Link to comment
Share on other sites

6 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

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;
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

 

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 :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

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;
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

 

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

 

 

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.

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

 

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
Link to comment
Share on other sites

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.

×
×
  • Create New...