Raised This Month: $ Target: $400
 0% 

Can someone solve my question about the code?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GarbageBox
Senior Member
Join Date: Feb 2010
Old 10-09-2010 , 07:23   Can someone solve my question about the code?
Reply With Quote #1

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?
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-09-2010 , 09:50   Re: Can someone solve my question about the code?
Reply With Quote #2

Quote:
Originally Posted by GarbageBox View Post
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.
__________________

Last edited by Bugsy; 10-09-2010 at 09:52.
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 10:25.


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