Raised This Month: $32 Target: $400
 8% 

#define CVAR_VALUE


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-29-2020 , 16:47   #define CVAR_VALUE
Reply With Quote #1

So, I have one question. I want to have prefix set, but that prefix can be set with cvar. I'm preatty sure that to achieve that I need some form of #define that defines that will define that cvars value.

So I have something like this

PHP Code:
g_vipp_prefix register_cvar("amx_vipp_prefix""[VIP]"
And than

PHP Code:
    new vpPrefix[32]
    
get_pcvar_string(g_vipp_prefixvpPrefixcharsmax(vpPrefix)) 
Than I want to have #define that has vpPrefix value.

Hope I made some sence.
supertrio17 is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 05-29-2020 , 17:09   Re: #define CVAR_VALUE
Reply With Quote #2

Why would you use a define for a default value? It's fine to set it directly in the cvar.

Do you want to set the cvar value into a define? Defines do not work like that, they happen at compile time.
__________________

Last edited by gabuch2; 05-29-2020 at 17:11.
gabuch2 is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-29-2020 , 17:26   Re: #define CVAR_VALUE
Reply With Quote #3

Okay, so how can I do this. I have this cvar, and I want value that I get from that cvar to be in here

PHP Code:
get_user_info(idSETINFO_KEYszInfocharsmax(szInfo)) 
Where SETINFO_KEY stands I want to have string from my cvar.
supertrio17 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-29-2020 , 17:28   Re: #define CVAR_VALUE
Reply With Quote #4

Code:
new SETINFO_KEY[32], szInfo[32] // Gets the value from the cvar and stores it in the SETINFO_KEY variable. get_pcvar_string(g_vipp_prefix, SETINFO_KEY, charsmax(SETINFO_KEY)) // Gets the SETINFO_KEY value from the user and stores it in the szInfo variable. get_user_info(id, SETINFO_KEY, szInfo, charsmax(szInfo))
__________________

Last edited by OciXCrom; 05-29-2020 at 17:28.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-29-2020 , 17:29   Re: #define CVAR_VALUE
Reply With Quote #5

Oh, I just keep amazing myself how stupid I can be sometimes... Thank you very much.

Im still learning
supertrio17 is offline
Old 05-29-2020, 17:36
supertrio17
This message has been deleted by supertrio17.
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-29-2020 , 17:40   Re: #define CVAR_VALUE
Reply With Quote #6

Check the API for the specific function - https://amxx-bg.info/api/chatmanager/cm_set_user_prefix

As you can see, it has only 2 arguments. You're using 3 here which is not possible.

I don't know what lpPrefix is, but if it's a string, it should be:

Code:
cm_set_user_prefix(id, lpPrefix)

The %s is not necessary here, nor anywhere when you have only one %s. It can directly be replaced with the string variable itself.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-29-2020 , 17:43   Re: #define CVAR_VALUE
Reply With Quote #7

Belive me or not, I was just about to delete that because I got how stupid it was...
supertrio17 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 01:15.


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