Raised This Month: $32 Target: $400
 8% 

"Unknown command" Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AuricYoutube
Senior Member
Join Date: Aug 2016
Location: Here
Old 01-29-2020 , 07:03   "Unknown command" Plugin
Reply With Quote #1

I want a plugin that detects when people try typing commands that don't exist on the server, I think it could check if a player's message starts with ! or / and if the command after it doesn't exist, it prints a message to the player.

For example:

Player: !ip
Unknown Command, please see available commands in !help.
AuricYoutube is offline
dustinandband
Senior Member
Join Date: May 2015
Old 01-30-2020 , 01:44   Re: "Unknown command" Plugin
Reply With Quote #2

Here are the steps you'd take:

1) Add a command listener (AddCommandListener) for "say" and "say_team"
2) Check the first character of the string for '!' or '/'
3) If IsChatTrigger() returns false on your string, you can print out a message and return Plugin_Handled
dustinandband is offline
AuricYoutube
Senior Member
Join Date: Aug 2016
Location: Here
Old 01-30-2020 , 05:39   Re: "Unknown command" Plugin
Reply With Quote #3

Lol I tried I swear. I can't figure out how to do it. This is what I have so far though.

Quote:
#include <sourcemod>

public OnPluginStart()
{
AddCommandListener(Command_Say, "say");
AddCommandListener(Command_Say, "say_team");
}

public Action:Command_Say(client, const String:command[], argc){
new String:text[16];
new String:cmd[16];

GetCmdArg(0, cmd, sizeof(cmd));

if (GetCmdArg(1, text, sizeof(text)) < 1)
return Plugin_Continue;

StripQuotes(text);

new bool:IsChatTrigger;

if (text[0] == '!')
return Plugin_Continue;
else if (text[0] == '/')
return Plugin_Continue;
else
return Plugin_Handled;

if (IsChatTrigger() == false)
{
PrintToChat(client, "Unknown Command.")
}
return Plugin_Handled;
}
These are the errors the compiler is giving me

Quote:
unknown.sp(20) : warning 217: loose indentation
// C:\timer\csgo\addons\sourcemod\scripting\unkn own.sp(20) : warning 219: local variable "IsChatTrigger" shadows a variable at a preceding level
// C:\timer\csgo\addons\sourcemod\scripting\unkn own.sp(22) : warning 217: loose indentation
// C:\timer\csgo\addons\sourcemod\scripting\unkn own.sp(29) : warning 225: unreachable code
// C:\timer\csgo\addons\sourcemod\scripting\unkn own.sp(29) : error 012: invalid function call, not a valid address
// C:\timer\csgo\addons\sourcemod\scripting\unkn own.sp(29) : error 029: invalid expression, assumed zero
// C:\timer\csgo\addons\sourcemod\scripting\unkn own.sp(29) : warning 215: expression has no effect
// C:\timer\csgo\addons\sourcemod\scripting\unkn own.sp(29) : error 001: expected token: ";", but found ")"
// C:\timer\csgo\addons\sourcemod\scripting\unkn own.sp(29) : fatal error 190: too many error messages on one line
I btw I found base for this code here: https://forums.alliedmods.net/showthread.php?t=229717

Last edited by AuricYoutube; 01-30-2020 at 05:39. Reason: forgot link
AuricYoutube is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 01-30-2020 , 05:43   Re: "Unknown command" Plugin
Reply With Quote #4

Just remove the "new bool:IsChatTrigger;" part, should compile (don't know if it will achieve what you want)
__________________

Last edited by Marttt; 01-30-2020 at 05:44.
Marttt is offline
AuricYoutube
Senior Member
Join Date: Aug 2016
Location: Here
Old 01-30-2020 , 08:29   Re: "Unknown command" Plugin
Reply With Quote #5

It compiles but doesn't work
AuricYoutube is offline
dustinandband
Senior Member
Join Date: May 2015
Old 01-30-2020 , 10:24   Re: "Unknown command" Plugin
Reply With Quote #6

Returning Plugin_Handled blocks the action - while Plugin_Continue lets the action go on.
If you return Plugin_Continue though the rest of the function isn't going to get executed - it's just going to let the game event get broadcasted.

so these parts need to be rewritten:
PHP Code:
if (text[0] == '!')
        return 
Plugin_Continue
example

Spoiler
dustinandband is offline
Reply


Thread Tools
Display Modes

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 18:42.


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