Author Topic: v13 broke raycast?  (Read 984 times)

Before v13, this command worked.  What this code does is transfer money from one player to another in my rp.  I've commented above the line I suspect of being the problem.   
Code: [Select]
function RPC_givemoney(%client,%args)
{
%money = mFloor(getWord(%args, 0));
if(%money < 1)
{
messageClient(%client, '', "\c6You must enter a valid amount of money to give.");
return;
}

if(TezRPData.getData(%client.bl_id).valueMoney - %money < 0)
{
messageClient(%client, '', "\c6You don't have that much money to give.");
return;
}
if(!isObject(%client.player))
{
messageClient(%client, '', "\c6Spawn first before you use this command.");
return;
}
//I'm sure the line below is causing the problem and I think some changes in v13 broke it.  Can anyone fix?
%target = containerRayCast(%client.player.getEyePoint(), vectorAdd(vectorScale(vectorNormalize(%client.player.getEyeVector()), 8), %client.player.getEyePoint()), $typeMasks::playerObjectType).client;
if(!isObject(%target))
{
messageClient(%client, '', "\c6You must be looking at and be in a reasonable distance of the player in order to give them money.");
return;
}
messageClient(%client, '', "\c6You give \c3$" @ %money SPC "\c6to \c3" @ %target.name @ "\c6.");
messageClient(%target, '', "\c3" @ %client.name SPC "\c6has given you \c3$" @ %money @ "\c6.");
TezRPData.getData(%client.bl_id).valueMoney -= %money;
TezRPData.getData(%target.bl_id).valueMoney += %money;
%client.TezRP(1);
%target.TezRP(1);
}

Get the first word of the raycast:
firstWord(containerRaycast(...

Get the first word of the raycast:
firstWord(containerRaycast(...
Code: [Select]
%target = firstWord(containerRayCast(%client.player.getEyePoint(), vectorAdd(vectorScale(vectorNormalize(%client.player.getEyeVector()), 8), %client.player.getEyePoint()), $typeMasks::playerObjectType).client);
It's still glitched =\
The money just returns back to the player trying to give it.

Code: [Select]
%target = containerRayCast(%client.player.getEyePoint(), vectorAdd(vectorScale(vectorNormalize(%client.player.getEyeVector()), 5), %client.player.getEyePoint()), $typeMasks::playerObjectType,%client.player).client;

Didn't you learn from your other thread about raycasts :| the raycast is just hitting the player that fired it.

Thanks Amade and Heed, it works now.