AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Invalid Cvar Pointer (https://forums.alliedmods.net/showthread.php?t=184658)

akcaliberg 05-07-2012 11:55

[HELP] Invalid Cvar Pointer
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new settag;
public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_concmd("amx_tag","tag")
    
settag register_cvar("amx_tag","Amx #")
    
}
public 
tag(id) {
    if(
get_user_flags(id) & ADMIN_KICK) {
        new 
arg[32], name[32];
        
read_argv(1,arg,31);
        new 
player cmd_target(id,arg,3);
        
get_user_name(player,name,31);
        new 
tag_2[16];
        
get_pcvar_string(settagtag_215)
        
client_cmd(player,"name ^"%%s^"",settag,name)
    }
    else {
        
console_print(id,"You Can't Use This Command !")
    }


Error:
Quote:

L 05/07/2012 - 18:46:13: Invalid CVAR pointer
L 05/07/2012 - 18:46:13: [AMXX] Run time error 10 (plugin "Amx_Tag.amxx") (native "get_pcvar_string") - debug not enabled!
L 05/07/2012 - 18:46:13: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
:cry:

Exolent[jNr] 05-07-2012 11:56

Re: [HELP] Invalid Cvar Pointer
 
I'm not sure if you can have a command and a cvar with the same name.

akcaliberg 05-07-2012 12:09

Re: [HELP] Invalid Cvar Pointer
 
Omg ! :D I completely forgot :D
Thanks, but now it gave this error:
Quote:

Tried to stuff bad command name "

Exolent[jNr] 05-07-2012 12:14

Re: [HELP] Invalid Cvar Pointer
 
What is your code now?

akcaliberg 05-07-2012 12:17

Re: [HELP] Invalid Cvar Pointer
 
PHP Code:

/* Plugin generated by AMXX-Studio */ 

#include <amxmodx> 
#include <amxmisc> 
#include <cstrike> 

#define PLUGIN "New Plug-In" 
#define VERSION "1.0" 
#define AUTHOR "author" 

new settag
public 
plugin_init() { 
    
register_plugin(PLUGINVERSIONAUTHOR
     
    
register_concmd("amx_tag","tag"
    
settag register_cvar("amx_settag","Amx #"
     

public 
tag(id) { 
    if(
get_user_flags(id) & ADMIN_KICK) { 
        new 
arg[32], name[32]; 
        
read_argv(1,arg,31); 
        new 
player cmd_target(id,arg,3); 
        
get_user_name(player,name,31); 
        new 
tag_2[16]; 
        
get_pcvar_string(settagtag_215
        
client_cmd(player,"name ^"%%s^"",settag,name
    } 
    else { 
        
console_print(id,"You Can't Use This Command !"
    } 



Exolent[jNr] 05-07-2012 12:20

Re: [HELP] Invalid Cvar Pointer
 
First, you should be using this method to change player's name:
Code:
set_user_info(id, "name", name);

Second, you are using the pointer when formatting instead of the value you get from the pointer.
Code:
new tag[16]; get_pcvar_string(settag, tag, charsmax(tag)); new tagged_name[32]; foramtex(taggedName, charsmax(taggedName), "%s %s", tag, name); set_user_info(id, "name", taggedName);

kramesa 05-07-2012 12:31

Re: [HELP] Invalid Cvar Pointer
 
Try this, cvars: amx_tag "Player" and amx_tag_name "Tag Name"

Untested:

Code:
#include <amxmodx> #include <amxmisc> new Tag; public plugin_init() {     Tag = register_cvar("amx_tag_name", "Amx #");     register_clcmd("amx_tag", "CmdTag"); } public CmdTag(id) {     if(get_user_flags(id) & ADMIN_KICK) {         new User[32], Uid;                 read_argv(1, User, 31);                 Uid = find_player("bhl", User);                 if(Uid == 0) {             client_print(id, print_chat, "Player not found.");             return PLUGIN_HANDLED;         }                 new szName[32], UserTag[32], SetName[32];                 get_user_name(Uid, szName, 31);         get_pcvar_string(Tag, UserTag, 31);                 format(SetName, 31, "%s %s", szName, UserTag);                 set_user_info(Uid, "name", SetName);         return PLUGIN_HANDLED;     }     else {         client_print(id, print_chat, "You can't use this command.");         return PLUGIN_HANDLED;     }     return PLUGIN_CONTINUE; }

akcaliberg 05-07-2012 12:39

Re: [HELP] Invalid Cvar Pointer
 
Quote:

Originally Posted by Exolent[jNr] (Post 1704282)
First, you should be using this method to change player's name:
Code:
set_user_info(id, "name", name);

Second, you are using the pointer when formatting instead of the value you get from the pointer.
Code:
new tag[16]; get_pcvar_string(settag, tag, charsmax(tag)); new tagged_name[32]; foramtex(taggedName, charsmax(taggedName), "%s %s", tag, name); set_user_info(id, "name", taggedName);

So what is the new code ? I can't understand exactly without full code.



Thanks kremesa

Muhaymin 08-25-2012 06:50

Re: [HELP] Invalid Cvar Pointer
 
Can Anyone Can Give Me A Right Plugin Of This I Cant Understand

akcaliberg 08-25-2012 11:59

Re: [HELP] Invalid Cvar Pointer
 
PHP Code:

#include <amxmodx> 
#include <amxmisc> 

new Tag;

public 
plugin_init() {
    
Tag register_cvar("amx_tag_name""Amx #");
    
register_clcmd("amx_tag""CmdTag");
}

public 
CmdTag(id) { 
    if(
get_user_flags(id) & ADMIN_KICK) {
        new 
User[32], Uid
        
        
read_argv(1User31);
        
        
Uid find_player("bhl"User); 
        
        if(
Uid == 0) { 
            
client_print(idprint_chat"Player not found.");
            return 
PLUGIN_HANDLED
        } 
        
        new 
szName[32], UserTag[32], SetName[32];
        
        
get_user_name(UidszName31); 
        
get_pcvar_string(TagUserTag31);
        
        
format(SetName31"%s %s"szNameUserTag);
        
        
set_user_info(Uid"name"SetName);
        return 
PLUGIN_HANDLED;
    }
    else {
        
client_print(idprint_chat"You can't use this command.");
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;




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

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