AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   #define CVAR_VALUE (https://forums.alliedmods.net/showthread.php?t=324865)

supertrio17 05-29-2020 16:47

#define CVAR_VALUE
 
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.

gabuch2 05-29-2020 17:09

Re: #define CVAR_VALUE
 
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.

supertrio17 05-29-2020 17:26

Re: #define CVAR_VALUE
 
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.

OciXCrom 05-29-2020 17:28

Re: #define CVAR_VALUE
 
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))

supertrio17 05-29-2020 17:29

Re: #define CVAR_VALUE
 
Oh, I just keep amazing myself how stupid I can be sometimes... Thank you very much.

Im still learning :(

OciXCrom 05-29-2020 17:40

Re: #define CVAR_VALUE
 
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.

supertrio17 05-29-2020 17:43

Re: #define CVAR_VALUE
 
Belive me or not, I was just about to delete that because I got how stupid it was...


All times are GMT -4. The time now is 17:04.

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