Dolphin86 Posted July 23, 2022 Posted July 23, 2022 (edited) Error: Script: Click Here Help please.. Edited July 23, 2022 by Dolphin86 Quote
0 _Terra Posted July 23, 2022 Posted July 23, 2022 chry_fld,144,48,5 script Gatcha Vending 562,{ mes "[Gatcha Ticket Vending]"; mes "Use your Gatcha Ticket here."; next; switch(select("- Use:- See possibility:- Exit")) { case 1: if ( !countitem(.itemuse) ) { mes "[Gatcha Ticket Vending]"; mes "A "+ getitemname(.itemuse) +" is needed to use this machine"; close; } delitem .itemuse, 1; getitem .temp_array[rand(0, getarraysize(.temp_array))], 1; end; case 2: next; mes "[Gatcha Ticket Vending]"; mes "Select possibility."; switch(select("- High Chance:- Mid Chance:- Low Chance:- Exit")){ case 1: next; mes "[Gatcha Ticket Vending]"; mes F_MesItemInfo(14003); mes F_MesItemInfo(40021); mes F_MesItemInfo(40028); mes F_MesItemInfo(40026); end; case 2: next; mes "[Gatcha Ticket Vending]"; mes F_MesItemInfo(40030); mes F_MesItemInfo(40031); mes F_MesItemInfo(40039); mes F_MesItemInfo(40040); end; case 3: mes "[Gatcha Ticket Vending]"; mes F_MesItemInfo(40001); mes F_MesItemInfo(40033); mes F_MesItemInfo(40035); mes F_MesItemInfo(40041); mes F_MesItemInfo(40042); end; case 4: next; mes "[Gatcha Ticket Vending]"; mes "Good Bye."; close; } } OnInit: waitingroom "Gatcha Pot",0,0; .itemuse = 40022; setarray .itemid[0], 14003,40021,40028,40026,40030,40031,40039,40040,40001,40033,40035,40041,40042; setarray .itemchance[0], 90,90,90,90,70,70,70,70,10,10,10,10,10; freeloop(1); .@counter = 0; for(.@i = 0; .@i < getarraysize(.itemid); .@i++) { for(.@k = 0; .@k < .itemchance[.@i]; .@k++) { .temp_array[.@counter] = .itemid[.@i]; .@counter++; } } freeloop(0); end; } 1 Quote
0 Dolphin86 Posted July 24, 2022 Author Posted July 24, 2022 11 hours ago, EIysium said: chry_fld,144,48,5 script Gatcha Vending 562,{ mes "[Gatcha Ticket Vending]"; mes "Use your Gatcha Ticket here."; next; switch(select("- Use:- See possibility:- Exit")) { case 1: if ( !countitem(.itemuse) ) { mes "[Gatcha Ticket Vending]"; mes "A "+ getitemname(.itemuse) +" is needed to use this machine"; close; } delitem .itemuse, 1; getitem .temp_array[rand(0, getarraysize(.temp_array))], 1; end; case 2: next; mes "[Gatcha Ticket Vending]"; mes "Select possibility."; switch(select("- High Chance:- Mid Chance:- Low Chance:- Exit")){ case 1: next; mes "[Gatcha Ticket Vending]"; mes F_MesItemInfo(14003); mes F_MesItemInfo(40021); mes F_MesItemInfo(40028); mes F_MesItemInfo(40026); end; case 2: next; mes "[Gatcha Ticket Vending]"; mes F_MesItemInfo(40030); mes F_MesItemInfo(40031); mes F_MesItemInfo(40039); mes F_MesItemInfo(40040); end; case 3: mes "[Gatcha Ticket Vending]"; mes F_MesItemInfo(40001); mes F_MesItemInfo(40033); mes F_MesItemInfo(40035); mes F_MesItemInfo(40041); mes F_MesItemInfo(40042); end; case 4: next; mes "[Gatcha Ticket Vending]"; mes "Good Bye."; close; } } OnInit: waitingroom "Gatcha Pot",0,0; .itemuse = 40022; setarray .itemid[0], 14003,40021,40028,40026,40030,40031,40039,40040,40001,40033,40035,40041,40042; setarray .itemchance[0], 90,90,90,90,70,70,70,70,10,10,10,10,10; freeloop(1); .@counter = 0; for(.@i = 0; .@i < getarraysize(.itemid); .@i++) { for(.@k = 0; .@k < .itemchance[.@i]; .@k++) { .temp_array[.@counter] = .itemid[.@i]; .@counter++; } } freeloop(0); end; } your the best @Elysium but question, what was wrong actually? Quote
0 _Terra Posted July 24, 2022 Posted July 24, 2022 11 hours ago, Dolphin86 said: your the best @Elysium but question, what was wrong actually? I just add freeloop(1); and freeloop(0) before and after on .@counter = 0 part. Quote
0 Emistry Posted September 23, 2022 Posted September 23, 2022 actually, you can also consider another alternative like this .size = getarraysize(.itemid); for (.@i = 0; .@i < .size; .@i++) .total_chance += .itemchance[.@i]; .@rate = rand(.total_chance); for (.@i = 0; .@i < .size; .@i++) { .@total_itemchance += .itemchance[.@i]; if (.@rate < .@total_itemchance) { getitem .itemid[.@i], 1; end; } } this would greatly reduce your array size, and probably perform slightly better Quote
Question
Dolphin86
Error:
Script:
Click Here
Help please..
Edited by Dolphin864 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.