About GlobalVariable

Started by Milos, Apr 26, 2016, 07:27 PM

Previous topic - Next topic

Milos

I created a function to add all users registered on my server in a global variable. But my question is: Is there a data limit for it?
If I have 5000 accounts, this variable will hold all?

Users <- [];

function LoadAccounts()
{
local q = QuerySQL( db, "SELECT * FROM Accounts" );
while ( GetSQLColumnData( q, 0 ) )
{
Users.push( GetSQLColumnData( q, 0 ) );
GetSQLNextRow( q );
}
FreeSQLQuery( q );
}

maxorator

Yes, unless you run out of memory. That shouldn't happen unless you store many millions of rows in there though.

.

Not at all. Assuming all members take about 1024 bytes of memory each (and I doubt they do) you'd still, eat only 5MB of memory. so I'd say that you're pretty safe. Memory leaks on the other hand, resulted from unreleased statements and other unmanaged data, will eventually make your server have a slow and painful death depending on how much you leak and for how long.
.

KAKAN

#3
I use the same way for storing bans and all, not for accounts though.
You can use a table and store the data of all joined players.
I find this way to be more useful :D
Accounts <- {
list = [],

function Load(){
 local q = QuerySQL( db, "SELECT * FROM Accounts" );
 while ( GetSQLColumnData( q, 0 ) )
 {
  Users.push( GetSQLColumnData( q, 0 ) );
  GetSQLNextRow( q );
 }
 FreeSQLQuery( q );
}
}

And to use it:
Accounts.Load();Good luck!
oh no

Milos

Quote from: KAKAN on Apr 27, 2016, 03:29 AMI use the same way for storing bans and all, not for accounts though.
You can use a table and store the data of all joined players.
I find this way to be more useful :D
Accounts <- {
list = [],

function Load(){
 local q = QuerySQL( db, "SELECT * FROM Accounts" );
 while ( GetSQLColumnData( q, 0 ) )
 {
  Users.push( GetSQLColumnData( q, 0 ) );
  GetSQLNextRow( q );
 }
 FreeSQLQuery( q );
}
}

And to use it:
Accounts.Load();Good luck!
I liked it, thank you for sharing :D