Jump to content
  • 0
Helena

Trade headgear for another headgear but keep the refine rate?

Question

Hi community. I'm wondering if someone can help me out in the simplest way possible. :3

 

Say I want to trade a beret that I'm carrying for a coronet but I want to keep the refine rate. How would that work with delitem2 and getitem2? I've tried looking at other scripts and the wiki samples but I can't figure it out. 

 

This is how far I got. It doesn't work, it gives the Coronet fine but sadly not with the Berets refine rate:

 

 

    getinventorylist;
    set @refineitemid, getequipid(5172); // save id of the item
    set @refinerycnt, getequiprefinerycnt(5172); //save refinery count
    next;
    
    mes "[Headgear Trader]";
    mes "Are you sure you want to trade your Beret for a Coronet?";
    menu "Yes!",-,"No, I would like a different sprite!",L_Menu2;
    delitem 5172,1;
    getitem2 2249,1,1,@refinerycnt,0,0,0,0,0;
    mes "The deal has been a success! Enjoy your new Headgear~";
    close;

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Much better if you use getitem2 :P

new_1-1,56,126,0    script    Test    4W_SAILOR,{
    if ( !countitem( 5172 ) ) close;
    getinventorylist;
    mes "Pick the refine rate of " + getitemname( 5172 ) + " that you want to trade...";
    next;
    for ( .@i = 0; .@i < @inventorylist_count; .@i++ ) {
        if ( @inventorylist_id[ .@i ] == 5172 )
            .@refine$[ getarraysize( .@refine$ ) ] = @inventorylist_refine[ .@i ];
    }
    .@s = select( implode( .@refine$, ":" ) ) - 1;
    mes "Are you sure you want to trade +" + .@refine$[ .@s ] + " " + getitemname( 5172 ) + " to +" + .@refine$[ .@s ] + " " + getitemname( 2249 ) + "?";
    next;
    if ( select( "Yes:No" ) - 1 ) close;
    delitem2 5172,1,1,.@refine$[ .@s ],0,0,0,0,0;
    getitem2 2249,1,1,.@refine$[ .@s ],0,0,0,0,0;
    close;
}
 

Share this post


Link to post
Share on other sites
  • 0

Thank you so much Patskie! Do you perhaps know how i can make it so instead of it just displaying the refine amounts in the menu, to display the whole item name? Like "+7 Beret, +0 Beret"?

 

and it also gives this error. It works but this displays regardless:

 

[Warning]: Unexpected type for argument 4. Expected number.
[Debug]: Data: variable name='.@refine$' index=0
[Debug]: Function: getitem2
Edited by Helena

Share this post


Link to post
Share on other sites
  • 0

(Don't know why I can't quote @Patskie post)

The Script posted by patskie have some bug,

Patskie isn't storing Cards and other fields of item, which may led to delitem2 not successfully complete, and as a result, the item with cards won't be traded no matter how much ever you try to trade

Share this post


Link to post
Share on other sites
  • 0

I guess you need to change .@refine$ into .@refine to get rid off of the error

 

Thanks for the reply. Thought that did the trick, but it didn't. Gives this error now. :(

 

[Error]: script:implode: not string array
[Debug]: Data: variable name='.@refine' index=0

 

(Don't know why I can't quote @Patskie post)

The Script posted by patskie have some bug,

Patskie isn't storing Cards and other fields of item, which may led to delitem2 not successfully complete, and as a result, the item with cards won't be traded no matter how much ever you try to trade

 

This is ok. I only need it for non-slotted/carded items. So unless that's not the only issue, this is fine I guess. :)

 

Now only to do the display in a cleaner way. Does anyone know how I can achieve a list with item names instead of the refine rates only in the menu? 

Edited by Helena

Share this post


Link to post
Share on other sites
  • 0

 

I guess you need to change .@refine$ into .@refine to get rid off of the error

 

Thanks for the reply. Thought that did the trick, but it didn't. Gives this error now. :(

 

[Error]: script:implode: not string array
[Debug]: Data: variable name='.@refine' index=0

 

>(Don't know why I can't quote @Patskie post)

The Script posted by patskie have some bug,

Patskie isn't storing Cards and other fields of item, which may led to delitem2 not successfully complete, and as a result, the item with cards won't be traded no matter how much ever you try to trade

 

This is ok. I only need it for non-slotted/carded items. So unless that's not the only issue, this is fine I guess. :)

 

Now only to do the display in a cleaner way. Does anyone know how I can achieve a list with item names instead of the refine rates only in the menu? 

 

new_1-1,56,126,0	script	Test	4W_SAILOR,{
	if (!countitem(5172)) {
		mes "You don't have any "+ getitemname(5172);
		close;
	}
	getinventorylist;
	mes "Pick the refine rate of "+ getitemname(5172) +" that you want to trade...";
	next;
	.@menu$ = "";
	for (.@i = 0; .@i < @inventorylist_count; ++.@i) {
		if (@inventorylist_id[.@i] == 5172 && @inventorylist_identify[.@i] == 1) {	// We Need Identified Item
			.@card = 0;
			if (@inventorylist_card1[.@i])
				.@card++;
			if (@inventorylist_card2[.@i])
				.@card++;
			if (@inventorylist_card3[.@i])
				.@card++;
			if (@inventorylist_card4[.@i])
				.@card++;
			// ~ +7 ItemName (x4 Cards)
			.@menu$ = .@menu$ +"~ +"+ @inventorylist_refine[.@i] +" "+ getitemname(@inventorylist_id[.@i])+ " (x"+ .@card +" Cards):";
			.@index[getarraysize(.@index)] = .@i;
		}
	}
	.@menu$ = .@menu$ +"Cancel";
	.@s = select(.@menu$)-1;
	if (.@s == getarraysize(.@index))
		close;
	.@i = .@index[.@s];
	mes "Are you sure you want to trade +"+ @inventorylist_refine[.@i] +" "+ getitemname(@inventorylist_id[.@i]) +" to +"+ @inventorylist_refine[.@i] +" "+ getitemname(2249) +"?";
	next;
	if (select("Yes:No") == 2)
		close;
	delitem2 @inventorylist_id[.@i], 1, 1, @inventorylist_refine[.@i], @inventorylist_attribute[.@i], @inventorylist_card1[.@i], @inventorylist_card2[.@i], @inventorylist_card3[.@i], @inventorylist_card4[.@i];
	getitem2 2249,1,1,@inventorylist_refine[.@i],0,0,0,0,0;
	close;
}

Share this post


Link to post
Share on other sites
  • 0

Thank youuu!

 

 

 


I guess you need to change .@refine$ into .@refine to get rid off of the error

 

Thanks for the reply. Thought that did the trick, but it didn't. Gives this error now. :(

 

[Error]: script:implode: not string array
[Debug]: Data: variable name='.@refine' index=0

 

r />/>

>(Don't know why I can't quote @Patskie post)

The Script posted by patskie have some bug,

Patskie isn't storing Cards and other fields of item, which may led to delitem2 not successfully complete, and as a result, the item with cards won't be traded no matter how much ever you try to

tradelockquote>

 

This is ok. I only need it for non-slotted/carded items. So unless that's not the only issue, this is fine I guess. :)

 

Now only to do the display in a cleaner way. Does anyone know how I can achieve a list with item names instead of the refine rates only in the menu? 

blockquote>
new_1-1,56,126,0	script	Test	4W_SAILOR,{
	if (!countitem(5172)) {
		mes "You don't have any "+ getitemname(5172);
		close;
	}
	getinventorylist;
	mes "Pick the refine rate of "+ getitemname(5172) +" that you want to trade...";
	next;
	.@menu$ = "";
	for (.@i = 0; .@i < @inventorylist_count; ++.@i) {
		if (@inventorylist_id[.@i] == 5172 && @inventorylist_identify[.@i] == 1) {	// We Need Identified Item
			.@card = 0;
			if (@inventorylist_card1[.@i])
				.@card++;
			if (@inventorylist_card2[.@i])
				.@card++;
			if (@inventorylist_card3[.@i])
				.@card++;
			if (@inventorylist_card4[.@i])
				.@card++;
			// ~ +7 ItemName (x4 Cards)
			.@menu$ = .@menu$ +"~ +"+ @inventorylist_refine[.@i] +" "+ getitemname(@inventorylist_id[.@i])+ " (x"+ .@card +" Cards):";
			.@index[getarraysize(.@index)] = .@i;
		}
	}
	.@menu$ = .@menu$ +"Cancel";
	.@s = select(.@menu$)-1;
	if (.@s == getarraysize(.@index))
		close;
	.@i = .@index[.@s];
	mes "Are you sure you want to trade +"+ @inventorylist_refine[.@i] +" "+ getitemname(@inventorylist_id[.@i]) +" to +"+ @inventorylist_refine[.@i] +" "+ getitemname(2249) +"?";
	next;
	if (select("Yes:No") == 2)
		close;
	delitem2 @inventorylist_id[.@i], 1, 1, @inventorylist_refine[.@i], @inventorylist_attribute[.@i], @inventorylist_card1[.@i], @inventorylist_card2[.@i], @inventorylist_card3[.@i], @inventorylist_card4[.@i];
	getitem2 2249,1,1,@inventorylist_refine[.@i],0,0,0,0,0;
	close;
}
Edited by Helena

Share this post


Link to post
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.   Restore formatting

  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.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.