Jump to content
  • 0
Sign in to follow this  
Lord Ganja

checking offline char_id

Question

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.

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

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