Jump to content
  • 0

Show Money/Zeny Format?


Innos

Question


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.01
  • Content Count:  62
  • Reputation:   5
  • Joined:  08/23/17
  • Last Seen:  

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.

Link to comment
Share on other sites

10 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  91
  • Reputation:   25
  • Joined:  11/28/11
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  91
  • Reputation:   25
  • Joined:  11/28/11
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.01
  • Content Count:  62
  • Reputation:   5
  • Joined:  08/23/17
  • Last Seen:  

Thanks. i have testing , but i mean i'm to stupid for this ^^

Edited by InnosTM
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

mes callfunc("int_format", .@prozeny);

Too late.

Edited by KeyWorld
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

typo error.

1 < .@len-1

It's

.@i < .@len-1

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.01
  • Content Count:  62
  • Reputation:   5
  • Joined:  08/23/17
  • Last Seen:  

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
Link to comment
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.   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.

×
×
  • Create New...