I was curious is someone could help me with this script.
This is how it works, the items in "setarray .@exc_1" can be traded/exchanged for the items in "setarray .@exc_2".
Problem: The script works fine if a item of "setarray .@exc_1" is present in the characters inventory, but if it isn't and someone uses the NPC, the script will bug out at the menu. As in, no "close" button will appear. (The "Cancel" doesn't actually cancel, it sends you to the next menu regardless if a item in the list is present)
I've tried several ways to fix it, but it is more difficult than I thought.
quiz_test,95,84,4 script Item Trader 797,{
setarray .@exc_1,8005,8006,8015,8016; // <- Checks in inventory for these items.
setarray .@exc_2,8005,8006,8015,8016; // <- Available items for exchange. Pretty much a copy/paste of the IDs above^
set .@n$,"[Item Trader]";
mes .@n$;
mes "Hello! I can exchange headgears, that means if you're bored of your current headgear, I can easily give you another!";
next;
mes .@n$;
mes "This is not a free service though. I require the following:";
mes "1x Headgear";
mes "3x Cash Point";
next;
mes .@n$;
mes "If you want me to do the exchange process for you, please select the Headgear you wish to exchange:";
while (.@e!=2) {
set .@e,(!.@e)?"1":"2";
if (.@e==2) { next; mes .@n$; mes "Please pick your new desired Headgear:";
mes " ";
mes "^FF0000(To see a list of existing sprites please check our servers database, accessable through the forums!)"; }
for (set .@i,0; .@i<getarraysize(getd(".@exc_"+.@e)); set .@i,.@i+1) setd ".@m"+.@e+"$",getd(".@m"+.@e+"$")+""+(((.@e==2||(.@e==1&&countitem(.@exc_1[.@i]))))?getitemname(getd(".@exc_"+.@e+"["+.@i+"]")):"")+":";
setd ".@m"+.@e,select(getd(".@m"+.@e+"$")+":Cancel")-1;
if (getd(".@m"+.@e)==getarraysize(getd(".@exc_"+.@e))) close;
}
next;
mes .@n$;
mes "Are you sure you want to exchange this item?";
menu "Yes, proceed.",-;
mes "Granted, have fun!";
delitem .@exc_1[.@m1],1;
getitem .@exc_2[.@m2],1;
set #CASHPOINTS,#CASHPOINTS - 3;
dispbottom "3 Cash Points have been deducted. Current Balance = "+#CASHPOINTS+" Cash Points.";
close;
}
}
Question
Mistique
Hello everyone!
I was curious is someone could help me with this script.
This is how it works, the items in "setarray .@exc_1" can be traded/exchanged for the items in "setarray .@exc_2".
Problem: The script works fine if a item of "setarray .@exc_1" is present in the characters inventory, but if it isn't and someone uses the NPC, the script will bug out at the menu. As in, no "close" button will appear. (The "Cancel" doesn't actually cancel, it sends you to the next menu regardless if a item in the list is present)
I've tried several ways to fix it, but it is more difficult than I thought.
Link to comment
Share on other sites
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.