How to execute a method client side?
by JohnT · in Torque Game Engine · 07/16/2005 (8:35 am) · 1 replies
Realize this is probably another major newbie question, but I have been banging my head on the keyboard for a while now.
I have implemented the fxRenderObject and added a ConsoleMethod that I want to call from script. I notice as the fxRenderObject is instantiated it gets created twice (i am assuming once for the server and again for the client)
When I call this object using:
NewObject.myConsoleMethod(1);
The server side receives the call and the client never sees the effect of this call so I believe everything is wired correctly.
My plan is to have the clients doing their own thing here with the object and I am not sure if this is possible using an object that exists in both the server and the client. If there is an easier way to deal with this I'd appreciate that advice as well.
Thanks for any help!
John
I have implemented the fxRenderObject and added a ConsoleMethod that I want to call from script. I notice as the fxRenderObject is instantiated it gets created twice (i am assuming once for the server and again for the client)
When I call this object using:
NewObject.myConsoleMethod(1);
The server side receives the call and the client never sees the effect of this call so I believe everything is wired correctly.
My plan is to have the clients doing their own thing here with the object and I am not sure if this is possible using an object that exists in both the server and the client. If there is an easier way to deal with this I'd appreciate that advice as well.
Thanks for any help!
John
About the author
Torque Owner Dan -
I am working with the my own custom FX object in a similar manor. If you get data on the server, you must package it up and send it to the client, if you want the client to know about it.
If you want the client script to update the object you could:
1 - Have the client send a command to the server
2 - Have the server send a command to the object (like you have now)
3 - Have the object update its vars and execute setMaskBits(...) and:
4 - Ensure your packUpdate has the approperate vars.
This will have the client call the server then have the server call the client. A good way to do it if you you want to avoid the client from calling the object directly which helps cut down on explotes and cheating.
If your want to know why your server object is getting the call rather than the client, its most likely that your function to call the object is being called from a script that is on the server.
It is possible for the client to manuplate an object without the server being involved. This is how the GUI elements are done. But you should keep in mind that if you give the client too much power without going through the sever for a check, the player could script his own cheats with your object. A good reason to have things run to a server that could potentially inpact a game.
Make sense?
Any wise people out there want to add or correct any of my mistakes? (I consider myself a newbie too so you wont offend. :-)