Jump to content
  • 0

SQL Script Question


Question

Posted

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.

6 answers to this question

Recommended Posts

Posted

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.

Posted

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'";
 
Posted

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

Posted

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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...