Innos Posted February 3, 2012 Group: Members Topic Count: 18 Topics Per Day: 0.01 Content Count: 62 Reputation: 5 Joined: 08/23/17 Last Seen: March 11, 2019 Share Posted February 3, 2012 Hi, how is the best & easier way to show my Zeny in this format? Its a sql banker. currently i use a second row only for show with "FORMAT(`showzeny`,0)" and set showzeny,prozeny; i don't know how i can change in this format only in the npc. thanks. Quote Link to comment Share on other sites More sharing options...
Terces Posted February 3, 2012 Group: Members Topic Count: 2 Topics Per Day: 0.00 Content Count: 91 Reputation: 25 Joined: 11/28/11 Last Seen: May 6, 2021 Share Posted February 3, 2012 if(.@value > 1000){ for(set .@x,1000; .@x < .@value; set .@x,.@x*1000){ set .@temp,.@value % .@x; if(.@newvalue$) set .@newvalue$,"."+.@newvalue; set .@newvalue$,.@temp+.@newvalue; } } else set .@newvalue$, .@value; I just made that up and I have no idea if it works the way I wanted it to....but it is an idea, nay? btw...".@value" is the value you want to format and ".@newvalue$" is the string you get out of it. Quote Link to comment Share on other sites More sharing options...
KeyWorld Posted February 3, 2012 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 379 Reputation: 304 Joined: 11/10/11 Last Seen: December 2, 2014 Share Posted February 3, 2012 @Terces I'm not sure since of your function (the modulo part isn't good I thing: for 12, it return "12" instead of "012" if I'm not wrong). Well, writing from scratch, but should work in theory (don't have my scripts right now). //callfunc( "int_format", 1055183018 ); // you can add a second argument for the separator, default ",". function script int_format { set .@int, getarg(0); set .@sep$, getarg(1,","); set .@str$, ""; if ( .@int < 0 ) { set .@int, -.@int; set .@neg, 1; } set .@len, getstrlen(.@int+"") - .@neg; for ( set .@i,0; .@i<.@len; set .@i,.@i+1 ) set .@str$, ( .@i % 3 == 2 && 1 < .@len-1 ? .@sep$ : "" ) + ( .@int / pow(10,.@i) ) % 10 + .@str$; return ( .@neg ? "-" : "" ) + .@str$; } Quote Link to comment Share on other sites More sharing options...
Terces Posted February 3, 2012 Group: Members Topic Count: 2 Topics Per Day: 0.00 Content Count: 91 Reputation: 25 Joined: 11/28/11 Last Seen: May 6, 2021 Share Posted February 3, 2012 the modulo really isn't a clever choice, as I have noticed. Also....I noticed some typos and it won't work anyway. I wanted to create an easy and short version, that didn't require a special function....failed at that, it seems. Quote Link to comment Share on other sites More sharing options...
KeyWorld Posted February 3, 2012 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 379 Reputation: 304 Joined: 11/10/11 Last Seen: December 2, 2014 Share Posted February 3, 2012 Maybe better (if I'm not wrong how insertchar() works): function script int_format { set .@int$, getarg(0)+""; set .@sep$, getarg(1,","); set .@l, getstrlen(.@sep$); set .@len, getstrlen(.@int$); for ( set .@i,.@len-3; .@i>0; set .@i, .@i-3-.@l ) set .@int$, insertchar( .@int$, .@sep$, .@i ); return .@int$; } 1 Quote Link to comment Share on other sites More sharing options...
Innos Posted February 3, 2012 Group: Members Topic Count: 18 Topics Per Day: 0.01 Content Count: 62 Reputation: 5 Joined: 08/23/17 Last Seen: March 11, 2019 Author Share Posted February 3, 2012 (edited) Thanks. i have testing , but i mean i'm to stupid for this ^^ Edited February 3, 2012 by InnosTM Quote Link to comment Share on other sites More sharing options...
Emistry Posted February 3, 2012 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: 18 hours ago Share Posted February 3, 2012 the script posted by KeyWorld has work... prontera,155,181,5 script Sample 757,{ set .@i$,callfunc( "int_format", 1055183018 ); mes .@i$; close; } function script int_format { set .@int, getarg(0); set .@sep$, getarg(1,","); set .@str$, ""; if ( .@int < 0 ) { set .@int, -.@int; set .@neg, 1; } set .@len, getstrlen(.@int+"") - .@neg; for ( set .@i,0; .@i<.@len; set .@i,.@i+1 ) set .@str$, ( .@i % 3 == 2 && 1 < .@len-1 ? .@sep$ : "" ) + ( .@int / pow(10,.@i) ) % 10 + .@str$; return ( .@neg ? "-" : "" ) + .@str$; } you have to pass the value into the function..... set .@i$,callfunc( "int_format", <Value> ); mes .@i$; Quote Link to comment Share on other sites More sharing options...
KeyWorld Posted February 3, 2012 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 379 Reputation: 304 Joined: 11/10/11 Last Seen: December 2, 2014 Share Posted February 3, 2012 (edited) mes callfunc("int_format", .@prozeny); Too late. Edited February 3, 2012 by KeyWorld Quote Link to comment Share on other sites More sharing options...
Emistry Posted February 3, 2012 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: 18 hours ago Share Posted February 3, 2012 but i found a problem when i pass a value of Zeny..like this set .@i$,callfunc( "int_format", Zeny ); the result show like this as you can see..there is 1 extra comma infront of the result.... Quote Link to comment Share on other sites More sharing options...
KeyWorld Posted February 3, 2012 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 379 Reputation: 304 Joined: 11/10/11 Last Seen: December 2, 2014 Share Posted February 3, 2012 typo error. 1 < .@len-1 It's .@i < .@len-1 1 Quote Link to comment Share on other sites More sharing options...
Innos Posted February 3, 2012 Group: Members Topic Count: 18 Topics Per Day: 0.01 Content Count: 62 Reputation: 5 Joined: 08/23/17 Last Seen: March 11, 2019 Author Share Posted February 3, 2012 (edited) you have to pass the value into the function.... This was only a test ^^ xDOk, works. great. Made my day. Thanks ^^ Many thanks KeyWorld Edited February 3, 2012 by InnosTM Quote Link to comment Share on other sites More sharing options...
Question
Innos
Hi, how is the best & easier way to show my Zeny in this format?
Its a sql banker. currently i use a second row only for show with "FORMAT(`showzeny`,0)" and set showzeny,prozeny;
i don't know how i can change in this format only in the npc.
thanks.
Link to comment
Share on other sites
10 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.