Jump to content
  • 0

Show Money/Zeny Format?


Question

Posted

Hi, how is the best & easier way to show my Zeny in this format?

lyqif2k8.jpg

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.

10 answers to this question

Recommended Posts

Posted

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.

Posted

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

Posted

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.

Posted

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

  • Upvote 1
Posted

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

ts6FX.png


you have to pass the value into the function.....

set .@i$,callfunc( "int_format", <Value> );
mes .@i$;

Posted

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

Km5MR.png

as you can see..there is 1 extra comma infront of the result....

Posted (edited)

z73vg77z.jpg

you have to pass the value into the function....
/swt This was only a test ^^ xD

Ok, works. great. Made my day. Thanks ^^

Many thanks KeyWorld :D

Edited by InnosTM

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...