Jump to content
  • 0

help [SQL Query]


Vietlubu

Question


  • Group:  Members
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  141
  • Reputation:   24
  • Joined:  01/19/12
  • Last Seen:  

i need 2 MySQL Query

1. filter all online players

2. filter all online accounts

thank!

Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

query_sql("SELECT account_id FROM `char` WHERE online = 1 LIMIT 128;",.@accounts);

Then to get player names, do a loop:

rid2name(.@accounts[var])

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  107
  • Reputation:   91
  • Joined:  01/19/12
  • Last Seen:  

Chars:

select char_id from `char` where online=1;

Accounts:

select l.account_id from `login` l join `char` c on l.account_id = c.account_id where c.online=1

The results can be more than 128 rows, use limit to restrict the row number using a page.

set .@PageSize, 100;
set .@Counter, 0;
do {
  set .@Results, query_sql("select l.account_id from `login` l join `char` c on l.account_id = c.account_id where c.online=1 limit " + .@Page + "," + .@PageSize, .@accounts);
  for (set .@x,0; .@x < .@Results; set .@x, .@x + 1) {
 set .@Counter, .@Counter + 1;
 debugmes "Account #" + .@Counter + ": " + .@accounts[.@x];
  }
  set .@Page, .@Page + .@PageSize;
} while (.@Results);

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  141
  • Reputation:   24
  • Joined:  01/19/12
  • Last Seen:  

thank you so much

How to check server online or offline

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

Link to comment
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.   Paste as plain text instead

  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.

×
×
  • Create New...