AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   register cvar string (https://forums.alliedmods.net/showthread.php?t=136287)

fabrizio guespe 08-24-2010 20:24

register cvar string
 
How do i register a cvar into a variable that is a string.


I tried this:

new cvar[32]
new msg[32]

cvar = register_cvar("admin_msg", "ADMIN MSG")
msg = get_pcvar_string(cvar)

DarkGod 08-24-2010 20:33

Re: register cvar string
 
http://amxmodx.org/funcwiki.php?go=func&id=1062

Bugsy 08-24-2010 20:36

Re: register cvar string
 
Just so you don't get confused, register_cvar returns an integer value (not an array). Change new cvar[32] to just new cvar (for the above code you posted)

fabrizio guespe 08-24-2010 20:55

Re: register cvar string
 
new cvar
new msg2[32]
cvar = register_cvar("admin_msg", "ADMIN MSG")
client_print(id, print_chat, "%s",get_pcvar_string(cvar,msg2, 31))

Doesn't work

Bugsy 08-24-2010 21:08

Re: register cvar string
 
Quote:

Originally Posted by fabrizio guespe (Post 1281008)
new cvar
new msg2[32]
cvar = register_cvar("admin_msg", "ADMIN MSG")
client_print(id, print_chat, "%s",get_pcvar_string(cvar,msg2, 31))

Doesn't work

get_pcvar_string populates the msg2 variable with the string value. The function itself returns the length of string retrieved.
PHP Code:

    new cvar,msg2[32
    
cvar register_cvar("admin_msg""ADMIN MSG")
    
get_pcvar_string(cvar,msg231)
    
server_print("%s",msg2)    

    
//to see #characters you could do
    
server_print("%d characters [%s]",get_pcvar_string(cvar,msg231),msg2



All times are GMT -4. The time now is 22:01.

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