AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Dynamic prefix (https://forums.alliedmods.net/showthread.php?t=153555)

seed 03-25-2011 16:39

Dynamic prefix
 
Hi, guys! I made a little test plugin, but it doesn't work. I tried to make dynamic prefixes for the message, but it didn't work. Can you tell me what have i done wrong? Here is the code:

Code:

#include <amxmodx>

new cvar_test, cvar_prefix

public plugin_init()
{
    register_plugin("Test", "1.0", "seed")
   
    cvar_test = register_cvar("test1", "1")
    cvar_prefix = register_cvar("test2", "dynamic")
    register_clcmd("say /test", "gotest")
}

public gotest(id)
{
    static testprefix[16]
    new testcheck, prefixc[16]
    get_pcvar_num(cvar_test)
    get_pcvar_string(cvar_prefix, prefixc, 15)
    if(testcheck == 1)
        formatex(testprefix, 15, "[1]")
    else if(testcheck == 2)   
        formatex(testprefix, 15, "[2]")
    else if(testcheck == 3)
        formatex(testprefix, 15, "%s", prefixc)
    client_print(id, print_chat, "%s asd", testprefix)
}

I want to make the prefix "[1]" when test1 cvar is 1, "[2]" when test1 cvar is 2 and if test1 cvar is 3 - the prefix gets test2's string.

nikhilgupta345 03-25-2011 16:46

Re: Dynamic prefix
 
You have to set testcheck = get_pcvar_num(cvar_test) because as of right now you are not setting it to anything, it is just a declared, never used variable.

seed 03-25-2011 16:57

Re: Dynamic prefix
 
It works now. Thank you!


All times are GMT -4. The time now is 14:37.

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