AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with creating "Unknown command". (https://forums.alliedmods.net/showthread.php?t=45894)

Bad_Bud 10-13-2006 23:48

Help with creating "Unknown command".
 
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).

Emp` 10-13-2006 23:53

Re: Help with creating "Unknown command".
 
http://forums.alliedmods.net/forumdisplay.php?f=27 look at the first couple...

XxAvalanchexX 10-14-2006 00:18

Re: Help with creating "Unknown command".
 
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.

teame06 10-14-2006 00:52

Re: Help with creating "Unknown command".
 
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 }

organizedKaoS 10-14-2006 00:57

Re: Help with creating "Unknown command".
 
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 :P

Bad_Bud 10-14-2006 01:19

Re: Help with creating "Unknown command".
 
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...

XxAvalanchexX 10-15-2006 15:12

Re: Help with creating "Unknown command".
 
Quote:

Originally Posted by Bad_Bud (Post 390901)
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 (Post 390901)
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?

Bad_Bud 10-15-2006 19:52

Re: Help with creating "Unknown command".
 
+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
}


Zenith77 10-15-2006 20:22

Re: Help with creating "Unknown command".
 
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.

Bad_Bud 10-15-2006 20:45

Re: Help with creating "Unknown command".
 
What are you talking about? It works just fine.


All times are GMT -4. The time now is 04:56.

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