Jump to content
  • 0
Sign in to follow this  
astralprojection

Display Input Amount to format

Question

 
	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

 

Share this post


Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 0
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, ",")

Share this post


Link to post
Share on other sites
  • 0
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 Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

 

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;

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

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 :D

Edited by Angelmelody

Share this post


Link to post
Share on other sites
  • 0

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 ... lol

getstrlen( 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;

Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

 

 

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 ... lol

getstrlen( getarg(0) ) also wont show warning ...

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

 

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;

 

 

Thanks ,but I test this script with passing an int variable as param,

my map console show warning

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;}

 

 

 

[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)

Edited by Angelmelody

Share this post


Link to post
Share on other sites
  • 0

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"; <-- OK
so yeah

getstrlen(1234) will throw error ( I messed up )

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

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.