Patskie 88 Posted May 1, 2013 (edited) Hello i just want to request if this is possible. Why not implement a script command wherein it will get all results from a query_sql command. For example if a script do a query_command like the following : query_sql "SELECT `name` FROM `char` WHERE `online` = '1'", .@name$; From the query given above i must implement a for loop statement to go over with all the data. for( set .@a,0; .@a < getarraysize(.@name$); set .@a,.@a + 1) mes "- " +.@name$[.@a]; My suggestions is this : 1. Implement a script command like ResultSet in java or DataReader on C#? so if this will happen. It would look like these when i use the query given above : ( i would give ResultSet as an example ) ResultSet rs = query.getResultSet(); //Get the result from the query_sql commandwhile (rs.next()) { set .@names$ = rs.getString("name"); mes "Online Users : " +.@names$;} } Or it may be : ResultSet rs = query_sql("SELECT `name` FROM `char` WHERE `online` = '1'") // Direct Querywhile (rs.next()) { set .@names$ = rs.getString("name"); mes "Online Users : " +.@names$;} } While the statement has next line get those and when they are in the name column then print them. Well for me it will be quite easy to make scripts Anyway this is just a suggestion. Edited May 2, 2013 by Patskie Quote Share this post Link to post Share on other sites
Dastgir 1246 Posted May 1, 2013 query_sql and loop is good for everyone i guess, well anyways, in both the cases there is a loop, just difference is the format. Quote Share this post Link to post Share on other sites
Patskie 88 Posted May 1, 2013 query_sql and loop is good for everyone i guess, well anyways, in both the cases there is a loop, just difference is the format. But for a newbie scripter. It will be more easy to learn and remember this suggestion. But like you've said. Either will do a loop Quote Share this post Link to post Share on other sites
jaBote 438 Posted May 1, 2013 Well, it may be easier for newbies, but I'd still go for the loop. Reason is simple: there's lot of documentation already and almost any scripting guide (not script_commands.txt which is a reference but an actual guide) also shows how to loop through the result set. And well, I may not be used to Java structure, but your example makes me think classic loop can be easier too - no need of invoking any artificial method of advancing through the resultset. Quote Share this post Link to post Share on other sites
Patskie 88 Posted May 2, 2013 Being on others point of view .next() command is more readable than a for loop statement. I know there is an existing script for dealing over all the data which is for loop. But there is a saying that the more simpler and easier the code is, the better, as long as they provide the accurate result. Another thing i want to consider in this suggestion, Can anyone (developer) here create a script command wherein it will get the item script of an item and put it in npc script? This suggestion is like this post on rAthena. Well correct me if this command is already existing. Thanks Quote Share this post Link to post Share on other sites
Dastgir 1246 Posted May 2, 2013 (edited) Well the suggestion is good, bcoz it do not have array, that means no limit to 128. I suggest to have both, the current one and the one that is suggested. Edited May 2, 2013 by dastgirpojee Quote Share this post Link to post Share on other sites
Patskie 88 Posted May 2, 2013 Well the suggestion is good, bcoz it do not have array, that means no limit to 128. I suggest to have both, the current one and the one that is suggested. Exactly! Some scripts might have been limited to 128 because of array limit. But with these suggestion it will read all the data until the very end Quote Share this post Link to post Share on other sites
Kenpachi 65 Posted May 2, 2013 This syntax is completely different from our syntax... and since you can use LIMIT in MySQL it is simple to loop through more than 128 entries. If we would create something like this we had to build a new variable typ which is exclusive because it would ignore the 128 entries limit. In my opinion this is too much effort for such little benefit. Quote Share this post Link to post Share on other sites