Lord Ganja 5 Posted September 13, 2015 I'm having an error because of this script. How do I skip the current loop when ".@char_id[.@i]" is offline? .@nb = query_sql("SELECT `char_id` FROM `char_reg_num_db` WHERE `key`='hunter' && `value`='1'", .@char_id ); for( .@i = 0; .@i < .@nb; .@i++ ) { dispbottom "(From Hunter Academy) : "+strcharinfo(0)+" just got online.",0xFFFF00,.@char_id[.@i]; } Error: [Error]: buildin_dispbottom: Player with char id '150018' is not found. Thanks in advance. Quote Share this post Link to post Share on other sites
0 Angelmelody 221 Posted September 15, 2015 you can use charid2rid CMD to check whether the player is online or not if(charid2rid(.@char_id[.@i]))dispbottom "...."; 1 Lord Ganja reacted to this Quote Share this post Link to post Share on other sites
0 GmOcean 92 Posted September 15, 2015 (edited) What you need to do is make sure they are online such as this: .@na = query_sql("SELECT `char_id`,`online` FROM `char`", .@c_id,.@online);.@nb = query_sql("SELECT `char_id` FROM `char_reg_num_db` WHERE `key`='hunter' && `value`='1'", .@char_id ); for( .@i = 0; .@i < .@nb; .@i++ ) { //Loops through second sql_query for( .@a = 0; .@a < .@na; .@a++ ) { //Loops through first sql_query if (.@c_id[.@a] == .@char_id[.@i] && .@online[.@a]) { //Compares Character IDs, and then checks if player is online. // If player is online, then we send the information out. Else, it should skip ahead to the next player who is online. dispbottom "(From Hunter Academy) : "+strcharinfo(0)+" just got online.",0xFFFF00,.@char_id[.@i]; } } } Granted there is a cleaner way to do this using a better sql_query, and/or using the command " while() " instead of " for() ". However, both should get the job done, and depending on the player base, the amount of resources saved is minimal at best. Edit: Haven't tested, but based on scripts I've written in the past this should work, barring any syntax errors. Edited September 15, 2015 by GmOcean Quote Share this post Link to post Share on other sites
0 Lord Ganja 5 Posted September 15, 2015 Thank you @@GmOcean and @@Angelmelody Quote Share this post Link to post Share on other sites
I'm having an error because of this script. How do I skip the current loop when ".@char_id[.@i]" is offline?
Error:
Thanks in advance.
Share this post
Link to post
Share on other sites