Game Development Community

Getting a pointer to client from inside of damage() function

by Clint S. Brewer · in Torque Game Engine · 10/29/2004 (2:58 pm) · 4 replies

What I really want to do is peek at the player's inventory when they shoot something to see if they have a specific item.
I know I can do that if I have the client object, but couldn't quite figure out how to get it from the parameteres that are passed in to the function.

here is basically what I want to do.

function DancingShroom::damage(%this, %obj, %position, %source, %amount, %damageType)
{
   //when we are hit with a projectile, this will get called,
   //but we need a way to get the client


   // doesn't work when player shoots them, hmm...
   messageClient(%obj.client, 'MsgTutorial', '\c0you hurt a mushroom');

}


it seemed like source possibly is the player, when I call dump on it, I see that it references my player's dts but for some reason I couldn't get it's client.

I'll try a few other things...

#1
10/29/2004 (3:34 pm)
Trace back to where %source is being sent from.. you can add .client to it and send it down the pipe

-Ron
#2
11/11/2004 (2:09 pm)
Thanks for the tip Ron,
I've been looking at other things lately, and now I'm starting to get my torque legs.
#3
08/08/2007 (11:17 am)
What if you have an empty function client side?

function foo() {
%player = ???;
}
#4
08/08/2007 (11:34 am)
@sim

One way to get the client on clientside is to send it from a commandToServer because it automatically gets the client. Then send that with a commandToClient and pass the %client to that function. Like so:


commandToServer(myCommand);

function serverCmdmyCommand(%client)
{
commandToClient(%client, MyClientCommand, %client);
}

Then on the clientside:

function clientCmdMyClientCommand(%client)
{
echo("%client: " @ %client);
}




I think another way is something like: ServerConnection.getControlObject() on the clientside.