#1

Hi, is it possible to loop all the player's to save the stats? I'm using mysql. And i'm talking about the UPDATE statement for all the players connected
Reply
#2

Yes, of course you can.

Example code:

PHP код:
new query[99];
for(new 
0MAX_PLAYERS ++)
{
    
mysql_format(mysqlquerysizeof(query), "UPDATE `Users` SET `Money` = %d WHERE `ID` = %d",
    
GetPlayerMoney(i),
    
mysql_tquery(mysqlquery"""");

Reply
#3

Use foreach.inc
Reply
#4

You should also add a check to make sure the player is logged in and registered, don't save them otherwise.
Reply
#5

You can basically use the function added in the 0.3.7: GetPlayerPoolSize which gets the hightest player ID (this is useful to save memory).


And so:


PHP код:
    for(new 0<= GetPlayerPoolSize(); i++)
    {
        if(
IsPlayerConnected(i) && loggedvariable[i] == true)
        {
            
//here put the code to save the variables on the db
        
}
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)