Vice City: Multiplayer

VC:MP Discussion => General Discussion => Topic started by: Milos on Apr 26, 2016, 07:27 PM

Title: About GlobalVariable
Post by: Milos on Apr 26, 2016, 07:27 PM
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 );
}
Title: Re: About GlobalVariable
Post by: maxorator on Apr 26, 2016, 07:35 PM
Yes, unless you run out of memory. That shouldn't happen unless you store many millions of rows in there though.
Title: Re: About GlobalVariable
Post by: . on Apr 26, 2016, 08:02 PM
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.
Title: Re: About GlobalVariable
Post by: KAKAN on Apr 27, 2016, 03:29 AM
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!
Title: Re: About GlobalVariable
Post by: Milos on Apr 27, 2016, 03:59 AM
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