Blockland Forums > Modification Help

Figure Out the Player at Whom Another Player is Looking

Pages: (1/1)

TheRealMint:

How do I find out who a player is looking at when he/she clicks the mouse? I realize that Armor::onTrigger will tell us when the player clicks, but I can't figure out how to find the player who is getting clicked.

phflack:

taken from the click push script, this should work?

--- Code: ---package Script_ClickPush
{
function Player::activateStuff(%player)
{
%v = Parent::activateStuff(%player);
%client = %player.client;

if(!$ClickPush::Status || (!%client.isAdmin && $ClickPush::AdminOnly))
return %v;

%target = containerRayCast(%player.getEyePoint(),vectorAdd(vectorScale(vectorNormalize(%player.getEyeVector()),2),%player.getEyePoint()),$TypeMasks::PlayerObjectType,%player);

if(!isObject(%target) || %target == %player || %player.getObjectMount() == %target)
return %v;

%target.setVelocity(vectorAdd(%target.getVelocity(),vectorScale(%player.getEyeVector(),$ClickPush::Amount)));

return %v;
}
};
activatePackage(Script_ClickPush);

--- End code ---


TheRealMint:


--- Quote from: phflack on April 02, 2012, 12:30:34 AM ---taken from the click push script, this should work?
-code-

--- End quote ---
Why thank you, phlack. That worked like a charm.

Pages: (1/1)

Go to full version