Client Side Datablock method
by Timothy C. Pelham · in Torque Game Engine · 06/02/2007 (8:33 am) · 2 replies
Ok...have another client side functionality question.
For a given object in the game (ie player/weapoon etc) the datablock scripts are actually in the server folder and executed as part of the server startup. Now during client connected the datablock is transferred to the player but what about the datablock methods?
So if I have an object...
datablock StaticShape(object)
{
....
}
and a method
function object::doStuff(%this)
{
...
}
Can I run this function on the client even though the method definiton originates on the server? I have an object that derives off of static shape in the engine and upon running a script function routes back to an object method using the executef function. It is not running the script function on the client object.
Is this even possible or am I doing something wrong? I know I am running the engine object method on the client object and it does echo saying that it runs, but the script method for the object is not executed. This does work when I run a local connected, but when I do dedicated server it does not run the method.
Any ideas?
Thanks.
For a given object in the game (ie player/weapoon etc) the datablock scripts are actually in the server folder and executed as part of the server startup. Now during client connected the datablock is transferred to the player but what about the datablock methods?
So if I have an object...
datablock StaticShape(object)
{
....
}
and a method
function object::doStuff(%this)
{
...
}
Can I run this function on the client even though the method definiton originates on the server? I have an object that derives off of static shape in the engine and upon running a script function routes back to an object method using the executef function. It is not running the script function on the client object.
Is this even possible or am I doing something wrong? I know I am running the engine object method on the client object and it does echo saying that it runs, but the script method for the object is not executed. This does work when I run a local connected, but when I do dedicated server it does not run the method.
Any ideas?
Thanks.
#2
Any ideas how I could do that a bit simpler/cleaner?
Also by doing all these client/server communications would it kill performance when larger amounts of users are interacting with objects at the same time?
Thanks.
06/02/2007 (9:41 am)
Thanks for the quick response. I am familiar with the server/client commands but I was hoping to do a method on an object. I'm trying to populate an interaction menu based on the object that is selected. I was using a datablock method so that each item could populate the menu depending on the object selected. Using the client/server functions I can pass the object along to the client to populate the menu, but then it seems I would need a large switch statement to handle the per object menu creation. Any ideas how I could do that a bit simpler/cleaner?
Also by doing all these client/server communications would it kill performance when larger amounts of users are interacting with objects at the same time?
Thanks.
Torque Owner Tim Heldna
Here's a crappy example:
//----------------------------------------------------------------------------- // Function that hides crosshair stored on client //----------------------------------------------------------------------------- function clientCmdHideCrosshair(%client) { reticleHud.setVisible(false); // Hide the crosshair } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Calling the above function from the client //----------------------------------------------------------------------------- commandToServer('hideCrosshair', %client); //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Jump to the server and execute the client function (at the very top) //----------------------------------------------------------------------------- function serverCmdHideCrosshair(%client) { commandToClient(%client, 'hideCrosshair'); } //-----------------------------------------------------------------------------