Napster Posted October 6, 2014 Posted October 6, 2014 (edited) i need help create function convert zeny when query sum zeny over 2147483647 from zeny log SQL query_sql "SELECT SUM(`amount`) FROM `zenylog`WHERE `id` > '0' LIMIT 1", .@sum; if(.@sum > 2147483647) { set .@sum$, " + .@sum; mes "" + .@sum$ +" billion"; } npc can't show over limit 2147483647 thank you for adv Edited October 6, 2014 by Napster Quote
GmOcean Posted October 6, 2014 Posted October 6, 2014 (edited) Are you having issues where a single entry in the sql db has an amount greater than max int? If so then theres nothing we can do unless you increase the size of max_int in the src by maybe converting it to uint64 or something. Edit: Althought this shouldn't be the issue as zenylog's amount is: int(11) which limits it to the max_int you specified. If your having issues finding a way to actually calculate the sum of ALL the sql entries together, then there is a way to do that. However to do so requires a loop and only pulling 1 query at a time. Let me know which is the issue D: Edited October 6, 2014 by GmOcean 1 Quote
Capuche Posted October 6, 2014 Posted October 6, 2014 if you just want to display the total you could store the value in a string variable (it's allowed) query_sql "SELECT SUM(`amount`) FROM `zenylog`", .@sum$; mes .@sum$ +" billion"; 1 Quote
GmOcean Posted October 7, 2014 Posted October 7, 2014 Oh? I didn't know that was allowed. Well, time to delete this annoyingly complicated function xD since it's no longer of use. And yeah, trust me, it is a pain to make stuff like this so take the easy route. Quote
Napster Posted October 9, 2014 Author Posted October 9, 2014 ask some questionwhen use string variable, how to can support or create function format_number ex: 1,000,000,000 Quote
Capuche Posted October 9, 2014 Posted October 9, 2014 you can use insertchar to insert something in the string insertchar(<string>,<char>,<index>) like this function format_number; mes format_number( "100000", "," );// display 100,000 close; function format_number { .@num$ = getarg(0); .@format$ = getarg(1); .@len = getstrlen( .@num$ ); for ( .@i = ( .@len%3 ? .@len%3 : 3 ); .@i < .@len; .@i += 4 ) { .@num$ = insertchar( .@num$, .@format$, .@i ); .@len++; } return .@num$; } I forgot the function in the main repo.. ////////////////////////////////////////////////////////////////////////////////// // Returns a number with commas between every three digits. // -- callfunc "F_InsertComma",<number> // Examples: // callfunc("F_InsertComma",7777777) // returns "7,777,777" ////////////////////////////////////////////////////////////////////////////////// function script F_InsertComma { set .@str$, getarg(0); for (set .@i,getstrlen(.@str$)-3; .@i>0; set .@i,.@i-3) set .@str$, insertchar(.@str$,",",.@i); return .@str$; } it's better D: 1 Quote
Question
Napster
i need help create function convert zeny
when query sum zeny over 2147483647 from zeny log SQL
npc can't show over limit 2147483647
thank you for adv
Edited by Napster7 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.