How to know the current process is a pure client?
by Tom Giant · in Torque 3D Professional · 11/29/2010 (8:31 am) · 5 replies
I need to write some codes that will only be called in the client-side. Is there some check functions like "isClient()" or "isServer()"?
In addition, is it safe that the function "commandToServer" is called in the client-side, or the function "commandToClient" is called in the server-side?
Thanks for any help.
In addition, is it safe that the function "commandToServer" is called in the client-side, or the function "commandToClient" is called in the server-side?
Thanks for any help.
About the author
#2
Additionally, a client that is a pure client will not have a $ServerGroup (you can test with isObject($ServerGroup) in script). You could also use ClientGroup.getCount(), which should return 0 for a pure client as there will be no other clients connected to it.
11/29/2010 (1:39 pm)
localClientConnection only exists when the game is run in single player mode, and the client and server exist together. So isObject(LocalClientConnection) will be false for a 'pure' client.Additionally, a client that is a pure client will not have a $ServerGroup (you can test with isObject($ServerGroup) in script). You could also use ClientGroup.getCount(), which should return 0 for a pure client as there will be no other clients connected to it.
#3
11/29/2010 (2:44 pm)
Quote:In addition, is it safe that the function "commandToServer" is called in the client-side, or the function "commandToClient" is called in the server-side?Is there any other use for it :P? In other words, yes it is safe to call commandToServer from client, and commandToClient from server.
#4
11/30/2010 (1:59 am)
Be careful, one thing that is not safe is to set a bit mask (C++) while on the client... this will result with an infinite loop for update...
#5
About additional question, I made a little mistake, sorry for that. Actually, I wondered whether or not it was safe that the function "commandToServer" is called in the server-side, or the function "commandToClient" is called in the client-side?
The problem originated in the following thread. I was thinking of the problem when I appended the code "commandToServer('RightMouseDown', %start, %end );
".
http://www.torquepowered.com/community/forums/viewthread/122679
Thanks for any help in advance.
11/30/2010 (3:14 am)
Got it. Thanks for your replies.About additional question, I made a little mistake, sorry for that. Actually, I wondered whether or not it was safe that the function "commandToServer" is called in the server-side, or the function "commandToClient" is called in the client-side?
The problem originated in the following thread. I was thinking of the problem when I appended the code "commandToServer('RightMouseDown', %start, %end );
".
http://www.torquepowered.com/community/forums/viewthread/122679
Quote:
I made some changes to the stock codes of the official document, then the "BoomBot" could be directed in the multiple player mode. But I don't know whether or not the changes are appropriate and safe.
Thanks for any help in advance.
Associate Manoel Neto
Default Studio Name