Raised This Month: $ Target: $400
 0% 

Cvar function on/off help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sav
Junior Member
Join Date: Dec 2006
Old 01-21-2007 , 15:00   Cvar function on/off help
Reply With Quote #1

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

Last edited by Sav; 01-21-2007 at 16:37.
Sav is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 01-22-2007 , 05:29   Re: Cvar function on/off help
Reply With Quote #2

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; } }
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.

Last edited by dutchmeat; 01-22-2007 at 05:29. Reason: forgot to close a bracket
dutchmeat 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 01:37.


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