Jump to content
  • 0

R> Item Exchanger


ShiroNaito

Question


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  65
  • Reputation:   1
  • Joined:  04/04/19
  • Last Seen:  

Good day ? ..I would like to request an Item Exchanger that uses array script .. This is how it will work 

 

The NPC will only recognize 3 items (501 502 503)

when I click the NPC the recognize item will appear as menu ..

If I chose 501 the NPC will exchange it for item 601 , if I chose 502 the NPC will exchange it for item 602 ..so on 

 

thanks

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

prontera,155,181,4	script	Sample	4_F_KAFRA1,{
	.@i = select(.menu$) - 1;
	if (countitem(.required_item[.@i]) < .required_amount[.@i]) {
		mes "Exchange - Failed";
		mes "You dont have enough "+.required_amount[.@i]+"x "+getitemname(.required_item[.@i])+" to exchange into "+.reward_amount[.@i]+"x "+getitemname(.reward_item[.@i]);
	}
	else {
		delitem .required_item[.@i], .required_amount[.@i];
		getitem .reward_item[.@i], .reward_amount[.@i];
		mes "Exchange - Success";
		mes "Exchanged "+.required_amount[.@i]+"x "+getitemname(.required_item[.@i])+" to exchange into "+.reward_amount[.@i]+"x "+getitemname(.reward_item[.@i]);
	}
	close;
	
	function func_Exchange	{
		.required_item[.size] = getarg(0, 0);
		.required_amount[.size] = getarg(1, 0);
		.reward_item[.size] = getarg(2, 0);
		.reward_amount[.size] = getarg(3, 0);
		.menu$ = .menu$ + "> "+.required_amount[.size]+"x "+getitemname(.required_item[.size])+" to "+.reward_amount[.size]+"x "+getitemname(.reward_item[.size]) + ":";
		.size++;
		return;
	}
	
	OnInit:
		// func_Exchange(<required_item>, <required_amount>, <reward_item>, <reward_amount>);
		func_Exchange(501, 1, 601, 1);
		func_Exchange(502, 1, 602, 2);
		func_Exchange(503, 1, 603, 3);
		end;
}

you can try this.

or this (with refine requirements)

prontera,155,181,4	script	Sample	4_F_KAFRA1,{
	.@i = select(.menu$) - 1;
	if (countitem2(.required_item[.@i], 1, .required_refine[.@i], 0, 0, 0, 0,0) < .required_amount[.@i]) {
		mes "Exchange - Failed";
		mes "You dont have enough "+.required_amount[.@i]+"x "+(.required_refine[.@i]?"+"+.required_refine[.@i]:"")+" "+getitemname(.required_item[.@i])+" to exchange into "+.reward_amount[.@i]+"x "+getitemname(.reward_item[.@i]);
	}
	else {
		delitem2(.required_item[.@i], .required_amount[.@i], 1, .required_refine[.@i], 0, 0, 0, 0, 0);
		getitem .reward_item[.@i], .reward_amount[.@i];
		mes "Exchange - Success";
		mes "Exchanged "+.required_amount[.@i]+"x "+getitemname(.required_item[.@i])+" to exchange into "+.reward_amount[.@i]+"x "+getitemname(.reward_item[.@i]);
	}
	close;
	
	function func_Exchange	{
		.required_refine[.size] = getarg(0, 0);
		.required_item[.size] = getarg(1, 0);
		.required_amount[.size] = getarg(2, 0);
		.reward_item[.size] = getarg(3, 0);
		.reward_amount[.size] = getarg(4, 0);
		.menu$ = .menu$ + "> "+.required_amount[.size]+"x "+(.required_refine[.size]?"+"+.required_refine[.size]:"")+" "+getitemname(.required_item[.size])+" to "+.reward_amount[.size]+"x "+getitemname(.reward_item[.size]) + ":";
		.size++;
		return;
	}
	
	OnInit:
		// func_Exchange(<required_refine>, <required_item>, <required_amount>, <reward_item>, <reward_amount>);
		func_Exchange(1, 5001, 1, 601, 1);
		func_Exchange(2, 5001, 1, 602, 2);
		func_Exchange(3, 5001, 1, 603, 3);
		end;
}

 

On 8/14/2019 at 10:12 PM, dev LOOLP said:

i can't test now, but try this..

exchanger.txt 1.25 kB · 3 downloads


Redone and functional!
:) Good use.

exchanger.txt 1.27 kB · 6 downloads

this aren't suitable, using npc-scope variable in such fashion will just end up possible hack-attempts.

Link to comment
Share on other sites

  • 1

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  90
  • Reputation:   34
  • Joined:  10/01/18
  • Last Seen:  

2 hours ago, ShiroNaito said:

Good day ? ..I would like to request an Item Exchanger that uses array script .. This is how it will work 

 

The NPC will only recognize 3 items (501 502 503)

when I click the NPC the recognize item will appear as menu ..

If I chose 501 the NPC will exchange it for item 601 , if I chose 502 the NPC will exchange it for item 602 ..so on 

 

thanks

Please give this a try, i hope this is what you're looking for.
 

prontera.gat, 155, 185, 4	script	Exchanger Board	4_BOARD3,{
	.@menu = select( 
		(countitem(501)?"- Exchange with "+getitemname(501)+"":""),
		(countitem(502)?"- Exchange with "+getitemname(502)+"":""),
		(countitem(503)?"- Exchange with "+getitemname(503)+"":""),
		"- Nothing"
		);
	switch(.@menu) {
	case 1:
		getitem 607,1;
		break;
	case 2:
		getitem 608,1;
		break;
	case 3:
		getitem 616,1;
		break;
	default:
		mes "[ Exchanger ]";
		mes "There's nothing i can do for you.";
		mes " ";
		mes "Please come back to me later!";
		break;
	}
	end;
}

 

Link to comment
Share on other sites

  • 1

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.01
  • Content Count:  233
  • Reputation:   49
  • Joined:  12/20/18
  • Last Seen:  

i can't test now, but try this..

exchanger.txt

Redone and functional!
:) Good use.

exchanger.txt

yes, but it's more complicated .. some tests are needed to avoid bug's .. 
and I don't have time to test all possible situations ..
I hope someone will use my code as a base and apply what you want, but it is not difficult .. 


 
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  65
  • Reputation:   1
  • Joined:  04/04/19
  • Last Seen:  

12 minutes ago, Royr said:

Please give this a try, i hope this is what you're looking for.
 


prontera.gat, 155, 185, 4	script	Exchanger Board	4_BOARD3,{
	.@menu = select( 
		(countitem(501)?"- Exchange with "+getitemname(501)+"":""),
		(countitem(502)?"- Exchange with "+getitemname(502)+"":""),
		(countitem(503)?"- Exchange with "+getitemname(503)+"":""),
		"- Nothing"
		);
	switch(.@menu) {
	case 1:
		getitem 607,1;
		break;
	case 2:
		getitem 608,1;
		break;
	case 3:
		getitem 616,1;
		break;
	default:
		mes "[ Exchanger ]";
		mes "There's nothing i can do for you.";
		mes " ";
		mes "Please come back to me later!";
		break;
	}
	end;
}

 

Hi thankyou for your fast response sir ...is it not possible to make it like this

 

setarray .@item, 501,502,503;

setarray .@exchange, 601,602,603;

 

If i pick item 501 it will automatically exchange to 601 so on so on ....

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  65
  • Reputation:   1
  • Joined:  04/04/19
  • Last Seen:  

1 hour ago, dev LOOLP said:

Redone and functional!

:) Good use.

exchanger.txt 1.27 kB · 2 downloads

Hi sir thankyou for patiently helping me ..didnt tried it yet but I appreciate your effort ..can I ask if is it possible to check the refine of item 501 and transter it on item 601 ... Example I have Jur +10 and I want to transfer it on Spec Jur to make it +10 upon exchanging? Thankyou sir !!!!!! ❤️

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