AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Can someone solve my question about the code? (https://forums.alliedmods.net/showthread.php?t=140139)

GarbageBox 10-09-2010 07:23

Can someone solve my question about the code?
 
Code:

#include <amxmodx>

/*---------------EDIT ME------------------*/
#define ADMIN_CHECK ADMIN_KICK

static const COLOR[] = "^x04" //green
static const CONTACT[] = "[email protected]"
/*----------------------------------------*/

new maxplayers
new gmsgSayText

public plugin_init() {
        register_plugin("Admin Check", "1.51", "OneEyed")
        maxplayers = get_maxplayers()
        gmsgSayText = get_user_msgid("SayText")
        register_clcmd("say", "handle_say")
        register_cvar("amx_contactinfo", CONTACT, FCVAR_SERVER)
}

What is the different between "static const" and #define?
register_cvar("amx_contactinfo", CONTACT, FCVAR_SERVER)
↑↑ It means create a cvar and it can modify in amxx.cfg?
"..., CONTACT" <- It means that it is already default at the top stuff? It can change it by use the amx_contactinfo?

Bugsy 10-09-2010 09:50

Re: Can someone solve my question about the code?
 
Quote:

Originally Posted by GarbageBox (Post 1319929)
What is the different between "static const" and #define?
register_cvar("amx_contactinfo", CONTACT, FCVAR_SERVER)
↑↑ It means create a cvar and it can modify in amxx.cfg?
"..., CONTACT" <- It means that it is already default at the top stuff? It can change it by use the amx_contactinfo?

http://forums.alliedmods.net/showpos...9&postcount=12

As for your second question, you are only using the const var to declare your cvar value. The method (const,#define,var,"value") used to set the initial value of the cvar has no bearing on whether or not the cvar can be changed (ie, this will not make it a 'constant cvar'). Changing the cvar via console or config file will not change the variable value in your code. A cvar declared in this fashion can be altered manually via console or through a .cfg file.

Declaring the CONTACT variable as a constant simply will restrict you from altering the value of that variable in your code.


All times are GMT -4. The time now is 10:25.

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