Jump to content
  • 0

SQL Script Question


Virtue

Question


  • Group:  Members
  • Topic Count:  92
  • Topics Per Day:  0.02
  • Content Count:  354
  • Reputation:   22
  • Joined:  11/17/11
  • Last Seen:  

Hi Scripting Pros,

 

is it possible to use this query on a script?

 

 

SELECT COUNT(account_id) AS OnlinePlayers FROM char WHERE online=1;
 

 

I will be using it for some script that checks the online player count

 

Thanks to those who will help.

Link to comment
Share on other sites

6 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  1702
  • Reputation:   238
  • Joined:  09/05/12
  • Last Seen:  

For what reason? you just need the data and not the column name

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  815
  • Reputation:   86
  • Joined:  10/26/12
  • Last Seen:  

For what reason? you just need the data and not the column name

Data..... what data? data folder? sql data?

 

 

You can revise this script

 

http://rathena.org/board/files/go/bd245e8b5202aa15932c5a1826e142fc/ingame-gm-list

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:  

Yes, that query is valid. Alternately, you could just use the return value of Query_sql (or the array size, doesn't make much of a difference).

 

Data..... what data? data folder? /ok

He's referring to the SQL data.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  815
  • Reputation:   86
  • Joined:  10/26/12
  • Last Seen:  

Yes, that query is valid. Alternately, you could just use the return value of Query_sql (or the array size, doesn't make much of a difference).

 

Data..... what data? data folder? sql data? /ok

He's referring to the SQL data.

 

this?

mysql_select_db($Srv_Database, $Connection);
    $query = "SELECT COUNT(*) as total FROM `char` WHERE online = '1'";
 
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  1702
  • Reputation:   238
  • Joined:  09/05/12
  • Last Seen:  

For what reason? you just need the data and not the column name

Do data folder have column name? Topic title already implies what my answer is all about :D

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2347
  • Joined:  10/28/11
  • Last Seen:  

something like this ?

prontera,155,161,5	script	Sample	757,{
query_sql( "SELECT `name` FROM `char` WHERE `online` = 1 LIMIT 128",.@name$ );
.@size = getarraysize( .@name$ );
while( .@i < .@size ){
	if( !checkvending( .@name$[.@i ) )
		.@count++;
	.@i++;
}
mes "Total "+.@count+" Player online without Vending.";
mes "Total "+( .@size - .@count )+" Player online with Vending.";
close;
}

my current script only limited to max 128 players...if you want to extend this.... you can try make use of OFFSET in the SQL statement ...

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...