Game Development Community

add message to message Hud on client side ??

by Jeff Yaskus · in Torque 3D Beginner · 02/17/2011 (10:30 pm) · 7 replies

This client / server side stuff gets me a bit confused at times.

Its likely very simple, but I can't seem to figure out how to add a message to the chat Hud, from the client side of the engine.

i.e. from within client side scripts.

This works from the server side ...
messageClient(LocalClientConnection.client, 'Hello', "Hello player");

But it would seem very silly to try to send this as a commandToServer ... just to get it to sent it back to the client HUD.

... Whats the easy way to add text to clients hud, from client side??

#1
02/23/2011 (4:44 pm)
Can you be more descriptive of the question? maybe give an example of what you want it to do? im having trouble understanding the big picture here lol
#2
02/23/2011 (5:19 pm)
If you are messaging while the player is joining, that's simple.

Look in "game/core/scripts/server/clientConnections.cs" to see how torque messages the player on enter.
In that file, you'll find 2 different functions for messages the client.
#3
02/23/2011 (5:59 pm)
LocalClientConnection will only return the client on the same box as the server - so you can get away with it in a singleplayer game, but not multiplayer/online.

You need to find the client's ID, and the server knows that, that's why you probably want to use a serverCmd.
#4
02/23/2011 (10:10 pm)
Thanks guys! I was trying to figure out how to basically sent a message to the player chat HUD, from a client side script.

It was to notify the client when their HEALTH dropped, due to lack of warmth / food / water ...

The following solution came to mind after reading Steve's resource on the sample game ... And it does the job, but still its limited to single player only, since it spams it to "all".

centerPrintAll("You are getting hungry ... ",5,1);
#5
02/23/2011 (10:47 pm)
That will print on ALL clients, so again, it's not good for networking/multiplayer - but doesn't matter for single player.
#6
02/23/2011 (11:27 pm)
Yes - same problem as before.

Seems like I ought to be to just run the following from a client side script ... since it would only get called on the client needing the message;

clientCmdCenterPrint( %message, %time, %size );

EDIT: It seems to work great, although have not tried it on multi-player yet.
#7
03/09/2011 (5:42 pm)
oohhh ok i get it now! nice work! glad you got it working =]