Raised This Month: $ Target: $400
 0% 

Help with creating "Unknown command".


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 10-13-2006 , 23:48   Help with creating "Unknown command".
Reply With Quote #1

Does anyone know what function is called when a user types in a console command that doesn't exist?

Example: If I were to type in "bloog" in the console, the console would read that "bloog" isn't a command, and would call a function that returns the message "Unknown command: bloog".

Either this is not it's own function call and is part of the console's operation, or I can't find it.

The reason I want to do this is to eliminate the console command "kill", which allows players to suicide. I want to give the illusion that the command doesn't exist, so I want to give a function call that gives a message saying that command doesn't exist.

Thanks for any help, I'm new to AMXX, but not to coding (three years).
Bad_Bud is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 10-13-2006 , 23:53   Re: Help with creating "Unknown command".
Reply With Quote #2

http://forums.alliedmods.net/forumdisplay.php?f=27 look at the first couple...
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-14-2006 , 00:18   Re: Help with creating "Unknown command".
Reply With Quote #3

Hook when a user calls suicide, by using the client_kill forward (make a public function named client_kill). Then use console_print to print out the message you want (ie: "Unknown command: kill"), and return PLUGIN_HANDLED to stop the initial kill request from going through.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Old 10-14-2006, 00:32
organizedKaoS
This message has been deleted by organizedKaoS.
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 10-14-2006 , 00:52   Re: Help with creating "Unknown command".
Reply With Quote #4

organizedKaos script will not work because you can't catch the kill command like that. What XxAvalanchexX said is correct. The script below is the one that will work.

Code:
#include <amxmodx> #include <engine> public plugin_init() {         register_plugin("Plugin", "0.0", "Gaben") } public client_kill(id) {     console_print(id, "Unknown command: kill")     return PLUGIN_HANDLED }
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
organizedKaoS
Senior Member
Join Date: Feb 2006
Old 10-14-2006 , 00:57   Re: Help with creating "Unknown command".
Reply With Quote #5

The method I posted:
Code:
#include <amxmodx> public plugin_init()      {      register_plugin(blah blah blah)      register_clcmd("kill", "block_kill") } public block_kill(id)      {      console_print(id, "Unknown command: kill")      return PLUGIN_HANDLED }

EDIT:...My example doesnt work, just tested....thx team06.

Used this method to catch and block the fullupdate command.

I guess fullupdate gets called differently from kill

Last edited by organizedKaoS; 10-14-2006 at 01:07.
organizedKaoS is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 10-14-2006 , 01:19   Re: Help with creating "Unknown command".
Reply With Quote #6

That's not really what I was looking for, sorry if I wasn't specific enough. The examples you posted are exactly like the code I already wrote. The reason I wanted an engine function for it was because say a user got clever and typed in "kIlL", it will still say "Unknown command: kill", because that's what I wrote in. I didn't want to have to mess with storing and checking strings for no reason, because I thought there might just be a function call that would handle it and get it over with, instead of faking it.

I know this is unrelated and might deserve another thread, but I was also looking to use "set_user_deaths" in The Specialists, but the compiler can't find the function, even though I have already included amxmodx, amxmisc, fun, tsx, tsfun, fakemeta ,engine. I see other people asking about this on the forums, but I never really saw a solution. Usually people just said "include fun", or something, and it seemed to fix the problem.

The takedamage function can't be found either...

Last edited by Bad_Bud; 10-14-2006 at 01:36.
Bad_Bud is offline
Old 10-14-2006, 01:22
Bad_Bud
This message has been deleted by Bad_Bud. Reason: Reducing amount of posts
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-15-2006 , 15:12   Re: Help with creating "Unknown command".
Reply With Quote #7

Quote:
Originally Posted by Bad_Bud View Post
That's not really what I was looking for, sorry if I wasn't specific enough. The examples you posted are exactly like the code I already wrote. The reason I wanted an engine function for it was because say a user got clever and typed in "kIlL", it will still say "Unknown command: kill", because that's what I wrote in. I didn't want to have to mess with storing and checking strings for no reason, because I thought there might just be a function call that would handle it and get it over with, instead of faking it.
There is really no engine function for it... the game just checks if the command they entered is valid, and if not tells them it isn't. But since kill really is valid, we have to override it. If you want it outputted back using the same case that they used, use this:

Code:
#include <amxmodx> public client_command(id) {      new command[32];      read_argv(0,command,31);      if(equali(command,"kill"))      {           console_print(id,"Unknown command: %s",command);           return PLUGIN_HANDLED;      }      return PLUGIN_CONTINUE; }

Quote:
Originally Posted by Bad_Bud View Post
I know this is unrelated and might deserve another thread, but I was also looking to use "set_user_deaths" in The Specialists, but the compiler can't find the function, even though I have already included amxmodx, amxmisc, fun, tsx, tsfun, fakemeta ,engine. I see other people asking about this on the forums, but I never really saw a solution. Usually people just said "include fun", or something, and it seemed to fix the problem.
set_user_deaths seems to have dissappeared. Hmm...

Quote:
The takedamage function can't be found either...
There is no "takedamage" function?
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 10-15-2006 , 19:52   Re: Help with creating "Unknown command".
Reply With Quote #8

+Karma, thanks for the input. Also, thanks for writing TalkZone, it was much easier to understand in helping me learn AMXX as opposed to Twilight's TalkArea[S2]...

And no, there is no takedamage function. Don't know why.

By the way, here's how I did it. This method also let me use a smaller string.

Code:
 
public client_kill(id)
{
 new Command[5]
 
 read_argv(0,Command,4)
 
 if(get_cvar_num("rp_allowsuicide")==0)
 {
  console_print(id,"Unknown command: %s",Command)
 }
 else
 {
  //Kills the player and reduces their score by 1.
  user_kill(id,0)
 }
 return PLUGIN_HANDLED
}

Last edited by Bad_Bud; 10-15-2006 at 19:55.
Bad_Bud is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-15-2006 , 20:22   Re: Help with creating "Unknown command".
Reply With Quote #9

That will not work for two reasons:

1) It will block every command if rp_allowsuicide is 0
2) It will kill a player everytime they execute a command if rp_allowsuicide is anything other than 0.

Use Avalanche's or teame06's code.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 10-15-2006 , 20:45   Re: Help with creating "Unknown command".
Reply With Quote #10

What are you talking about? It works just fine.
Bad_Bud 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 04:55.


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