Display Input Amount to format

astralprojection

New member
Messages
334
Points
0
 
Code:
	mes "How much do you buy it?";	input .@price;	next;	mes "Buying Price: ^FF0000"+.@price+"^000000z";	// sample: if i input: 1000000	// This will display: 	//	Buying Price: 1000000z	// How can i make it to this format:	// 	Buying Price: 1m	//	Buying Price: 1.1m	//	Buying Price: 600k	//	Buying Price: 1,000,000z
 
function script beautifyNumber { .@number$ = getarg(0); .@limiter$ = getarg(1); .@length = getstrlen(.@number$); .@numberSeparated$ = ""; if ("" != .@number$ && 3 < .@length) { while (.@length > 3) { .@numberSeparated$ = ("" != .@numberSeparated$) ? substr(.@number$, .@length - 3, .@length - 1) + .@limiter$ + .@numberSeparated$ : substr(.@number$, .@length - 3, .@length - 1); .@length = .@length - 3; } .@numberSeparated$ = substr(.@number$, 0, .@length - 1) + .@limiter$ + .@numberSeparated$; } return (.@numberSeparated$ != "") ? .@numberSeparated$ : .@number$;}
Example: callfunc("beautifyNumber", .@price, ",")

 
wot!!! thank you 

Litro .  I will try this right away. 
default_wink.png


 
http://rathena.org/board/topic/78269-annieruru-lame-script-collection/
Code:
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$;}
you'll find this if you use my mvp ladder, mvp room or mission board
 
Last edited by a moderator:
http://rathena.org/board/topic/78269-annieruru-lame-script-collection/

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$;}you'll find this if you use my mvp ladder, mvp room or mission board
Isn't  there any warning if getarg(0) is interger type?

maybe getarg(0) shoud be converted to string type first

.@i = getstrlen( .@str$ = ""+getarg(0) ) -3;

 
dunno how many times I've said

athena script engine will not throw error when assigning numbers or string

prontera,156,184,5  script  kjhsdkfjhs  100,{//  input .@a, -1000000000, 2000000000;//  dispbottom callfunc( "int__", .@a );  .@str$ = 12345;  .@int = "12345";  dispbottom .@str$ +" "+ .@int; // <-- return 12345 12345  end;}
they only throw error when comparing int and string

if ( .@int == .@str$ )

or displaying an integer in a dialog

dispbottom .@a;

I've used this function for almost 2 years and never getting any error

 
Last edited by a moderator:
dunno how many times I've said

athena script engine will not throw error when assigning numbers or string

prontera,156,184,5  script  kjhsdkfjhs  100,{//  input .@a, -1000000000, 2000000000;//  dispbottom callfunc( "int__", .@a );  .@str$ = 12345;  .@int = "12345";  dispbottom .@str$ +" "+ .@int; // <-- return 12345 12345  end;}
they only throw error when comparing int and string

.@int == .@str$

or displaying an integer in a dialog

dispbottom .@a;

I've used this function for almost 2 years and never getting any error
so....

getstrlen( .@str$ = getarg(0) ) -->pass an int type param won't show warning

getstrlen( getarg(0) )  --->pass an int type param will show warning

Assigning to a varaible is so amazing
default_biggrin.png


 
Last edited by a moderator:
so....

getstrlen( .@str$ = getarg(0) ) -->pass an int type param won't show warning

getstrlen( getarg(0) )  --->pass an int type param will show warning
nonono ... lolgetstrlen( getarg(0) ) also wont show warning ...

getstrlen(1234) or getstrlen("1234") also wont show warning ...

--> wrong info -> read next post

only

dispbottom getstrlen(1234);will show warning
mathematics

if getarg(0) is 12345

-> .@i = getstrlen( .@str$ = getarg(0) ) -3;

-> .@i = getstrlen( .@str$ = 12345 ) -3;

-> .@i = getstrlen(12345) -3; .@str$ = 12345; // <-- perform 2 equations ... split them

-> .@i = 5 -3; .@str$ = 12345;

-> .@i = 2; .@str$ = 12345;

 
Last edited by a moderator:
so....

getstrlen( .@str$ = getarg(0) ) -->pass an int type param won't show warning

getstrlen( getarg(0) )  --->pass an int type param will show warning
nonono ... lolgetstrlen( getarg(0) ) also wont show warning ...

getstrlen(1234) or getstrlen("1234") also wont show warning ...

only

Code:
dispbottom getstrlen(1234);
will show warning

mathematics

if getarg(0) is 12345

-> .@i = getstrlen( .@str$ = getarg(0) ) -3;

-> .@i = getstrlen( .@str$ = 12345 ) -3;

-> .@i = getstrlen(12345) -3; .@str$ = 12345; // <-- perform 2 equations ... split them

-> .@i = 5 -3; .@str$ = 12345;

-> .@i = 2; .@str$ = 12345;
Thanks ,but I test this script with passing an int variable as param,my map console show warning

Code:
function script int__ {.@i = getstrlen(getarg(0)) -3; //----> without assigning.@is_negative = charat( .@str$, 0 ) == "-";while ( .@i > .@is_negative ) {.@str$ = insertchar( .@str$, ",", .@i );.@i -= 3;}return .@str$;}prontera,153,180,5 script aaaa 100,{mes callfunc("int__",Zeny);close;}
Code:
[Warning]: Unexpected type for argument 1. Expected stri[Debug]: Data: param name='Zeny' type=20[Debug]: Function: getstrlen[Debug]: Source (NPC): aaaa at prontera (153,180)
 
Last edited by a moderator:
ok I was wrong previously, screw up

dispbottom "1. "+ getstrlen( Zeny ); debugmes "test1"; <-- error dispbottom "2. "+ getstrlen( Zeny +"" ); debugmes "test2"; <-- OK dispbottom "3. "+ getstrlen( .@z$ = Zeny ); debugmes "test3"; <-- OKso yeahgetstrlen(1234) will throw error ( I messed up )

getstrlen(1234 +""); <-- OK

getstrlen( .@a$ = 1234 ); <-- OK

 
Last edited by a moderator:
Back
Top