checking offline char_id

Lord Ganja

New member
Messages
161
Points
0
Age
34
Location
Ganja World
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.

 
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.

 
Last edited by a moderator:
Thank you @@GmOcean and @@Angelmelody
default_smile.png


 
Back
Top