Jb Roxas Posted February 8, 2012 Share Posted February 8, 2012 (edited) for example: headgear's id# 5738 chance 5% 5443 chance 5% 2294 chance 4% 5509 chance 3% 5150 chance 2% 5426 chance 1% Chances of Losing is 20% item to use to get those prize is id# 20078 Quantity 1 Npc special effect IF WON = /grat IF LOSE = npc effect like the refiner who failed to refine the items splendide,210,199,5 script Sample 757,{ set .OriValkID,2357; set .RareValkID,2305; set .Rate,10; mes "Do you want to refine your "+getitemname( .OriValkID )+" into "+getitemname( .RareValkID )+" ?"; next; if( select("Yes:No") == 2 ) close; if( !countitem( .OriValkID ) ){ mes "You didnt have "+getitemname( .OriValkID )+" now."; }else{ delitem .OriValkID,1; if( rand(100) < .Rate ){ getitem .RareValkID,1; mes "Done, congratz."; }else mes "But Failed."; } close; } Edited February 8, 2012 by Jb Roxas Quote Link to comment Share on other sites More sharing options...
Emistry Posted February 8, 2012 Share Posted February 8, 2012 try this prontera,155,181,5 script Sample 757,{ set .RequiredID,20078; if( !countitem( .RequiredID ) ){ mes "You need 1 "+getitemname( .RequiredID )+" to exchange."; }else if( rand(100) < 20 ){ mes "You have failed in this trade, "+getitemname( .RequiredID )+" will be removed."; delitem .RequiredID,1; specialeffect 155; }else{ mes "Congratz....."; specialeffect 154; set .Random,rand(100); if( .Random <= 5 ) getitem 5738,1; else if( .Random > 5 && .Random <= 10 ) getitem 5443,1; else if( .Random > 10 && .Random <= 14 ) getitem 2294,1; else if( .Random > 14 && .Random <= 17 ) getitem 5509,1; else if( .Random > 17 && .Random <= 19 ) getitem 5150,1; else if( .Random > 19 && .Random <= 20 ) getitem 5426,1; else mes "You gained nothing."; } close; } Quote Link to comment Share on other sites More sharing options...
Skorm Posted February 8, 2012 Share Posted February 8, 2012 (edited) http://mysticpaste.c...ate/nvt5Eq5cJ5/ Tested works really well, actually. splendide,210,199,5 script Sample 757,{ setarray [email protected][0],20,5738,20,5443,25,2294,33,5509,50,5150,100,5426; set [email protected],20078; mes "Do you want to use your "+getitemname( [email protected] )+" to try and get something awesome?"; next; if( select("Yes:No")-1 ) close; if( !countitem( [email protected] ) ){ mes "You don't have any "+getitemname( [email protected] )+"."; } else { delitem [email protected],1; for(set [email protected],0; [email protected] < getarraysize([email protected]); set [email protected],[email protected]+2){ if(rand([email protected][[email protected]])==1){ getitem ([email protected][[email protected]+1]),1; emotion e_grat; mes "Done, congratz."; close; } } specialeffect2 611; mes "It failed, sorry."; } close; } } To add more items. Simply put there probability out of 100 then there itemid in the [email protected] array. Example: If I wanted to add angra(1599) at 20% 100/20=5 setarray [email protected][0],20,5738,20,5443,25,2294,33,5509,50,5150,100,5426,5,1599; Edit: Sorry Emistry I didn't realize you had replied. Edit-Edit: Because 5%+5%+4%+3%+2%+1%+20%=40%? Doesn't add up to 100% (LOL) there is a 60% gap so the losing percent is actually something like 50% because of the gained percentage of having multiple chances to win. Edited February 8, 2012 by Skorm Quote Link to comment Share on other sites More sharing options...
Keysito Posted February 8, 2012 Share Posted February 8, 2012 http://mysticpaste.c...ate/nvt5Eq5cJ5/ Tested works really well, actually. splendide,210,199,5 script Sample 757,{ setarray [email protected][0],20,5738,20,5443,25,2294,33,5509,50,5150,100,5426; set [email protected],20078; mes "Do you want to use your "+getitemname( [email protected] )+" to try and get something awesome?"; next; if( select("Yes:No")-1 ) close; if( !countitem( [email protected] ) ){ mes "You don't have any "+getitemname( [email protected] )+"."; } else { delitem [email protected],1; for(set [email protected],0; [email protected] < getarraysize([email protected]); set [email protected],[email protected]+2){ if(rand([email protected][[email protected]])==1){ getitem ([email protected][[email protected]+1]),1; emotion e_grat; mes "Done, congratz."; close; } } specialeffect2 611; mes "It failed, sorry."; } close; } } Edit: Sorry Emistry I didn't realize you had replied. Edit-Edit: Because 5%+5%+4%+3%+2%+1%+20%=40%? Doesn't add up to 100% (LOL) there is a 60% gap so the losing percent is actually something like 50% because of the gained percentage of having multiple chances to win. Yeahy, Tested it works i have (Few Edited) So can i ask for help? how can i make announce that 'ONLY SELECTED ITEM' I only want I.D 5738 to be announce? Thank you for this. Melody :3 Quote Link to comment Share on other sites More sharing options...
Skorm Posted February 8, 2012 Share Posted February 8, 2012 (edited) http://mysticpaste.com/private/sY9NTAipgr/ prontera.gat,155,185,5 script Event Random 757,{ setarray [email protected][0],20,5738,20,5443,25,2294,33,5509,50,5150,100,5426; setarray [email protected]_announce[0],5738,5150; set [email protected]_required,1201; mes "Do you want to use your "+getitemname( [email protected]_required )+" to try and get something awesome?"; next; if( select("- Yes:- No")-1 ) close; if( !countitem( [email protected]_required ) ){ mes "You don't have any "+getitemname( [email protected]_required )+"."; mes "Please come back soon, if you have already them"; } else { delitem [email protected]_required,1; for(set [email protected],0; [email protected] < getarraysize([email protected]); set [email protected],[email protected]+2){ if(rand([email protected][[email protected]])==1){ getitem ([email protected][[email protected]+1]),1; mes "Congratulations!"; for(set [email protected],0; [email protected] < getarraysize([email protected]); set [email protected],[email protected]+1){ if([email protected][[email protected]+1][email protected]_announce[[email protected]]) { announce "[Event Random]: Player " + strcharinfo(0) +", has obtain "+ (([email protected][[email protected]]>=50)?"Low":"High") +" "+getitemname( [email protected][[email protected]+1] )+" with ["+ (100/[email protected][[email protected]]) +"%] Chance.",bc_all,0xBA55D3; } } specialeffect 154; close; } } specialeffect 155; mes "lt's failed, sorry."; } close; } Edited February 8, 2012 by Skorm Quote Link to comment Share on other sites More sharing options...
Jb Roxas Posted February 8, 2012 Author Share Posted February 8, 2012 else if( .Random > 5 && .Random <= 10 ) getitem 5443,1; <<- it means 5% over 100% ?? else if( .Random > 10 && .Random <= 14 ) getitem 2294,1; else if( .Random > 14 && .Random <= 17 ) getitem 5509,1; else if( .Random > 17 && .Random <= 19 ) getitem 5150,1; else if( .Random > 19 && .Random <= 20 ) getitem 5426,1; <<-- it means 1% over 100% ?? Quote Link to comment Share on other sites More sharing options...
Emistry Posted February 8, 2012 Share Posted February 8, 2012 else if( .Random > 5 && .Random <= 10 ) getitem 5443,1; <<- it means 5% over 100% ?? else if( .Random > 10 && .Random <= 14 ) getitem 2294,1; else if( .Random > 14 && .Random <= 17 ) getitem 5509,1; else if( .Random > 17 && .Random <= 19 ) getitem 5150,1; else if( .Random > 19 && .Random <= 20 ) getitem 5426,1; <<-- it means 1% over 100% ?? depend on this. set .Random,rand(100); Quote Link to comment Share on other sites More sharing options...
Jb Roxas Posted February 9, 2012 Author Share Posted February 9, 2012 @Emistry How about if, else if( .Random > 5 && .Random <= 10 ) getitem 5443,1; BROADCAST THE NAME OF THE ITEM IF THEY WON Quote Link to comment Share on other sites More sharing options...
Emistry Posted February 9, 2012 Share Posted February 9, 2012 set .Random,rand(BaseRate);if( .Random > .Num1 && .Random <= Num2 ) getitem ...... to calculate your rate... ( Num2 - Num1 ) / BaseRate to broadcast.. announce "You get item NAME",0; Quote Link to comment Share on other sites More sharing options...
Jb Roxas Posted February 9, 2012 Author Share Posted February 9, 2012 (edited) elseif(.Random>5&&.Random<=10) getitem 5443,1; announce "You get item NAME",5443; elseif(.Random>10&&.Random<=14) getitem 2294,1; announce "You get item NAME",2294; elseif(.Random>14&&.Random<=17) getitem 5509,1; announce "You get item NAME",5509; elseif(.Random>17&&.Random<=19) getitem 5150,1; announce "You get item NAME",5150; elseif(.Random>19&&.Random<=20) getitem 5426,1; announce "You get item NAME",5426; is it right? Edited February 9, 2012 by Jb Roxas Quote Link to comment Share on other sites More sharing options...
Emistry Posted February 9, 2012 Share Posted February 9, 2012 when your script / script going to read more than 1 line.. you have to use curley to wrap your script.. if( condition ){ < script here.......> }else{ < balblabla script...> } Quote Link to comment Share on other sites More sharing options...
Jb Roxas Posted February 9, 2012 Author Share Posted February 9, 2012 (edited) Sir can u type how to put the broadcast on this script if i win this item elseif(.Random>5&&.Random<=10) getitem 5443,1; <---- that is Cherub Hat Example of broadcast, YOU WON CHERUB HAT Edited February 9, 2012 by Jb Roxas Quote Link to comment Share on other sites More sharing options...
Skorm Posted February 9, 2012 Share Posted February 9, 2012 (edited) @jb Roxas I've already made a script that does all of that, are you blind? prontera.gat,155,185,5 script Event Random 757,{ setarray [email protected][0],20,5738,20,5443,25,2294,33,5509,50,5150,100,5426; setarray [email protected]_announce[0],5738,5150; set [email protected]_required,1201; mes "Do you want to use your "+getitemname( [email protected]_required )+" to try and get something awesome?"; next; if( select("- Yes:- No")-1 ) close; if( !countitem( [email protected]_required ) ){ mes "You don't have any "+getitemname( [email protected]_required )+"."; mes "Please come back soon, if you have already them"; } else { delitem [email protected]_required,1; for(set [email protected],0; [email protected] < getarraysize([email protected]); set [email protected],[email protected]+2){ if(rand([email protected][[email protected]])==1){ getitem ([email protected][[email protected]+1]),1; mes "Congratulations!"; for(set [email protected],0; [email protected] < getarraysize([email protected]); set [email protected],[email protected]+1){ if([email protected][[email protected]+1][email protected]_announce[[email protected]]) { announce "[Event Random]: Player " + strcharinfo(0) +", has obtain "+ (([email protected][[email protected]]>=50)?"Low":"High") +" "+getitemname( [email protected][[email protected]+1] )+" with ["+ (100/[email protected][[email protected]]) +"%] Chance.",bc_all,0xBA55D3; } } specialeffect 154; close; } } specialeffect 155; mes "lt's failed, sorry."; } close; } Will broadcast any item that is in the array. setarray .@items_announce[0],5738,5150; Edited February 9, 2012 by Skorm Quote Link to comment Share on other sites More sharing options...
Jb Roxas Posted March 9, 2012 Author Share Posted March 9, 2012 @Skorm, thank you so much man, it works fine on my server. @skorm what is the number for 20% chance? Quote Link to comment Share on other sites More sharing options...
Skorm Posted June 6, 2012 Share Posted June 6, 2012 100/20=5 so 5 is 20% Quote Link to comment Share on other sites More sharing options...
for example:
headgear's id#
5738 chance 5%
5443 chance 5%
2294 chance 4%
5509 chance 3%
5150 chance 2%
5426 chance 1%
Chances of Losing is 20%
item to use to get those prize is id# 20078 Quantity 1
Npc special effect
IF WON = /grat
IF LOSE = npc effect like the refiner who failed to refine the items
splendide,210,199,5 script Sample 757,{ set .OriValkID,2357; set .RareValkID,2305; set .Rate,10; mes "Do you want to refine your "+getitemname( .OriValkID )+" into "+getitemname( .RareValkID )+" ?"; next; if( select("Yes:No") == 2 ) close; if( !countitem( .OriValkID ) ){ mes "You didnt have "+getitemname( .OriValkID )+" now."; }else{ delitem .OriValkID,1; if( rand(100) < .Rate ){ getitem .RareValkID,1; mes "Done, congratz."; }else mes "But Failed."; } close; }Link to comment
Share on other sites