Game Development Community

server/client commands occuring at end of function regardless of location in function

by Joseph Bosch · in Torque X 2D · 04/30/2012 (10:20 am) · 2 replies

so I am having a strange problem where commands are occurring at the end of function rather then were they are in the function.

for example

function loadCom()
{
exec("~/gui/f9.gui");
sceneWindow2D.loadLevel("game/data/levels/f9.t2d");
commandToServer('cancelR');
$sceneGraph = sceneWindow2d.getSceneGraph();
Canvas.clear();
Canvas.setContent(f9Gui);
echo("f9 loaded");
commandToServer('dummyship');
echo ("setting up server for battle");
commandToServer('battleSetup');
}
and if I look at the console.log file

Loading compiled script C:/Users/PC/Dropbox/ED/game/gamescripts/server/battle.cs.
Loading compiled script C:/Users/PC/Dropbox/ED/game/gui/f9.gui.
Loading compiled script C:/Users/PC/Dropbox/ED/game/data/levels/f9.t2d.
f9 loaded
setting up server for battle
Mapping string: cancelR to index: 3
Mapping string: dummyship to index: 4
Mapping string: battleSetup to index: 5

from what I can tell server commands are being run at the end of functions in the order they were setup rather then where they are in the code. I suppose i could just have the serve and client bounce commands back and forth in small short functions but I cant help think I am missing something here.

#1
04/30/2012 (11:34 pm)
Well, when you send a commandToServer, it doesn't wait for the command to finish before continuing the function AFAIK, therefore the time it gets executed can be rather random. There might be a small delay before the server executes the function thats causing this.
#2
05/01/2012 (5:09 am)
Those lines can also be the commands being mapped to the string table, because RPC function names are not sent as text, but as IDs. You should see that output on both client and server, IIRC.