Raised This Month: $51 Target: $400
 12% 

Can't get chat commands to work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DonshiusLT
New Member
Join Date: Mar 2014
Old 03-22-2014 , 12:32   Can't get chat commands to work
Reply With Quote #1

Hey, I've been trying to get chat commands (/command in chat) to work for quite some time now but all tries have been unsuccessful, I have tried several methods but none of them work.

Firstly, I've been trying to hook into `say` command and using that with the code I found online.
OnPluginStart:
Code:
AddCommandListener(Command_SAY, "say");
And after OnPluginStart:
Code:
public Action:Command_SAY(client, const String:command[], argc)
{
    decl String:text[192];
    new startidx = 0;
    if (GetCmdArgString(text, sizeof(text)) < 1)
    {
        return Plugin_Continue;
    }
 
    if (text[strlen(text)-1] == '"')
    {
        text[strlen(text)-1] = '\0';
        startidx = 1;
    }

    if(strcmp(text[startidx], "/test", false) == 0)
    {
        PrintToChat(client, "TEST");
    }
    return Plugin_Continue;
}
Secondly, I tried using Action:OnClientCommand:
Code:
public Action:OnClientCommand(client, args)
{
    new String:cmd[16];
    GetCmdArg(0, cmd, sizeof(cmd));    /* Get command name */
 
    if(StrEqual(cmd, "test2"))
    {
        PrintToChat(client, "You have executed the command!!!");
        return Plugin_Handled;
    }
    return Plugin_Continue;
}
Any help would be useful.
DonshiusLT is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-22-2014 , 12:44   Re: Can't get chat commands to work
Reply With Quote #2

PHP Code:
public OnPluginStart()
{
    
RegConsoleCmd("sm_test"test);
}

public 
Action:test(clientargs)
{
    
ReplyToCommand(client"You %N, executed this command!"client);

    return 
Plugin_Handled;

Then by default, use in chat input
!test
/test


! = public, everyone can see your command what you typed
/ = silent

Last edited by Bacardi; 03-22-2014 at 12:46. Reason: edit
Bacardi is offline
joac1144
Senior Member
Join Date: Dec 2012
Location: Copenhagen, Denmark
Old 03-22-2014 , 12:57   Re: Can't get chat commands to work
Reply With Quote #3

So, you wanna make your own command?
https://wiki.alliedmods.net/Commands...d_Scripting%29

EDIT: Bacardi was faster
__________________

Last edited by joac1144; 03-22-2014 at 12:59.
joac1144 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 19:23.


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