Blockland Forums > Modification Help

Simple Coding Question

Pages: (1/2) > >>

WaterSpear:

I was jut wondering how to script out something say along these lines:
"on this chat message" (non-case-sensitive, and non-punctuation sensitive) "do this console command"

Anyone? I know the non-case-sensitive, and the non-punctuation sensitive might make everything complicated but still?

Fluff-is-back:

You can package the clientCmdChatMessage function.

for example:

--- Code: ---package chatListener
{
function clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg)
{
parent::clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg);

if(%msg $= "Phrase here.")
doStuff();
}
};

--- End code ---

This is client sided and will work for anyone who says the phrase.
EDIT: This is not case sensitive, but is punctuation sensitive.

RedGajin:


--- Quote from: Fluff-is-back on August 14, 2011, 04:05:54 AM ---You can package the clientCmdChatMessage function.

for example:

--- Code: ---package chatListener
{
function clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg)
{
parent::clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg);

if(%msg $= "Phrase here.")
doStuff();
}
};

--- End code ---

This is client sided and will work for anyone who says the phrase.
EDIT: This is not case sensitive, but is punctuation sensitive.

--- End quote ---
Like that old stuffty ass greetbot.
God, those things are annoying.

Placid:


--- Quote from: RedGajin on August 14, 2011, 06:42:01 AM ---Like that old stuffty ass greetbot.
God, those things are annoying.

--- End quote ---
actually no, the "old" stuffty ass greetbot is packaging a function that is called whenever a line is written to the client, not when a chat message is written to the client
i believe it was something like NMHtype::newLine or something

RockHammer:

Thanks Guys, so:
package chatListener
{
   function clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg)
   {
      parent::clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg);
      
      if(%msg $= "Hello")
         commandtosserver('messagesent', "Hello");
   }
};

Would do the thingy, ok, so how to I "Activate" the package and make it working?
and BTW thx for the help, and this is waterspear, but I got banned for no reason.

Pages: (1/2) > >>

Go to full version