Jump to content
  • 1

Setarray on .@menu


Question

Posted
Quote


    .@menu = select( 
        (countitem(.@required[0])?"- Exchange with "+getitemname(.@required[0])+"":""),
        (countitem(.@required[1])?"- Exchange with "+getitemname(.@required[1])+"":""),
        (countitem(.@required[2])?"- Exchange with "+getitemname(.@required[2])+"":""),
        (countitem(.@required[3])?"- Exchange with "+getitemname(.@required[3])+"":""),
        (countitem(.@required[4])?"- Exchange with "+getitemname(.@required[4])+"":""),
 

hii how can i shorten or make an array of cases so it 

example i have case 1: up to case 300: and so on

thankyou in advance

    switch(.@menu) {
    case 1:

9 answers to this question

Recommended Posts

  • 0
Posted
prontera,155,181,3	script	Yumi Test	94,{

	for(.@i=0;.@i<getarraysize(.Require);.@i++)
		.@menu$ += (countitem(.Require[.@i]) ? "- Exchange ^0055FF"+.ReqAmount[.@i]+"^000000 "+getitemname(.Require[.@i])+" to ^0055FF"+.ExcAmount[.@i]+"^000000 "+getitemname(.Exchange[.@i])+":":":");
	.@sel = select(.@menu$)-1;
	message strcharinfo(0),"Input amount 1-1000";
	input .@in,1,1000;
	if(countitem(.Require[.@sel]) < .ReqAmount[.@sel]*.@in){
		message strcharinfo(0),"Insufficient "+getitemname(.Require[.@sel])+"";
		end;
	}
	if(!checkweight(.Exchange[.@sel],.@in*.ExcAmount[.@sel])){
		message strcharinfo(0),"Insufficient inventory space";
		end;
	}
	delitem .Require[.@sel],.ReqAmount[.@sel]*.@in;
	getitem .Exchange[.@sel],.@in*.ExcAmount[.@sel];
end;
	
OnInit:
	setarray .Require[0],501,502,503,504,505;
	setarray .ReqAmount[0],1,1,1,1,1;
	setarray .Exchange[0],512,513,514,515,516;
	setarray .ExcAmount[0],50,25,20,30,45;
end;
}

 

  • 0
Posted
prontera,155,181,3	script	Yumi Test	94,{

	for(.@i=0;.@i<getarraysize(.Require);.@i++)
		.@menu$ += (countitem(.Require[.@i]) ? "- Exchange with "+getitemname(.Require[.@i])+":":":");
	.@sel = select(.@menu$)-1;
	npctalk "Exchange with "+getitemname(.Require[.@sel]);
	
OnInit:
	setarray .Require[0],501,502,503,504,505;
end;
}

 

  • Love 1
  • 0
Posted (edited)
On 12/30/2020 at 6:12 PM, Haruka Mayumi said:

prontera,155,181,3	script	Yumi Test	94,{

	for(.@i=0;.@i<getarraysize(.Require);.@i++)
		.@menu$ += (countitem(.Require[.@i]) ? "- Exchange with "+getitemname(.Require[.@i])+":":":");
	.@sel = select(.@menu$)-1;
	npctalk "Exchange with "+getitemname(.Require[.@sel]);
	
OnInit:
	setarray .Require[0],501,502,503,504,505;
end;
}

 

thanks so much for the reply.. this is the script i've been working on

prontera,155,185,4    script    Weapon Exchanger    4_BOARD3,{
setarray .@item, 5125,2116,2521,1148,2250,2355,2324;
setarray .@amount, 5,1,3;
setarray .@exchange, 7915,675;

setarray .@item1, 2244,2245,2248,2282,2254,2255,1559,2527,5045,5017,1162,5008,2317,1158,1466,2249,1124,1128,1477,2288,1236,1256,2507,2319,2274;


    .@menu = select( 
//bronze
        (countitem(.@item[0])?"- "+getitemname(.@item[0])+" = "+.@amount[0]+" "+getitemname(.@exchange[0])+" ":""),
        (countitem(.@item[1])?"- "+getitemname(.@item[1])+" = "+.@amount[0]+" "+getitemname(.@exchange[0])+" ":""),
        (countitem(.@item[2])?"- "+getitemname(.@item[2])+" = "+.@amount[0]+" "+getitemname(.@exchange[0])+" ":""),
        (countitem(.@item[3])?"- "+getitemname(.@item[3])+" = "+.@amount[0]+" "+getitemname(.@exchange[0])+" ":""),
        (countitem(.@item[4])?"- "+getitemname(.@item[4])+" = "+.@amount[0]+" "+getitemname(.@exchange[0])+" ":""),
        (countitem(.@item[5])?"- "+getitemname(.@item[5])+" = "+.@amount[0]+" "+getitemname(.@exchange[0])+" ":""),
//Silver
        (countitem(.@item1[0])?"- "+getitemname(.@item1[0])+" = "+.@amount[1]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[1])?"- "+getitemname(.@item1[1])+" = "+.@amount[1]+" "+getitemname(.@exchange[1])+" ":""),

//3 silver

        (countitem(.@item1[2])?"- "+getitemname(.@item1[2])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[3])?"- "+getitemname(.@item1[3])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[4])?"- "+getitemname(.@item1[4])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[5])?"- "+getitemname(.@item1[5])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[6])?"- "+getitemname(.@item1[6])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[7])?"- "+getitemname(.@item1[7])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[8])?"- "+getitemname(.@item1[8])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[9])?"- "+getitemname(.@item1[9])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[10])?"- "+getitemname(.@item1[10])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[11])?"- "+getitemname(.@item1[11])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[12])?"- "+getitemname(.@item1[12])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[13])?"- "+getitemname(.@item1[13])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[14])?"- "+getitemname(.@item1[14])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[15])?"- "+getitemname(.@item1[15])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[16])?"- "+getitemname(.@item1[16])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[17])?"- "+getitemname(.@item1[17])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[18])?"- "+getitemname(.@item1[18])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[19])?"- "+getitemname(.@item1[19])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[20])?"- "+getitemname(.@item1[20])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[21])?"- "+getitemname(.@item1[21])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[22])?"- "+getitemname(.@item1[22])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),

        (countitem(.@item1[23])?"- "+getitemname(.@item1[23])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[24])?"- "+getitemname(.@item1[24])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[25])?"- "+getitemname(.@item1[25])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[26])?"- "+getitemname(.@item1[26])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[27])?"- "+getitemname(.@item1[27])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),
        (countitem(.@item1[28])?"- "+getitemname(.@item1[28])+" = "+.@amount[2]+" "+getitemname(.@exchange[1])+" ":""),


        "- Nothing"
        );
    switch(.@menu) {
    case 1:
    input @amount,0,1000;
    set .choice, 0;
    delitem .@item[0],@amount;
    getitem .@exchange[0],.@amount[.choice]*@amount;
        break;
    case 2:
    input @amount,0,1000;
    set .choice, 1;
    delitem .@item[1],@amount;
    getitem .@exchange[0],.@amount[.choice]*@amount;
        break;
    case 3:
    input @amount,0,1000;
    set .choice, 2;
    delitem .@item[2],@amount;
    getitem .@exchange[0],.@amount[.choice]*@amount;
        break;
    case 4:
    input @amount,0,1000;
    set .choice, 3;
    delitem .@item[3],@amount;
    getitem .@exchange[0],.@amount[.choice]*@amount;
        break;
    case 5:
    input @amount,0,1000;
    set .choice, 4;
    delitem .@item[4],@amount;
    getitem .@exchange[0],.@amount[.choice]*@amount;
        break;
    case 6:
    input @amount,0,1000;
    set .choice, 5;
    delitem .@item[5],@amount;
    getitem .@exchange[0],.@amount[.choice]*@amount;
        break;

//Silver
    case 7:
    input @amount,0,1000;
    set .choice, 0;
    delitem .@item1[0],@amount;
    getitem .@exchange[1],.@amount[1]*@amount;
        break;
    case 8:
    input @amount,0,1000;
    set .choice, 1;
    delitem .@item1[1],@amount;
    getitem .@exchange[1],.@amount[1]*@amount;
        break;
    case 9:
    input @amount,0,1000;
    set .choice, 2;
    delitem .@item1[2],@amount;
    getitem .@exchange[1],.@amount[1]*@amount;
        break;
    case 10:
    input @amount,0,1000;
    set .choice, 3;
    delitem .@item1[3],@amount;
    getitem .@exchange[1],.@amount[1]*@amount;
        break;

//3 silver
    case 11:
    input @amount,0,1000;
    set .choice, 4;
    delitem .@item1[4],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 12:
    input @amount,0,1000;
    set .choice, 5;
    delitem .@item1[5],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 13:
    input @amount,0,1000;
    set .choice, 6;
    delitem .@item1[6],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 14:
    input @amount,0,1000;
    set .choice, 7;
    delitem .@item1[7],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 15:
    input @amount,0,1000;
    set .choice, 8;
    delitem .@item1[8],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 16:
    input @amount,0,1000;
    set .choice, 9;
    delitem .@item1[9],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 17:
    input @amount,0,1000;
    set .choice, 10;
    delitem .@item1[10],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 18:
    input @amount,0,1000;
    set .choice, 11;
    delitem .@item1[11],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 19:
    input @amount,0,1000;
    set .choice, 12;
    delitem .@item1[12],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 20:
    input @amount,0,1000;
    set .choice, 13;
    delitem .@item1[13],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 21:
    input @amount,0,1000;
    set .choice, 14;
    delitem .@item1[14],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 22:
    input @amount,0,1000;
    set .choice, 15;
    delitem .@item1[15],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 23:
    input @amount,0,1000;
    set .choice, 16;
    delitem .@item1[16],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 24:
    input @amount,0,1000;
    set .choice, 17;
    delitem .@item1[17],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 25:
    input @amount,0,1000;
    set .choice, 18;
    delitem .@item1[18],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 26:
    input @amount,0,1000;
    set .choice, 19;
    delitem .@item1[19],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 27:
    input @amount,0,1000;
    set .choice, 20;
    delitem .@item1[20],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 28:
    input @amount,0,1000;
    set .choice, 21;
    delitem .@item1[21],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 29:
    input @amount,0,1000;
    set .choice, 22;
    delitem .@item1[22],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 30:
    input @amount,0,1000;
    set .choice, 23;
    delitem .@item1[23],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 31:
    input @amount,0,1000;
    set .choice, 24;
    delitem .@item1[24],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 32:
    input @amount,0,1000;
    set .choice, 25;
    delitem .@item1[25],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 33:
    input @amount,0,1000;
    set .choice, 26;
    delitem .@item1[26],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 34:
    input @amount,0,1000;
    set .choice, 27;
    delitem .@item1[27],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 35:
    input @amount,0,1000;
    set .choice, 28;
    delitem .@item1[28],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 36:
    input @amount,0,1000;
    set .choice, 29;
    delitem .@item1[29],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 37:
    input @amount,0,1000;
    set .choice, 30;
    delitem .@item1[30],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;
    case 38:
    input @amount,0,1000;
    set .choice, 31;
    delitem .@item1[31],@amount;
    getitem .@exchange[1],.@amount[2]*@amount;
        break;

    default:
        mes "[ Exchanger ]";
        mes "There's nothing i can do for you.";
        mes " ";
        mes "Please come back to me later!";
        break;
    }
    end;
    

}

id like to want it simpler .. so i wont get confused adding cases.. 

 

as you see im on only case 38; and it's too long already.. scrolling up and down to check if it works breaks my eyes

like maybe 

setarray .@case, 1,2,3,4,5,6,7,8,9,10

each case will delete a specified item and get an specified item

example.. 1 red potion = 1 flywing , but 1 orange potion will get 2 dead branches

Edited by Haruka Mayumi
Code Box
  • 0
Posted (edited)
prontera,155,181,3	script	Yumi Test	94,{

	for(.@i=0;.@i<getarraysize(.Require);.@i++)
		.@menu$ += (countitem(.Require[.@i]) ? "- Exchange ^0055FF"+.ReqAmount[.@i]+"^000000 "+getitemname(.Require[.@i])+" to "+getitemname(.Exchange[.@i])+":":":");
	.@sel = select(.@menu$)-1;
	message strcharinfo(0),"Input amount 1-1000";
	input .@in,1,1000;
	if(countitem(.Require[.@sel]) < .ReqAmount[.@sel]*.@in){
		message strcharinfo(0),"Insufficient "+getitemname(.Require[.@sel])+"";
		end;
	}
	if(!checkweight(.Exchange[.@sel],.@in)){
		message strcharinfo(0),"Insufficient inventory space";
		end;
	}
	delitem .Require[.@sel],.ReqAmount[.@sel]*.@in;
	getitem .Exchange[.@sel],.@in;
end;
	
OnInit:
	setarray .Require[0],501,502,503,504,505;
	setarray .ReqAmount[0],5,2,3,4,1;
	setarray .Exchange[0],512,513,514,515,516;
end;
}

 

Edited by Haruka Mayumi
Added Checkweight
  • Upvote 1
  • 0
Posted
On 12/30/2020 at 8:46 PM, Haruka Mayumi said:

prontera,155,181,3	script	Yumi Test	94,{

	for(.@i=0;.@i<getarraysize(.Require);.@i++)
		.@menu$ += (countitem(.Require[.@i]) ? "- Exchange ^0055FF"+.ReqAmount[.@i]+"^000000 "+getitemname(.Require[.@i])+" to "+getitemname(.Exchange[.@i])+":":":");
	.@sel = select(.@menu$)-1;
	message strcharinfo(0),"Input amount 1-1000";
	input .@in,1,1000;
	if(countitem(.Require[.@sel]) < .ReqAmount[.@sel]*.@in){
		message strcharinfo(0),"Insufficient "+getitemname(.Require[.@sel])+"";
		end;
	}
	if(!checkweight(.Exchange[.@sel],.@in)){
		message strcharinfo(0),"Insufficient inventory space";
		end;
	}
	delitem .Require[.@sel],.ReqAmount[.@sel]*.@in;
	getitem .Exchange[.@sel],.@in;
end;
	
OnInit:
	setarray .Require[0],501,502,503,504,505;
	setarray .ReqAmount[0],5,2,3,4,1;
	setarray .Exchange[0],512,513,514,515,516;
end;
}

 

thankyou so much ill try this later .. it will be a huge help 

 

jawaii,204,287,3    script    Yumi Test    94,{

    for(.@i=0;.@i<getarraysize(.Require);.@i++)
        .@menu$ += (countitem(.Require[.@i]) ? "- Exchange ^0055FF"+.ReqAmount[.@i]+"^000000 "+getitemname(.Require[.@i])+" to "+getitemname(.Exchange[.@i])+":":":");
    .@sel = select(.@menu$)-1;
    message strcharinfo(0),"Input amount 1-1000";
    input .@in,1,1000;
    if(countitem(.Require[.@sel]) < .ReqAmount[.@sel]*.@in){
        message strcharinfo(0),"Insufficient "+getitemname(.Require[.@sel])+"";
        end;
    }
    if(!checkweight(.Exchange[.@sel],.@in)){
        message strcharinfo(0),"Insufficient inventory space";
        end;
    }
    delitem .Require[.@sel],.ReqAmount[.@sel]*.@in;
    getitem .Exchange[.@sel],.@in;
end;
    
OnInit:
    setarray .Require[0],1232,1242,13001,1234,1236,13047
                 ,1238
                 ,1241,1233,13002
                 ,1235
                 ,1230;    
    setarray .ReqAmount[0],1,1,1,1,1,1
                  ,5
                  ,10,10,10
                  ,30
                  ,50;
    setarray .Exchange[0],7929,7929,7929,7929,7929,7929,7929,7929,7929,7929,7929,7929;
end;
}

@Haruka Mayumitried it.. however i am confused a little bit.. i was trying to exchange itemID 1230 for 50 pcs 7929 , it requires me 50 1230 for 1 7929 ( the concept is an NPC that buys items from players )

 

On 12/30/2020 at 10:57 PM, Haruka Mayumi said:

prontera,155,181,3	script	Yumi Test	94,{

	for(.@i=0;.@i<getarraysize(.Require);.@i++)
		.@menu$ += (countitem(.Require[.@i]) ? "- Exchange ^0055FF"+.ReqAmount[.@i]+"^000000 "+getitemname(.Require[.@i])+" to ^0055FF"+.ExcAmount[.@i]+"^000000 "+getitemname(.Exchange[.@i])+":":":");
	.@sel = select(.@menu$)-1;
	message strcharinfo(0),"Input amount 1-1000";
	input .@in,1,1000;
	if(countitem(.Require[.@sel]) < .ReqAmount[.@sel]*.@in){
		message strcharinfo(0),"Insufficient "+getitemname(.Require[.@sel])+"";
		end;
	}
	if(!checkweight(.Exchange[.@sel],.@in*.ExcAmount[.@sel])){
		message strcharinfo(0),"Insufficient inventory space";
		end;
	}
	delitem .Require[.@sel],.ReqAmount[.@sel]*.@in;
	getitem .Exchange[.@sel],.@in*.ExcAmount[.@sel];
end;
	
OnInit:
	setarray .Require[0],501,502,503,504,505;
	setarray .ReqAmount[0],1,1,1,1,1;
	setarray .Exchange[0],512,513,514,515,516;
	setarray .ExcAmount[0],50,25,20,30,45;
end;
}

 

Worked !! .. there's just a bug .. when you're on the @input state.. when you typed 0 .. it still gets the item and exchange it.. normaly you should enter 1 .. 

  • 0
Posted (edited)

Since you are exchanging it already.. the input is from 1 to 1000

input .@in,1,1000;

You just need to change this line and add 1 line after it.. should be like this

input .@in,0,1000;
if(!.@in) end;
Edited by Haruka Mayumi
  • Upvote 1
  • 0
Posted

Thankyou so much for helping me .. thank you thankyou @Yumi Haruka  [SOLVED] (i dont know if this is against the rules.. [sorry for not reading it all]) can i tag you on my other script request? which involves a NPC that will drop an item every X minutes if a player is nearby? ( For PVP purposes and Defending the spot) "with a waiting room countdown" -- if this is against the rules .. i am so sorry 

  • 0
Posted
12 hours ago, Haruka Mayumi said:

You can tag me on a post and if I have some time. I might do it.. but do not message me.

Thankyou so much.. i named The NPC as Haruka Mayumi, it's the least i can do

Haruka.png

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...