ShiroNaito Posted August 14, 2019 Posted August 14, 2019 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 Quote
0 Emistry Posted September 3, 2019 Posted September 3, 2019 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. Quote
1 Royr Posted August 14, 2019 Posted August 14, 2019 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; } Quote
1 LOOLP - OFF Posted August 14, 2019 Posted August 14, 2019 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 .. 1 Quote
0 ShiroNaito Posted August 14, 2019 Author Posted August 14, 2019 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 .... Quote
0 ShiroNaito Posted August 15, 2019 Author Posted August 15, 2019 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 !!!!!! Quote
Question
ShiroNaito
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
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.