Raised This Month: $ Target: $400
 0% 

Dynamic prefix


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
seed
Junior Member
Join Date: Nov 2008
Location: Bulgaria !!!
Old 03-25-2011 , 16:39   Dynamic prefix
Reply With Quote #1

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.
seed is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 03-25-2011 , 16:46   Re: Dynamic prefix
Reply With Quote #2

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.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
seed
Junior Member
Join Date: Nov 2008
Location: Bulgaria !!!
Old 03-25-2011 , 16:57   Re: Dynamic prefix
Reply With Quote #3

It works now. Thank you!
seed is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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