Raised This Month: $ Target: $400
 0% 

register cvar string


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fabrizio guespe
Junior Member
Join Date: Aug 2010
Old 08-24-2010 , 20:24   register cvar string
Reply With Quote #1

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)
fabrizio guespe is offline
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 08-24-2010 , 20:33   Re: register cvar string
Reply With Quote #2

http://amxmodx.org/funcwiki.php?go=func&id=1062
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-24-2010 , 20:36   Re: register cvar string
Reply With Quote #3

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)
__________________
Bugsy is offline
fabrizio guespe
Junior Member
Join Date: Aug 2010
Old 08-24-2010 , 20:55   Re: register cvar string
Reply With Quote #4

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
fabrizio guespe is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-24-2010 , 21:08   Re: register cvar string
Reply With Quote #5

Quote:
Originally Posted by fabrizio guespe View Post
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
__________________
Bugsy 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 22:01.


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