Raised This Month: $ Target: $400
 0% 

register_clcmd with parameter? [SOLVED]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
James
Senior Member
Join Date: Dec 2004
Old 12-11-2006 , 16:16   register_clcmd with parameter? [SOLVED]
Reply With Quote #1

Hello, can I somehow add parameter to register_clcmd command? I want one function (with parameter), which will be called by more register_clcmds.. Like change map...

Now I must copy 2 same function (with different mapname)
register_clcmd("say /cbble", "cmd_cbble", 0, "- changelevel de_cbble")
register_clcmd("say /cpl_mill", "cmd_cpl_mill", 0, "- changelevel de_cpl_mill")


I would like something like this:
register_clcmd("say /cbble", "cmd_changemap('cbble')", 0, "- changelevel de_cbble")
register_clcmd("say /cpl_mill", "cmd_changemap('mill')", 0, "- changelevel de_cpl_mill")

cmd_changemap(id,name[]) {
...
}

Much cleaner code.. Any help please?

Last edited by James; 12-11-2006 at 19:22.
James is offline
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 12-11-2006 , 16:30   Re: register_clcmd with parameter?
Reply With Quote #2

for say command you can use the say event here an code example
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "Administrator" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("say", "handle_say") } public handle_say(id){ new nums = read_argc()//read_argc return how many parameter are given in the say client_print(id,print_chat,"You have say %d commands/parameter",nums) for (new i = 1; i < read_argc(); i++) {         new command[32]         read_argv(i, command, 31) //read_argv read the i parameter and store it into command         client_print(id,print_chat,"You %d paramter is %s",i,command)     } new say[128] read_args(say,127) //read_args return the fully string who was say client_print(id,print_chat,"You fully say is: %s",say) }
__________________
schnitzelmaker is offline
James
Senior Member
Join Date: Dec 2004
Old 12-11-2006 , 16:35   Re: register_clcmd with parameter?
Reply With Quote #3

Interesting, I will try it!
James is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 12-11-2006 , 16:39   Re: register_clcmd with parameter?
Reply With Quote #4

Try this:

Code:
register_clcmd("say","cmd_changemap") register_clcmd("say_team","cmd_changemap") cmd_changemap(id){ new said[191] read_args(said,190) remove_quotes(said) if(equali(said,"/cbble")){ server_cmd("changelevel de_cbble") return PLUGIN_HANDLED //Do not show the text that has been said,pointless }else if(equali(said,"/cpl_mill")){ server_cmd("changelevel de_cpl_mill") return PLUGIN_HANDLED //Dito } return PLUGIN_CONTINUE }
__________________
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.
dutchmeat is offline
James
Senior Member
Join Date: Dec 2004
Old 12-11-2006 , 16:47   Re: register_clcmd with parameter?
Reply With Quote #5

I see only way is controll every say text in the game :/ Dont know if it is good solution (many say texts in PUB servers) ... I trying keep CPU usage lowest as possible
James is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 12-11-2006 , 16:52   Re: register_clcmd with parameter?
Reply With Quote #6

then use this;
for admin_kick only,

Code:
register_clcmd("say","cmd_changemap") register_clcmd("say_team","cmd_changemap") cmd_changemap(id){ if(!access(id, ADMIN_KICK))  return PLUGIN_CONTINUE //let the msg go, if not an admin new said[191] read_args(said,190) remove_quotes(said)  if(equali(said,"/cbble")){   server_cmd("changelevel de_cbble")   return PLUGIN_HANDLED //Do not show the text that has been said,pointless  }else if(equali(said,"/cpl_mill")){   server_cmd("changelevel de_cpl_mill")   return PLUGIN_HANDLED //Dito  } return PLUGIN_CONTINUE }
__________________
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.
dutchmeat is offline
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 12-11-2006 , 17:32   Re: register_clcmd with parameter?
Reply With Quote #7

Quote:
I see only way is controll every say text in the game :/ Dont know if it is good solution (many say texts in PUB servers) ... I trying keep CPU usage lowest as possible
you can also use only
Code:
register_clcmd("say /cbble", "handle_say", 0, "- changelevel de_cbble") register_clcmd("say /cpl_mill", "handle_say", 0, "- changelevel de_cpl_mill")
to sort it out.

But it is the same to sort it in the say function or in register_clmd.
__________________

Last edited by schnitzelmaker; 12-11-2006 at 17:36.
schnitzelmaker is offline
James
Senior Member
Join Date: Dec 2004
Old 12-11-2006 , 17:34   Re: register_clcmd with parameter?
Reply With Quote #8

Yeah.. Sometimes I think I am stupid

Problem solved, code is cleaner, ADMIN acces, say /command, and then controll say by handle_say.. Thanks a Lot! Karma +

Last edited by James; 12-11-2006 at 19:21.
James is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 12-12-2006 , 07:57   Re: register_clcmd with parameter? [SOLVED]
Reply With Quote #9

Quote:
I trying keep CPU usage lowest as possible
FYI: the metod above isn't CPU intensive.
VEN 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 06:57.


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