Jump to content
  • 0
Sign in to follow this  
tmav94

Help with some multiples query_sql

Question

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:

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 by tmav94

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0


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 Sample

query 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 by mleo1

Share this post


Link to post
Share on other sites
  • 0


.@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 at
picklog table: type field
mysql limit, you need to offset to show them all

 
 
Not Tested Sample
query 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];

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

 


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 Sample

query 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);

 

 

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

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