Game Development Community

Get Client Who Used Input?

by Steve Acaster · in Torque 3D Professional · 07/24/2011 (3:12 pm) · 4 replies

Have managed to confuse myself ... again ...

I want to get the ClientID of who "pressed a button/caused an input" of a default.binds function.

I can't use localClientConnection because it's solely for Client Local To Server and thus not networked ... and I can't use client.player because It's not appropriate for what I'm doing. The controlObject is the Client's camera.

I was thinking of using the ClientGroup ... but surely that would just give me a for each Client, rather than the Client which activated the input.

... and then I baffled myself ...

function myInput(%val)
{

//get client who pressed here <---------

   if(%val > 0)
   {
      //science goes here
   }
   else
   {
      //science goes here
   }
}

moveMap.bind( mouse, zaxis, myInput );

I'm probably just missing something obvious (or equally likely forgot something).

#1
07/24/2011 (3:22 pm)
I don't see any way to detect which client pressed a button, so to speak, since this is purely client side. However, when the client processes the bind, in default.bind, it may send a message to the server. An example would be drop camera at player. This would give you the ability to catch what the client(s) are doing. If what you are looking for isn't sending anything to the server you could always add a call to flag the action.
#2
07/24/2011 (4:07 pm)
Hey Steve,

I actually had a function to do this exact thing, but it's on my other HD at the moment. The rough approximation(from what I can remember) would be either ServerConnection.getControlObject(), or LocalClientConnection.getControlObject().

If I get a chance, I'll pull the backup HD out and snag that code and post it up for you.
#3
07/24/2011 (4:13 pm)
moveMap.bind( mouse, zaxis, "commandToServer(\'myInput\');", "");

function ServerCmdmyInput(%client)
{
   ...
}
#4
07/24/2011 (6:17 pm)
This is dumb, I was already using a serverCmd inside the function ... could've just got the client from there couldn't I?

I said "probably obvious" ... ffs ...

Thanks for the brain jolt, cheers.