PDA

View Full Version : cvars in a motd


Dr.G
02-12-2009, 04:00 PM
well lately ive been working a some bonus shit for own server, and i ended up have more then 40 adjustable cvars and even tho i made it all myself i wasnt able to remember them all. So what to do? Well came up with an idea about makeing a say command to a motd and get them all printed there, so i did. And this is how i did it, its actully pretty easy, check this out:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN_NAME "Motd test"
#define VERSION "1.0"
#define AUTHOR "Dr.G"

/* extra macros to print */
#define WEB_SITE ".:: dodplugins.net ::."
#define OWNER "Zor"

new p_on

// only test pointers
new p_one, p_two, p_three, p_four

public plugin_init()
{
register_plugin(PLUGIN_NAME, VERSION, AUTHOR)

p_on = register_cvar("dod_motd_test","1") //on/off

p_one = register_cvar("dod_motd_test_1","12")
p_two = register_cvar("dod_motd_test_2","21")
p_three = register_cvar("dod_motd_test_3","13")
p_four = register_cvar("dod_motd_test_4","31")

/*
Say cmd's
NOTE that global say might not work for linux machines!!!
*/
register_clcmd("say /motdtest","motd_test",ADMIN_IMMUNITY)
register_clcmd("say_team /motdtest","motd_test",ADMIN_IMMUNITY)
}

public motd_test(id)
{
if(get_pcvar_num(p_on))
{

new header[33]
/* the length on this array might be a bit big for this lol */
new motd[2048]
new len

/* server name = hostname :) */
new hostname[65]
get_cvar_string("hostname", hostname, 64)

/* lets put the motd together */
formatex(header,32,"%s",PLUGIN_NAME)

len = formatex(motd,2047,"<html><head><style type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-top:0px;}</style></head><body><pre>")

len += formatex(motd[len],2047-len,"[%s]^n<hr>^n",PLUGIN_NAME)

len += formatex(motd[len],2047-len,"Current settings are:^n^n")

len += formatex(motd[len],2047-len,"Testing @ %s^n^n",hostname)

len += formatex(motd[len],2047-len,"dod_motd_test_1: %d^n^n",get_pcvar_num(p_one))

len += formatex(motd[len],2047-len,"dod_motd_test_2: %d^n^n",get_pcvar_num(p_two))

len += formatex(motd[len],2047-len,"dod_motd_test_3: %d^n^n",get_pcvar_num(p_three))

len += formatex(motd[len],2047-len,"dod_motd_test_4: %d^n^n",get_pcvar_num(p_four))

len += formatex(motd[len],2047-len,"<hr>^n^n %s says^n <i>^"is this smart or what!!!</i>^"",AUTHOR)

len += formatex(motd[len],2047-len,"<b><center> %s^nHey have anybody seen %s?? lol</center></b>", WEB_SITE, OWNER)

show_motd(id,motd,header)
}
return PLUGIN_HANDLED
}

BIG credit to xxavalanchexx i looked in his gungame and found the method. Ive attached a SS of how the motd will show...

Cheers!

Tank
02-12-2009, 07:11 PM
Nice work but doesn't cvar.ini just show you what they are set at?

Dr.G
02-13-2009, 11:21 AM
u can add them in that cvar.ini and get them in the menu, but well thats something every server admin would need to do, in this way u can make a specific motd for each plugin, and maybe make a public one for e.g your melee bonus one and make a description and the settings will auto update... another example i just updated the bot damage one for testing, see the attachment... when u say /botdamage the motd will show u the current settings... however i think its pretty smart but iam just n00b with this lol