AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Cvar function on/off help (https://forums.alliedmods.net/showthread.php?t=50200)

Sav 01-21-2007 15:00

Cvar function on/off help
 
Hey guys i was makeing a plugin that displays the motds for
recruit /recrut
main motd /motd
rules /rules

wat i need to do is have
amx_motd 1|2
and have it turn it off.. if any of you want to post ither the cvar check for it or a function to turn off and on. thank you.

please post it with comments explaining what it does (learning)
heres my code
Code:

#include <amxmodx>
#include <amxmisc>
 
new g_Switch;
 
public plugin_init()
{
        register_plugin("Show Motd", "1.0", "SavSin/Raphero");
        register_clcmd("say /motd", "motd");
        register_clcmd("say /recruit", "recruit");
        register_clcmd("say /rules", "rules");
        g_Switch = register_cvar("amx_motd","1");
}
public motd(id)
{
        if(get_pcvar_num(g_Switch))
        {
                show_motd(id, "czero/motd.txt", "Motd");
                return;
        }
}
public recruit(id)
{
        if(get_pcvar_num(g_Switch))
        {
                show_motd ( id, "recruit.txt");
                return;
        }
}
public rules(id)
{
        if(get_pcvar_num(g_Switch))
        {
                show_motd ( id, "rules.txt");
                return;
        }
}


Got it updated code above

dutchmeat 01-22-2007 05:29

Re: Cvar function on/off help
 
Code:
new g_Switch; //First we create a socalled variable.   public plugin_init() { register_plugin("Show Motd", "1.0", "SavSin/Raphero"); register_clcmd("say /motd", "motd"); register_clcmd("say /recruit", "recruit"); register_clcmd("say /rules", "rules"); //fill in the variable we made before... g_Switch = register_cvar("amx_motd","1"); } public motd(id) { //If we have recieved a positive value(either 1 or higher) if(get_pcvar_num(g_Switch)) { show_motd(id, "czero/motd.txt", "Motd"); return; } }


All times are GMT -4. The time now is 22:21.

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