sql
hello. i want to make a plugin but first i have to be sure that i use sql correct.
I have a piece of code that works without problems. Can someone look over it and tell me what i can improve or if i did something that can cause bugs? PHP Code:
|
Re: sql
One thing that I saw as useless was this,
PHP Code:
Using your method can supercharge the CPU of that database and crash it. |
Re: sql
Quote:
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:
---------- optimization ------- PHP Code:
PHP Code:
|
Re: sql
Much time I thought that using set_task will lag your server, but hearing you, you changed my opinion.
Now I found out why it took so long time to change the map on some king of servers I tested it. |
Re: sql
Quote:
I'm using set_task because i m trying to avoid this error: Code:
[MySQL] Thread worker was unable to start. |
Re: sql
Also on threaded query fail stop the rest of the code from executing for example
PHP Code:
Also There is no need to free the handle in threaded query function data callback ((FreeHandle))(SQL_FreeHandle(Query)) |
Re: sql
Quote:
PHP Code:
PHP Code:
Code:
Note |
Re: sql
Quote:
|
Re: sql
I only use execute on queries that I need executed immediately. Examples are the creation and pruning of tables at plugin_init/plugin_cfg.
For everything else, including loading and saving player data during gameplay, threaded queries should be used. |
Re: sql
Quote:
|
| All times are GMT -4. The time now is 02:39. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.