Raised This Month: $ Target: $400
 0% 

[help] motd and client_cmd


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 12-30-2008 , 14:42   Re: [help] motd and client_cmd
Reply With Quote #2

I added some comments. Some were obvious optimizations and some were potential fixes:

Code:
////////////////////////////////////////////////////////////////////////////////// // // Information: // This will help your visitors to set there rates right // All users can say /rates or !rates in chat and they will get a help screen // with more info. // Both txt files goes to the server root, where ie. server.cfg is found // ////////////////////////////////////////////////////////////////////////////////// // // Thanks to: // Vet for show motd metode and txt file both taken from // <a href="http://forums.alliedmods.net/showthread.php?p=541168" target="_blank" rel="nofollow noopener">http://forums.alliedmods.net/showthread.php?p=541168</a> // ////////////////////////////////////////////////////////////////////////////////// // // Changelog: // ////////////////////////////////////////////////////////////////////////////////// #include <amxmodx> #include <amxmisc> #include <dodx> #define PLUGIN  "DoD Rate fixer" #define AUTHOR  "Dr.G - www.clan-go.net" #define VERSION "1.0" //NEW RATES Fit on most clients #define RATE1   "cl_cmdrate 80" #define RATE2   "cl_updaterate 80" #define RATE3   "net_graph 3" #define RATE4   "net_graphwidth 300" #define RATE5   "cl_rate 9999" #define RATE6   "rate 20000" //DEFAULT RATES Taken from config.cfg #define D_RATE1 "cl_cmdrate 30" #define D_RATE2 "cl_updaterate 20" #define D_RATE3 "net_graph 0" #define D_RATE4 "net_graphwidth 0" #define D_RATE5 "cl_rate 0" #define D_RATE6 "rate 20000" //pointers new p_enable, p_timeacmsg, p_joinmsg, p_cycleinfo, p_infotime public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_cvar("dod_rate_fixer_stats", VERSION, FCVAR_SERVER|FCVAR_SPONLY)     /* This is bad practice; register it twice (once for say_team and        once for say) and do everything in one function */     register_clcmd("say","sayEvent1")     register_clcmd("say_team","sayEvent1")     register_clcmd("say","sayEvent2")     register_clcmd("say_team","sayEvent2")     register_clcmd("say","sayEvent3")     register_clcmd("say_team","sayEvent3")     register_clcmd("say","sayEvent4")     register_clcmd("say_team","sayEvent4")         p_enable = register_cvar("dod_rate_fix","1")            //Plugin on/off | 1=on 0=off     p_joinmsg = register_cvar("dod_rate_fix_joinmsg","0")       //Turns info message on/off | 1=on 0=off     p_timeacmsg = register_cvar("dod_rate_fix_msg_delay","30")  //Amount of time in sec. before info msg are shown     p_cycleinfo = register_cvar("dod_rate_fix_loop_info", "0")  //Loop info msg | 1=on 0=off     p_infotime = register_cvar("dod_rate_fix_set_info_time", "600") //Time in sec before info msg is showen again 600 is 10 min :)         //thx vet     // check if files exisits     /* Repeat of a check. Also, cache the string "rate_help.txt" by        making it a global variable */     if(!file_exists("rate_help.txt"))         set_fail_state("[DoD Rate fixer]rate_help.txt does not exsist!")     if(!file_exists("rate_help.txt"))         set_fail_state("[DoD Rate fixer]rate_tut.txt does not exsist!")         // Loop info if p_cycleinfo is 1     /* Unnecessarily complex check. You can remove the "== 1" part        and it will have the exact same effect */     if(get_pcvar_num(p_cycleinfo) == 1)         set_task(get_pcvar_float(p_infotime),"ShowMsg1",id,"",0,"b")     } public client_putinserver(id) {       if(!is_user_bot(id) && get_pcvar_num(p_enable) && is_user_connected(id) && get_pcvar_num(p_joinmsg) == 1)     {         set_task(get_pcvar_float(p_timeacmsg),"ShowMsg",id)     }     return PLUGIN_CONTINUE } public ShowMsg(id) {       if(!is_user_bot(id) && is_user_connected(id))         client_print(id, print_chat, "[DoD Rate fixer] Need help to fix your rates? say /rates in chat to see more info about this..")     return PLUGIN_CONTINUE } public ShowMsg1(id) {       if(!is_user_bot(id) && is_user_connected(id))         client_print(0, print_chat, "[DoD Rate fixer] Need help to fix your rates? say /rates in chat to see more info about this..")     return PLUGIN_CONTINUE } public sayEvent1(id) {     new said[32]     read_args(said,31)     remove_quotes(said)     /* Try adding a trim call here: trim(said) */         if((equali(said, "/rates")) || (equali(said, "!rates")))     {         /* Is this file in the root? i.e. cstrike/rate_help.txt? If not,            put it there */         show_motd(id, "rate_help.txt","[DoD Rate fixer] Help screen")         return PLUGIN_CONTINUE             }     return PLUGIN_CONTINUE } public sayEvent2(id) {     new said[32]     read_args(said,31)     remove_quotes(said)     /* Try adding a trim call here: trim(said) */         if((equali(said, "/fixmyrates")) || (equali(said, "!fixmyrates")))     {         client_cmd(id,RATE1)         client_cmd(id,RATE2)         client_cmd(id,RATE3)         client_cmd(id,RATE4)         client_cmd(id,RATE5)         client_cmd(id,RATE6)         client_print(id, print_chat, "[DoD Rate fixer] Your rates is now set!")         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE } public sayEvent3(id) {     new said[32]     read_args(said,31)     remove_quotes(said)     /* Try adding a trim call here: trim(said) */         if((equali(said, "/ratetut")) || (equali(said, "!ratetut")))     {         show_motd(id, "rate_tut.txt","dodplugins.net")         dod_user_kill(id) //kill without death added to score         client_cmd(id,"jointeam","3") // join spec         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE     } public sayEvent4(id) {     new said[32]     read_args(said,31)     remove_quotes(said)     /* Try adding a trim call here: trim(said) */         if((equali(said, "/defaultrates")) || (equali(said, "!defaultrates")))     {         client_cmd(id,D_RATE1)         client_cmd(id,D_RATE2)         client_cmd(id,D_RATE3)         client_cmd(id,D_RATE4)         client_cmd(id,D_RATE5)         client_cmd(id,D_RATE6)         client_print(id, print_chat, "[DoD Rate fixer] Your rates is now set to default!")         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE }
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
 



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 09:17.


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