How do Client receive message from sever?
by Jabawork · in Torque Game Engine · 08/19/2006 (2:18 am) · 4 replies
This is a noob question.
I was wondering how client receive message from sever when I use messageClient() function?
Can anyone answer me please? Thx!
I was wondering how client receive message from sever when I use messageClient() function?
Can anyone answer me please? Thx!
About the author
#2
Sorry, working on English by now.
08/19/2006 (11:26 am)
"How the function and call to it need to be configured" :pSorry, working on English by now.
#3
On the server, use a line of code like this:
Then on the client, this invokes a function called clientCmdDoSomething:
In my example, I have sent 2 arguments to the client: %arg1 receives the value "hello" and %arg2 receives the value 1.2
A very useful construct for invoking a function on all clients is:
Here I'm telling all connected clients about the arrival of an NPC gang into one of my game's timetrial events
Hope that helps...
08/19/2006 (12:13 pm)
First of all you need to have a reference to the client's GameConnection object, call it %clientOn the server, use a line of code like this:
commandToClient(%client, 'DoSomething', "hello", 1.2);
Then on the client, this invokes a function called clientCmdDoSomething:
function clientCmdDoSomething(%arg1, %arg2) {
// code in here...
}In my example, I have sent 2 arguments to the client: %arg1 receives the value "hello" and %arg2 receives the value 1.2
A very useful construct for invoking a function on all clients is:
for( %i = 0; %i < ClientGroup.getCount(); %i++ ) {
%cl = ClientGroup.getObject(%i);
commandToClient(%cl, 'NPCGangArrival', %name);
}Here I'm telling all connected clients about the arrival of an NPC gang into one of my game's timetrial events
Hope that helps...
#4
08/20/2006 (12:52 am)
This helps alot! Thank you!
Torque Owner Sam Redfern
-- how the function and call to it need to be configured?
-- how does it happen in the engine?
-- how TCP works? ;-)