AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Get cvar name (https://forums.alliedmods.net/showthread.php?t=236335)

extream87 03-03-2014 07:22

[SOLVED] Get cvar name
 
What is wrong obtaining the name "Owner"
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "author" new admintag new MyVar[ 15 ]; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         admintag = register_cvar("admin_tag", "Owner"); } public save_points(id) { ColorChat(player, GREEN, "^1O ^4[%s] ^1deu-te skillpoints.", get_pcvar_string(admintag, MyVar, charsmax(MyVar))); }

NiHiLaNTh 03-03-2014 07:25

Re: [HELP] Get cvar name
 
Code:

static cell AMX_NATIVE_CALL get_pcvar_string(AMX *amx, cell *params)
{
   
cvar_t *ptr = reinterpret_cast<cvar_t *>(params[1]);
    if (!
ptr)
    {
       
LogError(amx, AMX_ERR_NATIVE, "Invalid CVAR pointer");
        return
0;
    }

    return
set_amxstring(amx, params[2], ptr->string ? ptr->string : "", params[3]);
}


get_pcvar_string doesn't return string. Also in pawn you can't return strings anyway.

Code:

public save_points(id) 
{
get_pcvar_string(admintag, MyVar, charsmax(MyVar))
ColorChat(player, GREEN, "^1O ^4[%s] ^1deu-te skillpoints.", MyVar);
}



extream87 03-03-2014 07:35

Re: [HELP] Get cvar name
 
Works, thank you.

But why i cant make it all in one line?

Code:
ColorChat(player, GREEN, "^1O ^4[%s] ^1deu-te skillpoints.", get_pcvar_string(admintag, MyVar, charsmax(MyVar)));

YamiKaitou 03-03-2014 11:29

Re: [HELP] Get cvar name
 
Quote:

Originally Posted by extream87 (Post 2106712)
But why i cant make it all in one line?

Reread his post as he told you why


All times are GMT -4. The time now is 06:00.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.