Getting the client's GameConnection in script
by Aaron Murray · in Torque Game Engine · 11/23/2001 (8:58 pm) · 3 replies
I'm pretty sure this has been answered somewhere before, but I can't find it, and a link to whereever this is explained will be just as appreciated as an answer.
I'm just wondering how I would go about getting a reference to the client who's running the current script's GameConnection variable. In the code, you get it like this...
GameConnection * con = GameConnection::getServerConnection();
So I'm just wondering how I would go about doing this in the script, in a function which isn't passed any %client variable or anything. Thanks!
I'm just wondering how I would go about getting a reference to the client who's running the current script's GameConnection variable. In the code, you get it like this...
GameConnection * con = GameConnection::getServerConnection();
So I'm just wondering how I would go about doing this in the script, in a function which isn't passed any %client variable or anything. Thanks!
About the author
#2
11/25/2001 (10:48 am)
Oh... Hmm, guess I didn't understand exactly how the scripts work... Alright, thanks for the reply!
#3
function clientCmdfoo()
{
commandToServer('moo');
}
function serverCmdmoo(%client)
{
commandToClient(%client, 'loo', %client);
}
funciton clientCmdloo(%client)
{
// the code you actually want to run goes here
}
Right: when you use commandToServer('function') then 'function' gets called with the first argument being the client which called it. You then just get the server to tell the client to run the function you originally wanted and you have hold of the client pointer.
Anyway, I bet someone's going to tell me this isn't very efficient, packet wise...
04/02/2002 (4:37 am)
well, this may not be what you want, but:function clientCmdfoo()
{
commandToServer('moo');
}
function serverCmdmoo(%client)
{
commandToClient(%client, 'loo', %client);
}
funciton clientCmdloo(%client)
{
// the code you actually want to run goes here
}
Right: when you use commandToServer('function') then 'function' gets called with the first argument being the client which called it. You then just get the server to tell the client to run the function you originally wanted and you have hold of the client pointer.
Anyway, I bet someone's going to tell me this isn't very efficient, packet wise...
Torque Owner Tim Gift