Game Development Community

Grabbing %client from %obj

by Austin Whitlatch · in Technical Issues · 02/27/2008 (8:04 am) · 4 replies

Alright, While I know %client and %obj are just variables like any other, but what I wanted to know is how do you grab the %client variable from the %obj variable assuming %obj is the same as %client.player. How do I grab the %client from the %client.player since I am not given direct access to it.
function Chest::onPickup(%this, %obj, %shape, %amount)
{
   //overridden function from Weapon::OnPickup. Will be able to pick up chest 

  %client = %obj.client; // <-doesn't work
OR
  %client = %obj.Parent; //<-also doesn't work, tried each of these

   echo("ONPICKUP: " @ %client.pickupChest); // <- Doesn't work regardless of which one above i tried
   if(%client.pickupChest == 1)
   {
      Parent::onPickup(%this, %obj, %shape, %amount);
         commandToServer('changePOV',0);
         commandToServer('use',"Chest"); 
   }
}
function Chest::onCollision(%this,%obj,%col, %shape)
{
   echo("Chest:OnCollision");
   // Collision with other objects, including items   
   %client = %col.client; <-works
   echo("CLIENT: " @ %client.pickupChest); //<-works
   if(!%client)   
   {      
   	return;
   }     
}
I am not calling the %client in the same way in both of these functions. Ones going through %col the other from %obj. If ANYONE has an idea on how in the heck to grab the %client please let me know.

#1
02/27/2008 (8:31 am)
Use echo in your functions

echo("%this: " @ %this);
echo("%obj : " @ %obj );

You can even try %obj.client or %this.client, or %obj.player or whatever...

and then use dump() in the console. %this.dump() %obj.dump() %col.dump()

That should help you find what you're looking for.
#2
02/27/2008 (10:52 am)
I think the syntax is "%client = %obj.getControllingClient();".

Nathan
#3
02/27/2008 (11:22 am)
Austin, mb's advise is excellent - echo() is your friend.

here's a couple other things of interest to echo -
echo(%obj.getClassName());
echo(%shape.getClassName());

note that AIPlayers may be picking stuff up, and they won't have a client, obviously.

the normal syntax is %player.client.
#4
03/03/2008 (8:42 am)
Thanks so much for the posts guys, i figured out what the issue was. For some reason the %shape is actually what i needed to use. For some reason %shape.client is where the client for the player is being held not in the %obj like I had previously believed. Thanks so much for the help guys, I appreciate it :0