AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Check client command (https://forums.alliedmods.net/showthread.php?t=87587)

biscuit628 03-14-2009 02:02

Check client command
 
how to check a client command?
example..
i want to know player have or haven't a command call "Apple"
now..i put this in my code..
PHP Code:

client_cmd(id,Apple

then
Check PlayerA , PlayerA doesn't have the command, so he get "Unknow Command" in the console //true
Check PlayerB , PlayerB has the command,but it is nothing in the value <Apple ""> //false
Check PlayerC , PlayerC has the command, and the value is<Apple "Orange">//false
how can i get true or false?

sorry for my very very poor english..

TheRadiance 03-14-2009 02:14

Re: Check client command
 
PHP Code:

register_clcmd"Apple""CommandApple" )

public 
CommandAppleid )
    return 
PLUGIN_HANDLED 

Also this should help you:
PHP Code:

query_client_cvar(id, const cvar[], const resultFunc[], paramlen=0, const params[] = ""


danielkza 03-14-2009 03:01

Re: Check client command
 
If you mean checking client's aliases, you can't, otherwise, client commands are handled server-side, with a few exceptions (connect, disconnect, etc)

Hunter-Digital 03-14-2009 18:02

Re: Check client command
 
It actually is possible... I made this check with statsme a long time ago... you CAN check whenever a player uses an unknown command but CANNOT check if a player has a command that is aliased... or... you could... by sending it and expect unknown command, if you receive it, it's not set, if not, it's aliased :lol:

don't really remember how I did it tough, I'll search through my old scripts and see what I can find :P

EDIT:
yeah, was something like hooking TextMsg and checking argument 2 with "#Game_unknown_command"... or something :lol: :P

EDIT #2: tested a code and works, gets user ID and the unknown command sent:
PHP Code:

#include <amxmodx>
 
public plugin_init()
{
    
register_event("TextMsg""hook_textMsg""b""2=#Game_unknown_command")
}
 
public 
hook_textMsg(idmsg[], cmd[])
{
    
client_print(0print_chat"%d - unknown command: %s"idcmd)
 
    return 
PLUGIN_CONTINUE



biscuit628 03-16-2009 09:29

Re: Check client command
 
Quote:

Originally Posted by Hunter-Digital (Post 780611)
It actually is possible... I made this check with statsme a long time ago... you CAN check whenever a player uses an unknown command but CANNOT check if a player has a command that is aliased... or... you could... by sending it and expect unknown command, if you receive it, it's not set, if not, it's aliased :lol:
...

Thank!,but i got some problem
i compile the code
PHP Code:

#include <amxmodx>
#include <amxmisc>


public plugin_init() {
    
register_plugin("New Plug-In""1.0""Administrator")
    
register_event("TextMsg""hook_textMsg""b""2=#Game_unknown_command")
}

public 
client_putinserver(id)
{
    
client_cmd(id,"Apple")
}
public 
hook_textMsg(idmsg[], cmd[])
{
    new 
name[30]
    
get_user_name(id,name,29)
    
server_print("%s - unknown command: %s"namecmd)
    return 
PLUGIN_CONTINUE


when PlayerA use the unknowcommand,it's print the msg "PlayerA - unknow command: New Plug-In":cry:

Owyn 03-16-2009 12:53

Re: Check client command
 
and to me it says ""PlayerA - unknow command: textMsg"

ps - so with hlguard on this thing gonna spam like hell? =\

but it works, lol at people who said it is impossible to see what is going on in player's console +_+

SnoW 03-16-2009 13:17

Re: Check client command
 
Quote:

Originally Posted by .Owyn. (Post 781963)
but it works, lol at people who said it is impossible to see what is going on in player's console +_+

Can't see any, at least not in this thread.

danielkza 03-16-2009 17:23

Re: Check client command
 
Why not just register_clcmd() the command, and run it using client_cmd? If the callback is executed the command is not aliased, if it's not, it is.

Hunter-Digital 03-17-2009 05:53

Re: Check client command
 
that's odd... when I tested that code it worked :| showed my player ID and the command sent... now it doesn't... zomfg :|

Owyn 03-20-2009 10:06

Re: Check client command
 
i think it needs a read_data() func to show unknown command


All times are GMT -4. The time now is 08:55.

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