Game Development Community

How to send data from server to client?

by Peder Husom · in Torque 3D Beginner · 05/26/2011 (5:30 am) · 3 replies

Hi

I can't seem to get the grasp of messageAll. Here is my current problem. I want to something like;

messageAll('TeamScoreChanged', %teamId, %teamScore, %teamNumPlayers);

The problem is that the messageAll wants the parameters
%msgType, %msgString, %a1, %a2, .., %aN

So I suppos I should put the 'TeamScoreChanged' in the %msgType? But then what do I put in the %msgString?
I don't want to send a string, just 3 ints.

#1
05/26/2011 (6:04 am)
messageAll('msgTeamScareChanged', 'Score: %1 %3 : %2 %4', %team1, %team2, %team1score, %team2score);

Always start msgType with 'msg'
%1 = first parameter
%2 second
%3 etc

If team1 = blue, team2 = red, team1score = 4, team2score = 2: message prints

Score: Blue 4 : Red 2
#2
05/26/2011 (6:22 am)
Solved it by making my own function

function myMessageAll(%cmd, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10, %a11, %a12, %a13)
{
	for( %cl = 0; %cl < ClientGroup.getCount(); %cl++ )
	{
		commandToClient( ClientGroup.getObject( %cl ) , %cmd , %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10, %a11, %a12, %a13);
	}
}

in the /game/core/scripts/server/message.cs


Only cons I can come up with is that you cant use that addMessageCallback
#3
05/26/2011 (6:31 am)
Either re-write the stock messaging system to not look for a message string, or simply send an empty string. Then use a message callback for hud manipulation -- look at how the playerList or scoreHud handles updating scores, kills, deaths, etc.