Yasunari Ishibashi Posted November 27, 2012 Group: Members Topic Count: 49 Topics Per Day: 0.01 Content Count: 157 Reputation: 2 Joined: 01/06/12 Last Seen: August 25, 2014 Share Posted November 27, 2012 (edited) example script : function script CustomBoxUpper { setarray .BoxItems[0],25194,25195,25197,25199,25202,25203,25205; set .Random, rand( getarraysize( .BoxItems ) ); getitem .BoxItems[ .Random ], 1; announce "["+strcharinfo(0)+"] baru saja memperoleh ["+getitemname(.BoxItems[ .Random ])+"] dari Custom Box.",0; end; } Please help me edit the script, I want to add percent chance each get an item. eg: 25194 -> 40% 25195 -> 25% 25196 -> 10% 25199 -> 1% if anyone can help edit my scripts? sorry my bad english Edited November 27, 2012 by Yasunari Ishibashi Quote Link to comment Share on other sites More sharing options...
GM Takumirai Posted November 27, 2012 Group: Members Topic Count: 69 Topics Per Day: 0.01 Content Count: 592 Reputation: 31 Joined: 11/14/11 Last Seen: July 29, 2015 Share Posted November 27, 2012 the better way to do this is to make another type of obb.. http://rathena.org/board/topic/68778-how-to-make-a-custom-obb-or-oca/#entry126978 Quote Link to comment Share on other sites More sharing options...
Yasunari Ishibashi Posted November 27, 2012 Group: Members Topic Count: 49 Topics Per Day: 0.01 Content Count: 157 Reputation: 2 Joined: 01/06/12 Last Seen: August 25, 2014 Author Share Posted November 27, 2012 the better way to do this is to make another type of obb.. http://rathena.org/b...ca/#entry126978 how to add annoucher items obtained from the box? Quote Link to comment Share on other sites More sharing options...
GM Takumirai Posted November 27, 2012 Group: Members Topic Count: 69 Topics Per Day: 0.01 Content Count: 592 Reputation: 31 Joined: 11/14/11 Last Seen: July 29, 2015 Share Posted November 27, 2012 if you want like that you can use this.. http://rathena.org/board/topic/65196-tcg-drainer-very-useful-to-most-of-the-servers-just-like-lotti-girl-in-pro/ Quote Link to comment Share on other sites More sharing options...
Yasunari Ishibashi Posted November 27, 2012 Group: Members Topic Count: 49 Topics Per Day: 0.01 Content Count: 157 Reputation: 2 Joined: 01/06/12 Last Seen: August 25, 2014 Author Share Posted November 27, 2012 whether it can make a sample script? similar function as an additional type obb, annoucher if it get the items from the box sorry bad english Quote Link to comment Share on other sites More sharing options...
Emistry Posted November 27, 2012 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted November 27, 2012 try this ? http://pastebin.com/raw.php?i=JvgpBfzs Fixed missing getitem , added item amount. http://pastebin.com/raw.php?i=LbGztCH5 Quote Link to comment Share on other sites More sharing options...
Yasunari Ishibashi Posted November 28, 2012 Group: Members Topic Count: 49 Topics Per Day: 0.01 Content Count: 157 Reputation: 2 Joined: 01/06/12 Last Seen: August 25, 2014 Author Share Posted November 28, 2012 what if adding zeny 50 million 60% poringcoin x 5 50% goldcoin x 2 20% please help Quote Link to comment Share on other sites More sharing options...
AnnieRuru Posted November 30, 2012 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted November 30, 2012 what if adding zeny 50 million 60% poringcoin x 5 50% goldcoin x 2 20% please help set .@rand, rand( 20+50+60 ); if ( .@rand < 20 ) getitem "goldcoin", 2; else if ( .@rand < 20+50 ) getitem "poringcoin", 5; else if ( .@rand < 20+50+60 ) set zeny, zeny + 50000000; I think you should see the trick sort the conditions from lowest chance to higher chance Quote Link to comment Share on other sites More sharing options...
Yasunari Ishibashi Posted November 30, 2012 Group: Members Topic Count: 49 Topics Per Day: 0.01 Content Count: 157 Reputation: 2 Joined: 01/06/12 Last Seen: August 25, 2014 Author Share Posted November 30, 2012 how to add annoucher when getting items from the box? Quote Link to comment Share on other sites More sharing options...
AnnieRuru Posted November 30, 2012 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted November 30, 2012 (edited) change if ( .@rand < 20 ) getitem "goldcoin", 2; into if ( .@rand < 20 ) { getitem "goldcoin", 2; announce strcharinfo(0) +" has earn gold coin x2", bc_all; } PS: lucky I'm the kind of scripter that is learn from ZERO (totally nothing) this is the trick I used 5 years ago ... of course now I use array x.x and yeah ... I also asked this kind of questions before x.x Edited November 30, 2012 by AnnieRuru Quote Link to comment Share on other sites More sharing options...
uDe Posted November 30, 2012 Group: Members Topic Count: 43 Topics Per Day: 0.01 Content Count: 400 Reputation: 5 Joined: 12/05/11 Last Seen: September 27, 2015 Share Posted November 30, 2012 how to add annoucher when getting items from the box? here? try this ? http://pastebin.com/raw.php?i=JvgpBfzs Fixed missing getitem , added item amount. http://pastebin.com/raw.php?i=LbGztCH5 Quote Link to comment Share on other sites More sharing options...
Yasunari Ishibashi Posted December 1, 2012 Group: Members Topic Count: 49 Topics Per Day: 0.01 Content Count: 157 Reputation: 2 Joined: 01/06/12 Last Seen: August 25, 2014 Author Share Posted December 1, 2012 try this ? http://pastebin.com/raw.php?i=JvgpBfzs Fixed missing getitem , added item amount. http://pastebin.com/raw.php?i=LbGztCH5 what if adding zeny 50 million 60% poringcoin x 5 50% goldcoin x 2 20% please help set .@rand, rand( 20+50+60 ); if ( .@rand < 20 ) getitem "goldcoin", 2; else if ( .@rand < 20+50 ) getitem "poringcoin", 5; else if ( .@rand < 20+50+60 ) set zeny, zeny + 50000000; I think you should see the trick sort the conditions from lowest chance to higher chance thanks Quote Link to comment Share on other sites More sharing options...
Yasunari Ishibashi Posted December 4, 2012 Group: Members Topic Count: 49 Topics Per Day: 0.01 Content Count: 157 Reputation: 2 Joined: 01/06/12 Last Seen: August 25, 2014 Author Share Posted December 4, 2012 (edited) try this ? http://pastebin.com/raw.php?i=JvgpBfzs Fixed missing getitem , added item amount. http://pastebin.com/raw.php?i=LbGztCH5 parse_line: expect command, missing function name or calling undeclared function 28 : { * 29 : '.'@i = rand(100); 30 : please justify the script and adding the amount of the item obtained with annoucher,thanks change if ( .@rand < 20 ) getitem "goldcoin", 2; into if ( .@rand < 20 ) { getitem "goldcoin", 2; announce strcharinfo(0) +" has earn gold coin x2", bc_all; } PS: lucky I'm the kind of scripter that is learn from ZERO (totally nothing) this is the trick I used 5 years ago ... of course now I use array x.x and yeah ... I also asked this kind of questions before x.x function script sample { set .@rand, rand( 20+50+60 ); if ( .@rand < 20 ) { getitem "goldcoin", 2; announce strcharinfo(0) +" has earn gold coin x2", bc_all; } else if ( .@rand < 20+50 ) getitem "poringcoin", 5; announce strcharinfo(0) +" has earn poring coin x5", bc_all; } else if ( .@rand < 20+50+60 ) set zeny, zeny + 50000000; announce strcharinfo(0) +" has earn zeny 50.000.000", bc_all; } } please justify the script Edited December 4, 2012 by Yasunari Ishibashi Quote Link to comment Share on other sites More sharing options...
Yasunari Ishibashi Posted December 10, 2012 Group: Members Topic Count: 49 Topics Per Day: 0.01 Content Count: 157 Reputation: 2 Joined: 01/06/12 Last Seen: August 25, 2014 Author Share Posted December 10, 2012 bump Quote Link to comment Share on other sites More sharing options...
AnnieRuru Posted December 10, 2012 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted December 10, 2012 .... are you asking to be spoon feed ? xxxxx, ...... ,{ doevent "asdf::Onasdf"; },{},{} - script asdf -1,{ Onasdf: set .@rand, rand( 20+50+60 ); if ( .@rand < 20 ) { getitem "gold_coin", 2; announce strcharinfo(0) +" has earn gold coin x2", bc_all; } else if ( .@rand < 20+50 ) { getitem "poring_coin", 5; announce strcharinfo(0) +" has earn poring coin x5", bc_all; } else if ( .@rand < 20+50+60 ) { set zeny, zeny + 50000000; announce strcharinfo(0) +" has earn zeny 50,000,000", bc_all; } } Quote Link to comment Share on other sites More sharing options...
Ryokem Posted December 10, 2012 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 205 Reputation: 19 Joined: 10/12/12 Last Seen: November 7, 2013 Share Posted December 10, 2012 (edited) .... are you asking to be spoon feed ? set .@rand, rand( 20+50+60 ); // [...] else if ( .@rand < 20+50+60 ) { //Do stuff } What's the point of this? .@rand goes from 0 to (20+50+60)-1, it's obvious that its lower than (20+50+60) xD You added an useless check. Just like this will be enough set .@rand, rand( 20+50+60 ); // [...] else { //Do stuff } Edited December 10, 2012 by Ryokem Quote Link to comment Share on other sites More sharing options...
AnnieRuru Posted December 10, 2012 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted December 10, 2012 (edited) What's the point of this? .@rand goes from 0 to (20+50+60)-1, it's obvious that its lower than (20+50+60) xD You added an useless check. Just like this will be enough set .@rand, rand( 20+50+60 ); // [...] else { //Do stuff } yeah its lower , that's why I use < and not using <=how about you post up your script so let's compare our methods EDITING post : ... using arrays because I know you are the kind of person who loves to complicate the topic, and I can play with you EDIT2: here you go - script asdf -1,{ Onasdf: .@rand = rand(.totalchance); while ( ( .@rand = .@rand - getd( ".r"+ .@r +"[0]" ) ) >= 0 ) .@r++; announce strcharinfo(0) +" has earn "+ .ann$[.@r], bc_all; if ( getd( ".r"+ .@r +"[1]" ) ) zeny = zeny + getd( ".r"+ .@r +"[1]" ); if ( .size[.@r] > 2 ) for ( .@i = 0; .@i < .size[.@r]; .@i += 2 ) getitem getd( ".r"+ .@r +"["+ .@i +"]" ), getd( ".r"+ .@r +"["+( .@i +1 )+"]" ); end; OnInit: // <chance>, <zeny>, <require item ID 1>, <require item amount 1>, <require item ID 2>, <require item amount 2>, .... setarray .r1, 20, 0, 671,2 ; setarray .r2, 50, 0, 7539,2 ; setarray .r3, 60, 50000000; .total = 3; freeloop 1; .@i = 1; while ( .@i <= .total ) { .totalchance = .totalchance + getd(".r"+ .@i ); if ( getd( ".r"+ .@i +"[1]" ) ) .ann$[.@i] = .ann$[.@i] +"zeny "+ callfunc( "int__", getd( ".r"+ .@i +"[1]" ) ); .@j = 2; .size[.@i] = getarraysize( getd(".r"+ .@i ) ); if ( getd( ".r"+ .@i +"[1]" ) && .size[.@i] > 2 ) .ann$[.@i] = .ann$[.@i] +" and "; while ( .@j < .size[.@i] ) { .ann$[.@i] = .ann$[.@i] + getitemname( getd( ".r"+ .@i +"["+ .@j +"]" ) ) +" x"+ getd( ".r"+ .@i +"["+( .@j +1 )+"]" )+( ( .@j == .size[.@i] -2 )? "":"," ); .@j += 2; } // announce .ann$[.@i], 0; .@i++; } freeloop 0; end; } function script int__ { .@i = getstrlen( .@str$ = getarg(0) ) -3; .@is_negative = charat( .@str$, 0 ) == "-"; while ( .@i > .@is_negative ) { .@str$ = insertchar( .@str$, ",", .@i ); .@i -= 3; } return .@str$; } ] Edited December 10, 2012 by AnnieRuru Quote Link to comment Share on other sites More sharing options...
Ryokem Posted December 10, 2012 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 205 Reputation: 19 Joined: 10/12/12 Last Seen: November 7, 2013 Share Posted December 10, 2012 (edited) yeah its lower , that's why I use < and not using <= how about you post up your script so let's compare our methods I meant like this - script asdf -1,{ Onasdf: set .@rand, rand( 20+50+60 ); if ( .@rand < 20 ) { getitem "gold_coin", 2; announce strcharinfo(0) +" has earn gold coin x2", bc_all; } else if ( .@rand < 20+50 ) { getitem "poring_coin", 5; announce strcharinfo(0) +" has earn poring coin x5", bc_all; } //else if ( .@rand < 20+50+60 ) { //Your version. else { set zeny, zeny + 50000000; announce strcharinfo(0) +" has earn zeny 50,000,000", bc_all; } } 'Cause you will 100% fall in that case if it jumps to that else. So no need to do the if (.@rand < 20+50+60 ) check Edited December 10, 2012 by Ryokem Quote Link to comment Share on other sites More sharing options...
AnnieRuru Posted December 10, 2012 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted December 10, 2012 I can hardly believe I am being taught to use ELSE... that was for educational purpose .... ok we are complicating this topic 'Cause you will 100% fall in that case if it jumps to that else. I like an explanation to this ... Quote Link to comment Share on other sites More sharing options...
Ryokem Posted December 10, 2012 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 205 Reputation: 19 Joined: 10/12/12 Last Seen: November 7, 2013 Share Posted December 10, 2012 I can hardly believe I am being taught to use ELSE... that was for educational purpose .... ok we are complicating this topic 'Cause you will 100% fall in that case if it jumps to that else. I like an explanation to this ... What's so hard to understand? set .@rand, rand( 20+50+60 ) ; Will randomize a number from 0 to (20+50+60)-1. Are you fine with this? else if ( .@rand < 20+50+60 ) .@rand is OBVIOUSLY < (20+50+60) because its range goes from Will randomize a number from 0 to (20+50+60)-1. So you are just using server memory to check something obvious. Then, just use else, instead of else if, as there no need to check the obvious. Is this really so difficult to understand? O.o Quote Link to comment Share on other sites More sharing options...
Omnipotent Posted December 10, 2012 Group: Members Topic Count: 1 Topics Per Day: 0.00 Content Count: 71 Reputation: 25 Joined: 11/23/11 Last Seen: May 16, 2024 Share Posted December 10, 2012 I can hardly believe I am being taught to use ELSE... that was for educational purpose .... ok we are complicating this topic 'Cause you will 100% fall in that case if it jumps to that else. I like an explanation to this ... What's so hard to understand? set .@rand, rand( 20+50+60 ) ; Will randomize a number from 0 to (20+50+60)-1. Are you fine with this? else if ( .@rand < 20+50+60 ) .@rand is OBVIOUSLY < (20+50+60) because its range goes from Will randomize a number from 0 to (20+50+60)-1. So you are just using server memory to check something obvious. Then, just use else, instead of else if, as there no need to check the obvious. Is this really so difficult to understand? O.o She already knows it, what she said is that she made it that way to show how it's done. 2 Quote Link to comment Share on other sites More sharing options...
Question
Yasunari Ishibashi
example script :
Please help me edit the script,
I want to add percent chance each get an item.
eg:
25194 -> 40%
25195 -> 25%
25196 -> 10%
25199 -> 1%
if anyone can help edit my scripts?
sorry my bad english
Edited by Yasunari IshibashiLink to comment
Share on other sites
20 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.