Blockland Forums > Modification Help
Chat Bot Problem
(1/4) > >>
jes00:
I tried the following code and the      if (%name $= "jes00") is not working.


--- Code: ---package chatbot
{
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
{
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
                switch$(%msg)
                {
                        case "Test":
     if (%name $= "jes00")
                               commandToServer('messageSent',"Test: Success!");
                        case "Hi":
                              commandToServer('messageSent',"Hi");
                        case "the muffin smells good!":
                                commandtoserver('messagesent',"It does indeed!");
                        case "Goodbye":
                                commandtoserver('messagesent',"Goodbye.");
                }
}

};
activatePackage(chatbot);
--- End code ---
infiniteLoop:
That is wrong.

this is minus the switch. (I hate switches so much)


--- Code: ---package chatbot
{
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
{
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if(%name $= $pref::Player::NetName)
{
//Writes a line in the console
//so check your console to see
//if it worked
//--------

error("Testing worked.");

//--------
}
}

};
activatePackage(chatbot);
--- End code ---
jes00:

--- Quote from: infiniteLoop on August 02, 2011, 06:34:33 PM ---That is wrong.

this is minus the switch. (I hate switches so much)


--- Code: ---package chatbot
{
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
{
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
if(%name $= $pref::Player::NetName)
{
//Writes a line in the console
//so check your console to see
//if it worked
//--------

error("Testing worked.");

//--------
}
}

};
activatePackage(chatbot);
--- End code ---

--- End quote ---
Umm now I'm just confused.
infiniteLoop:
You have if(%name $= "jes") or whatever, but nothing under it.. and it's just in an awkward spot.

What i wrote is saying * if %name is equal to whatever your current blockland name is, write in the console "Testing worked." *
jes00:

--- Quote from: infiniteLoop on August 02, 2011, 06:42:05 PM ---You have if(%name $= "jes") or whatever, but nothing under it.. and it's just in an awkward spot.

What i wrote is saying * if %name is equal to whatever your current blockland name is, write in the console "Testing worked." *

--- End quote ---
But I only want it to check if it's me in the case of someone saying Test.
Navigation
Message Index
Next page

Go to full version