x


Network Chat not sending messages to other clients

I'm having a problem where my network chat script isn't sending the messages for to or from other players. :/ here is the script -

var             mySkin : GUISkin;
var             userName : String;

private var     windowRectT = Rect (10,310,700,20);
var             scrollViewVector : Vector2;
private var     outputText : String = "";
private var     inputText : String = "";

function OnGUI () {
if(networkView.isMine){
    GUI.skin = mySkin;
    windowRectT = GUILayout.Window (0, windowRectT,ChatWindow, "Chat");
}
}
function ChatWindow () {
 GUILayout.Label ("User Name:");
 userName = GUILayout.TextField (userName);
 GUILayout.Label("Message: "); 
 scrollViewVector = GUILayout.BeginScrollView (scrollViewVector);
 GUILayout.TextArea (outputText);
 GUILayout.EndScrollView();
 GUILayout.Label ("Chat:");
 inputText = GUILayout.TextField (inputText); 
    if (GUILayout.Button ("Send")) {
        networkView.RPC ("SendChat", RPCMode.All, userName + ": " + inputText);
        inputText = "";
    }
    GUI.DragWindow (Rect (0,0,1000,1000));
 }
@RPC
function SendChat (text : String) { 
if(networkView.isMine)
{
Debug.Log("chat sent!!!");
    outputText += (text + "\n"); 
}    
}

Thanks for the help everyone!

(Anyone can feel free to use this in there game if needed as a base code for chat, but if you find a fix please post it. Thanks!)

more ▼

asked Jan 26 '12 at 12:33 AM

twoface262 gravatar image

twoface262
129 40 52 55

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3739
x3460
x702
x237
x58

asked: Jan 26 '12 at 12:33 AM

Seen: 655 times

Last Updated: Jan 26 '12 at 12:48 AM