tmav94 1 Posted March 13, 2015 (edited) Hi, guys! How to show entire data where char_id = getcharid(0) in npc dialog?I believe that i'll need to use WHILE's, IF and some query_sql's...But, i dont know for where i can start...Can you help me?@OTHERWAYA player have "Z" entries on sql_db... When i use: query_sql( "SELECT `x` FROM `y` WHERE `char_id` = '"+escape_sql( getcharid(0) )+"'",.@status); can i show the values with this? while (i < entries_quantity) {mes "Args: "+.@status[i]+";} can you understand what i can say?@IFOUNDSOMETHING I found a ranking script that have what i want... Look: query_sql "SELECT `char_reg_num_db`.`value`,`char`.`name` FROM `char` INNER JOIN `char_reg_num_db` ON `char_reg_num_db`.`char_id`=`char`.`char_id` WHERE `char_reg_num_db`.`key`='overallkdr' ORDER BY `char_reg_num_db`.`value` DESC LIMIT 1",.@value,.@name$;for (.@i=0; .@i<getarraysize(.@value); .@i++){mes "^0000FFOverall KDR^000000: ^808000"+ .@name$[.@i] +"^000000 - ^CC6633"+ .@value[.@i] +":1^000000";} E.g: The player will send a "Apple" to database.The player will send a "Mace" to database. The player will send a "Ygg" to database.I want to show all items sent by the character in a npc dialogue. Edited March 13, 2015 by tmav94 Quote Share this post Link to post Share on other sites
0 mleo1 36 Posted March 13, 2015 (edited) query_sql( "SELECT `x` FROM `y` WHERE `char_id` = '"+escape_sql( getcharid(0) )+"'",.@status); https://rathena.org/wiki/Query_sql I want to show all items sent by the character in a npc dialogue. you need to look at picklog table: type field mysql limit, you need to offset to show them all Not Tested Samplequery last 20 items that you sent in storage sample set .@nb, query_logsql("SELECT nameid, amount FROM picklog WHERE type='R' AND amount<0 AND char_id=150000 ORDER BY time DESC LIMIT 20",.@item,.@amount); for(set .@i,0; .@i < .@nb; set .@i,.@i+1) mes .@item[.@i] +" "+ .@amount[.@i]; Edited March 13, 2015 by mleo1 1 tmav94 reacted to this Quote Share this post Link to post Share on other sites
0 tmav94 1 Posted March 13, 2015 .@nb = Receive entries on DB like a INT type?.@item = is now a array? .@amount = is now array too? and if i want to show a String Var?the variable will be converted to String Var Array? query_sql( "SELECT `x` FROM `y` WHERE `char_id` = '"+escape_sql( getcharid(0) )+"'",.@status); https://rathena.org/wiki/Query_sql I want to show all items sent by the character in a npc dialogue. you need to look atpicklog table: type fieldmysql limit, you need to offset to show them all Not Tested Samplequery last 20 items that you sent in storage sample set .@nb, query_logsql("SELECT nameid, amount FROM picklog WHERE type='R' AND amount<0 AND char_id=150000 ORDER BY time DESC LIMIT 20",.@item,.@amount); for(set .@i,0; .@i < .@nb; set .@i,.@i+1) mes .@item[.@i] +" "+ .@amount[.@i]; Quote Share this post Link to post Share on other sites
0 Garr 117 Posted March 13, 2015 First of all, how do you register items in the first place if you want to get them from DB? Second, you'll be better off reading the entry on query_sql first. *query_sql("your MySQL query"{, <array variable>{, <array variable>{, ...}}});*query_logsql("your MySQL query"{, <array variable>{, <array variable>{, ...}}});Executes an SQL query. A 'select' query can fill array variables with up to 128 rows of values, and will return the number of rows (the array size).Note that 'query_sql' runs on the main database while 'query_logsql' runs on the log database.Example: .@nb = query_sql("select name,fame from `char` ORDER BY fame DESC LIMIT 5", .@name$, .@fame); mes "Hall Of Fame: TOP5"; mes "1."+.@name$[0]+"("+.@fame[0]+")"; // Will return a person with the biggest fame value. mes "2."+.@name$[1]+"("+.@fame[1]+")"; mes "3."+.@name$[2]+"("+.@fame[2]+")"; mes "4."+.@name$[3]+"("+.@fame[3]+")"; mes "5."+.@name$[4]+"("+.@fame[4]+")"; As you see, .@nb is an int that holds number of matching rows. .@item and .@amount are itemID and amount arrays, starting to fill from 0 to (.@nb - 1). If you need a string from SQL, you need to pass a string variable to the query_sql, aka add postfix "$", like in the example above, .@name$. Quote Share this post Link to post Share on other sites
0 Mhalicot 392 Posted March 14, 2015 query_sql( "SELECT `x` FROM `y` WHERE `char_id` = '"+escape_sql( getcharid(0) )+"'",.@status); https://rathena.org/wiki/Query_sql I want to show all items sent by the character in a npc dialogue. you need to look at picklog table: type field mysql limit, you need to offset to show them all Not Tested Samplequery last 20 items that you sent in storage sample set .@nb, query_logsql("SELECT nameid, amount FROM picklog WHERE type='R' AND amount<0 AND char_id=150000 ORDER BY time DESC LIMIT 20",.@item,.@amount); for(set .@i,0; .@i < .@nb; set .@i,.@i+1) mes .@item[.@i] +" "+ .@amount[.@i]; *set <variable>,<expression>;*set(<variable>,<expression>)This command is deprecated and it shouldn't be used in new scripts, exceptsome special cases (mostly, set getvariableofnpc). Use direct valueassignment instead. so for example: instead of usingset .@nb, query_sql("select name,fame from `char` ORDER BY fame DESC LIMIT 5", .@name$, .@fame);use.@nb = query_sql("select name,fame from `char` ORDER BY fame DESC LIMIT 5", .@name$, .@fame); Quote Share this post Link to post Share on other sites
Hi, guys!
How to show entire data where char_id = getcharid(0) in npc dialog?
I believe that i'll need to use WHILE's, IF and some query_sql's...But, i dont know for where i can start...
Can you help me?
@OTHERWAY
A player have "Z" entries on sql_db...
When i use:
can i show the values with this?
can you understand what i can say?
@IFOUNDSOMETHING
I found a ranking script that have what i want... Look:
E.g:
The player will send a "Apple" to database.
The player will send a "Mace" to database.
The player will send a "Ygg" to database.
I want to show all items sent by the character in a npc dialogue.
Edited by tmav94Share this post
Link to post
Share on other sites