Quote:
Originally Posted by Dragos
One thing that I saw as useless was this,
PHP Code:
set_task(0.1, "MySql_Init");
You can simply call the function "MySql_Init()" without using set_task for every 0.10 seconds because that function will be automatically called when the plugin is loaded.
Using your method can supercharge the CPU of that database and crash it.
|
What is this nonsense?
Using a delay is not a bad idea, imagine alot of plugins connecting on plugin_init this will cause a bit server lag until all the data is processed.
How ever i saw some potential mistakes you might want to avoid
client_putinserver(id) forward is not guaranteed to be called after client_authorized(id) so you might want to do the following code in client_authorized(id) body because its guaranteed that steam id is ready to be retrieved.
PHP Code:
{
new szQuery[512];
new szData[1];
szData[0] = id;
formatex(szQuery, charsmax(szQuery), "SELECT * FROM `%s` WHERE `steamid` = '%s'", g_szTable, g_PlayerData[id][STEAMID]);
SQL_ThreadQuery(g_SqlTuple, "GetPoints", szQuery, szData, 1);
}
Also you can you use static to initialize big arrays, for a better speed performance.
---------- optimization -------
PHP Code:
server_print(" ");
server_print("[%s] SQL ERROR: %s", szError, g_szPluginName);
server_print(" ");
PHP Code:
server_print("^n[%s] SQL ERROR: %s^n", szError, g_szPluginName);
__________________