get_cvar_string( returns empty string for amx_* cvars
I used to make custom db tuple using hardcoded credentials. I have moved all the data to configs/sql.cfg but when I try to create tuple using SQL_MakeStdTuple it gives me error saying it cannot connect to mysql socket. I found out that it is due to get_cvar_string returns empty string on any amx_* cvars including amx_sql_* ones. I tried to obtain these data in plugin_precache and thought they are empty because of wrong timing (i.e. config files are loaded after this native) but when I moved the code to plugin_init the issue is still persist. Could someone please explain why is that and what am I doing wrong?
I do not really care which of the functions I have to use: SQL_MakeStdTuple or SQL_MakeDbTuple, get_[p]cvar_string or anything else I simply do not want to write my own parser for the config file. |
Re: get_cvar_string( returns empty string for amx_* cvars
Technically, get_cvar_string() doesn't return anything (strings are populated by reference) but I can't tell if that's what you're doing because you didn't provide any code to look at . . .
Have you verified that the cvar has the value in it at all? It looks like AMX Mod X's default admin plugin executes this file in plugin_init() so you shouldn't expect it before then. In fact, you should probably not do anything with your custom code until plugin_cfg() (or the newer version of it). If you're not running the default AMX Mod X admin plugin, are you sure it's getting executed at all? |
Re: get_cvar_string( returns empty string for amx_* cvars
I should have provided the code to you, my bad.
PHP Code:
From your comment I realized that it is the admin plugin that handles all the routine. And the reason why I get empty string is that I do not use this plugin) I thought these variables are read by amxmodx module itself or any other module, not plugins. I have checked admin.sma code, it first calls register_cvar to register custom variables, then it executes server command PHP Code:
|
Re: get_cvar_string( returns empty string for amx_* cvars
heres a quick way https://www.amxmodx.org/api/sqlx/SQL_MakeStdTuple
|
Re: get_cvar_string( returns empty string for amx_* cvars
Quote:
|
Re: get_cvar_string( returns empty string for amx_* cvars
Quote:
This makes me think that it wasn't a good idea to include it as part of the AMX Mod X include files and should be relegated to a code snippet/example. |
Re: get_cvar_string( returns empty string for amx_* cvars
Quote:
Post us your version / meta list |
Re: get_cvar_string( returns empty string for amx_* cvars
Quote:
|
Re: get_cvar_string( returns empty string for amx_* cvars
Quote:
|
| All times are GMT -4. The time now is 00:33. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.