Question regarding chat-input?

Hi Forum, I’ve been using some of the networking-assets like
chat-javascript, and learning a lot from them, again thanks to anyone who share work online, it helps new comers study code and how-to. But a lil’ ill confused on this, how do I check for a specific string type, and sends a defined message from it. E.g. If someone were to type /smile, then it would send a specific message like “Smiles”.

var skin : GUISkin;

private var inputField = “”;
private var display = true;
private var entries = ArrayList();
private var scrollPosition : Vector2;

private var window = Rect(50, 50, 351, 250);

function OnGUI ()
{
GUI.skin = skin;

window = GUI.Window (1, window, GlobalChatWindow, “”);
}

class ChatEntry
{
var sender = “”;
var text = “”;
var mine = true;
}

function GlobalChatWindow (id : int)
{
scrollPosition = GUILayout.BeginScrollView (scrollPosition);

for (var entry : ChatEntry in entries)
{
GUILayout.BeginHorizontal();

if (!entry.mine)
{
GUILayout.Label (entry.text, “chat_leftaligned”);
GUILayout.FlexibleSpace ();
}
else
{
GUILayout.Label (entry.text, “chat_rightaligned”);
GUILayout.FlexibleSpace ();
}

GUILayout.EndHorizontal();
GUILayout.Space(3);

}

GUILayout.EndScrollView ();

if (
Event.current.type == EventType.keyDown && Event.current.character == "
" && inputField.Length > 0)
{

ApplyGlobalChatText(inputField, 1);
networkView.RPC(“ApplyGlobalChatText”, RPCMode.Others, inputField, 0);
inputField = “”;
}

GUI.SetNextControlName(“Chat input field”);
inputField = GUILayout.TextField(inputField);

GUI.DragWindow();
}

@RPC
function ApplyGlobalChatText (str : String, mine : int)
{
var entry = new ChatEntry();
entry.sender = “Not implemented”;
entry.text = str;
if (mine == 1) entry.mine = true;
else entry.mine = false;

entries.Add(entry);

if (entries.Count > 50)
entries.RemoveAt(0);

scrollPosition.y = 1000000;
}

Don’t know a thing about chat/networking, but based on the code, I’d say adding this:

if ( Event.current.type == EventType.keyDown && Event.current.character == "n" && inputField.Length > 0) {

if(inputField == "/smile")  //add these lines
inputField = "Smile!";

ApplyGlobalChatText(inputField, 1); networkView.RPC("ApplyGlobalChatText", RPCMode.Others, inputField, 0); inputField = ""; }

should give you an idea I think…