Raised This Month: $ Target: $400
 0% 

[help] motd and client_cmd


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dr.G
Senior Member
Join Date: Nov 2008
Old 12-30-2008 , 12:13   [help] motd and client_cmd
Reply With Quote #1

Well something went wrong here, but i cant see what/how, and since its basic coding its even more odd to me, but iam still new with this tho.

The first problem is that the motd is showing, 2nd the /fixmyrates doesnt do anything either



PHP Code:
//NEW RATES 
#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"
 
public plugin_init()
{
 
register_clcmd("say","sayEvent1")
 
register_clcmd("say_team","sayEvent1")
 
register_clcmd("say","sayEvent2")
}
 
public 
sayEvent1(id)
{
 new 
said[32
 
read_args(said,31)
 
remove_quotes(said)
 
 if((
equali(said"/rates")) || (equali(said"!rates"))) 
 {
 
  
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)
 
 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(idprint_chat"[DoD Rate fixer] Your rates is now set!")
  return 
PLUGIN_CONTINUE
 

 return 
PLUGIN_CONTINUE

The sma file attached it the full code....

Thanks in advance
__________________

Last edited by Dr.G; 03-11-2009 at 09:28.
Dr.G is offline
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
Dr.G
Senior Member
Join Date: Nov 2008
Old 12-31-2008 , 07:29   Re: [help] motd and client_cmd
Reply With Quote #3

Thanks alot Hawk! I hope ive done it as it should be now Now it goes like this but still no cigar :/ Any ideas why the motd and cmds arent showen/used?

PHP 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
// http://forums.alliedmods.net/showthread.php?p=541168
//
// BIG thanks to Hawk552 @ allied modders!
//
//////////////////////////////////////////////////////////////////////////////////
//
// Changelog:
// 12/30 08 - Code clean up! Thanks to Hawk552
//
//////////////////////////////////////////////////////////////////////////////////
#include <amxmodx>
#include <amxmisc>
#include <dodx>
#define PLUGIN "DoD Rate fixer"
#define AUTHOR "Dr.G - www.clan-go.net"
#define VERSION "1.1"
//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 150"
#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"
//FILES
#define HELP "rate_help.txt"
#define HELPURL "rate_tut.txt"
//pointers
new p_enablep_timeacmsgp_joinmsgp_cycleinfop_infotime
public plugin_init()
{
 
register_plugin(PLUGINVERSIONAUTHOR)
 
register_cvar("dod_rate_fixer_stats"VERSIONFCVAR_SERVER|FCVAR_SPONLY)
 
register_clcmd("say","sayEvent")
 
register_clcmd("say_team","sayEvent")
 
 
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
 
if(!file_exists(HELP))
  
set_fail_state("[DoD Rate fixer]rate_help.txt does not exsist!")
 if(!
file_exists(HELPURL))
  
set_fail_state("[DoD Rate fixer]rate_tut.txt does not exsist!")
 
 
// Loop info if p_cycleinfo is 1
 
if(get_pcvar_num(p_cycleinfo))
  
set_task(get_pcvar_float(p_infotime),"ShowMsg1",0,"",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))
 {
  
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(idprint_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()

 
client_print(0print_chat"[DoD Rate fixer] Need help to fix your rates? say /rates in chat to see more info about this..")
 return 
PLUGIN_CONTINUE
}
public 
sayEvent(id)
{
 new 
said[32
 
read_args(said,31)
 
remove_quotes(said)
 
trim(said)
 
 if((
equali(said"/rates")) || (equali(said"!rates"))) 
 {
 
  
show_motd(idHELP,"[DoD Rate fixer] Help screen")
  return 
PLUGIN_CONTINUE
 
 
}
 
 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(idprint_chat"[DoD Rate fixer] Your rates is now set!")
  return 
PLUGIN_CONTINUE
 

 
 if((
equali(said"/ratetut")) || (equali(said"!ratetut"))) 
 {
  
show_motd(idHELPURL,"dodplugins.net")
  
dod_user_kill(id//kill without death added to score
  
client_cmd(id,"jointeam","3"// join spec
  
return PLUGIN_CONTINUE
 
}
 
 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(idprint_chat"[DoD Rate fixer] Your rates is now set to default!")
  return 
PLUGIN_CONTINUE
 
}
 return 
PLUGIN_CONTINUE
 

__________________

Last edited by Dr.G; 03-11-2009 at 09:28.
Dr.G is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 12-31-2008 , 15:27   Re: [help] motd and client_cmd
Reply With Quote #4

Try using containi and also make it print out the message using client_print (just so you can see what's going on).
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Dr.G
Senior Member
Join Date: Nov 2008
Old 12-31-2008 , 21:43   Re: [help] motd and client_cmd
Reply With Quote #5

Illl try that! Thanks!
__________________

Last edited by Dr.G; 12-31-2008 at 22:16.
Dr.G is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 12-31-2008 , 23:22   Re: [help] motd and client_cmd
Reply With Quote #6

Quote:
//////////////////////////////////////////////////////////////////////////////////
//
// 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
// http://forums.alliedmods.net/showthread.php?p=541168
//
// BIG thanks to Hawk552 @ allied modders!
//
//////////////////////////////////////////////////////////////////////////////////
//
// Changelog:
// 12/30 08 - Code clean up! Thanks to Hawk552
// 10/01 09 - containi said - equali said....
//
//////////////////////////////////////////////////////////////////////////////////
#include <amxmodx>
#include <amxmisc>
#include <dodx>
#define PLUGIN "DoD Rate fixer"
#define AUTHOR "Dr.G - www.clan-go.net"
#define VERSION "1.2"
//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 150"
#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"
//FILES
#define HELP "rate_help.txt"
#define HELPURL "rate_tut.txt"
//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)
register_clcmd("say","sayEvent")
register_clcmd("say_team","sayEvent")

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
if(!file_exists(HELP))
set_fail_state("[DoD Rate fixer]rate_help.txt does not exsist!")
if(!file_exists(HELPURL))
set_fail_state("[DoD Rate fixer]rate_tut.txt does not exsist!")

// Loop info if p_cycleinfo is 1
if(get_pcvar_num(p_cycleinfo))
set_task(get_pcvar_float(p_infotime),"ShowMsg 1",0,"",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))
{
set_task(get_pcvar_float(p_timeacmsg),"ShowMs g",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()
{
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 sayEvent(id)
{
new said[32]
read_args(said,31)
remove_quotes(said)
trim(said)

if((containi(said, "/rates")) || (containi(said, "!rates")))
{

show_motd(id, HELP,"[DoD Rate fixer] Help screen")

}

if((containi(said, "/fixmyrates")) || (containi(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!")

}

if((containi(said, "/ratetut")) || (containi(said, "!ratetut")))
{
show_motd(id, HELPURL,"dodplugins.net")
dod_user_kill(id) //kill without death added to score
client_cmd(id,"jointeam","3") // join spec

}

if((containi(said, "/defaultrates")) || (containi(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_HANDLED
}



Still aint doing anything.... It does detect the chat msg tho since its not showen... but thats all..
__________________
Dr.G is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 01-01-2009 , 04:36   Re: [help] motd and client_cmd
Reply With Quote #7

No, you need to use:

Code:
containi(string,phrase) != -1

As each of your conditions. containi() returns 0 when it locates the string starting at the first cell.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
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 09:17.


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