Raised This Month: $ Target: $400
 0% 

[TF2] Complex Command Question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoRRageBoy
BANNED
Join Date: Jul 2011
Old 09-05-2011 , 12:51   [TF2] Complex Command Question
Reply With Quote #1

What I'm looking to do is create a command that activates when a player says a certain thing in chat. But I want it to consist of one single command that can be triggered through several different chat command options, and I also want to have each different chat command option do something different.

I used to know how to do this, but it's been awhile since I've done any major coding and I've completely forgotten how to do what I'm trying to do.

Here's the command I have so far (not shown: the DisplayPage function)
PHP Code:
public Action:CommandInfo(clientargs)
{
    
decl String:strUrl[1024];
    
Format(strUrlsizeof(strUrl), "%s1.html"INFO_URL);
    
DisplayPage(clientstrUrl);
    
    return 
Plugin_Handled;

I've already got the INFO_URL define set up, I've got the DisplayPage function set up as well.

From here, I want this command to be triggered by the following (example) triggers:

- !info 1
- !info 2
- !info 3

And based on which of the 3 triggers a player says, the function of the command will change, as such:

!info 1
PHP Code:
decl String:strUrl[1024];
Format(strUrlsizeof(strUrl), "%s1.html"INFO_URL);
DisplayPage(clientstrUrl); 
!info 2
PHP Code:
decl String:strUrl[1024];
Format(strUrlsizeof(strUrl), "%s2.html"INFO_URL);
DisplayPage(clientstrUrl); 
!info 3
PHP Code:
decl String:strUrl[1024];
 
Format(strUrlsizeof(strUrl), "%s3.html"INFO_URL);
DisplayPage(clientstrUrl); 
As you can see, the "Format(strUrl, sizeof(strUrl), "%s1.html", INFO_URL);" line changes for each trigger. "!info 1" would load up the 1.html page of the defined INFO_URL site. "!info 2" would load up the 2.html page, and so forth.


How would I go about accomplishing this? I can't quite remember and it's bugging the hell out of me.
GoRRageBoy is offline
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 09-05-2011 , 12:56   Re: [TF2] Complex Command Question
Reply With Quote #2

http://docs.sourcemod.net/api/index....d=show&id=473&
__________________
einmal mit profis arbeiten. einmal.
Thrawn2 is offline
GoRRageBoy
BANNED
Join Date: Jul 2011
Old 09-05-2011 , 13:48   Re: [TF2] Complex Command Question
Reply With Quote #3

Oh wait, I found what I had forgotten:

PHP Code:
public Action:Say(clientargs)
{
    if(
IsValidClient(client))
    {
        new 
String:message[192];
        
GetCmdArgString(messagesizeof(message));
        
StripQuotes(message);

        if(
StrEqual(message"<trigger goes here>"))
        {
            <Function 
goes here>
        }
    }

GoRRageBoy is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 09-05-2011 , 13:52   Re: [TF2] Complex Command Question
Reply With Quote #4

Nope.

PHP Code:
RegConsoleCmd("sm_triggergoeshere"Command_SomeCommand"Description of command); 
That will make triggers !triggergoeshere and /triggergoeshere. Don't hook chat for triggers. Make your own command with a sm_ prefix and sourcemod will make the triggers for you.
__________________
[my plugins]

When you think about asking a question... consider what have you tried?
Antithasys is offline
GoRRageBoy
BANNED
Join Date: Jul 2011
Old 09-05-2011 , 14:06   Re: [TF2] Complex Command Question
Reply With Quote #5

Quote:
Originally Posted by Antithasys View Post
Nope.

PHP Code:
RegConsoleCmd("sm_triggergoeshere"Command_SomeCommand"Description of command); 
That will make triggers !triggergoeshere and /triggergoeshere. Don't hook chat for triggers. Make your own command with a sm_ prefix and sourcemod will make the triggers for you.
That Say command thing is what I was using for quite awhile for simple things.

Obviously I know how to register console/admin commands, but when it came to things like coding in various panels that could be triggered to appear via a small phrase in chat, I'd use the Say command thing, then just add as many of those message things as needed, and it would reduce the amount of actual Console/Admin commands in my plugin(s) quite a lot.
GoRRageBoy is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 09-05-2011 , 14:10   Re: [TF2] Complex Command Question
Reply With Quote #6

But none of the would trigger on the function IsChatTrigger() cause they are not property registered.
__________________
[my plugins]

When you think about asking a question... consider what have you tried?
Antithasys is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 09-06-2011 , 20:37   Re: [TF2] Complex Command Question
Reply With Quote #7

It would also stop your plugin getting approved should it be released.
__________________
asherkin 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 13:50.


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