Okay, so here it is currently
if(isPackage(CrosshairTargeting))
deactivatePackage(CrosshairTargeting);
package CrosshairTargeting
{
function GameConnection::SpawnPlayer(%this)
{
crosshairTarget(%this.player);
if (isObject(%obj.client))
{
crossHair.setBitmap("Base/client/ui/crosshair");
}
return parent::SpawnPlayer(%this);
}
function Armor::onDisabled(%this, %pl, %enabled)
{
if (isObject(%pl.client))
{
cancel(%pl.crosshairTargetLoop);
crossHair.setBitmap("Base/client/ui/crosshair");
}
return Parent::onDisabled(%this, %pl, %enabled);
}
function GameConnection::onClientLeaveGame(%client)
{
cancel(%client.player.crosshairTargetLoop);
return parent::onClientLeaveGame(%client);
}
};
activatePackage(CrosshairTargeting);
function crosshairTarget(%obj)
{
%client = %player.client;
if (isObject(%obj.crosshairTargetLoop))
cancel(%obj.crosshairTargetLoop);
%eye = %obj.getEyePoint();
%ev = %obj.getEyeVector();
%length = 64;
%mask = $Typemasks::All;
%raycast = containerRaycast(%eye, VectorAdd(%eye,VectorScale(%ev,%length)),%mask,%ignore_this_object);
%hit = firstWord(%raycast);
if (%hit)
%end = getWords(%raycast, 1, 3);
if (%hit)
%client.targetPos = %end;
else
%client.targetPos = "";
%client.target = %hit;
%type = getType(%client.target);
if (%client.lastTargetPos $= "" || %type $= "PLAYER" || %type $= "BOT" || %type $= "VEHICLE")
{
%client.lastTargetPos = %client.targetPos;
if (%type $= "PLAYER" || %type $= "BOT")
{
%client.centerPrint("\c6Player or bot.",3);
if(isObject(%client))
{
crossHair.setBitmap("Add-Ons/Server_DynamicCrosshair/crossHair_targeted");
}
}
else if (%type $= "VEHICLE")
{
%client.centerPrint("\c6Vehicle.",3);
if(isObject(%client))
{
crossHair.setBitmap("Add-Ons/Server_DynamicCrosshair/crossHair_ally");
}
}
else
{
%client.centerPrint("\c6Etc.",3);
if(isObject(%client))
{
crossHair.setBitmap("base/client/ui/crossHair");
}
}
}
%obj.crosshairTargetLoop = schedule(30, 0, crosshairTarget, %obj);
}
Now the console says this
Add-Ons/Server_DynamicCrosshair/server.cs (38): Unable to find object: '' attempting to call function 'getEyePoint'
BackTrace: ->crosshairTarget
Add-Ons/Server_DynamicCrosshair/server.cs (39): Unable to find object: '' attempting to call function 'getEyeVector'
BackTrace: ->crosshairTarget
Add-Ons/Server_DynamicCrosshair/server.cs (54): Unable to find function getType
Lines 38 and 39
%eye = %obj.getEyePoint(); %ev = %obj.getEyeVector(); |
Line 54, which probably broke due to using
%client = %player.client; instead of
%client = %obj.client; %type = getType(%client.target); |
You're mixing client and server sided code. This add-on can't work.
Surely there must be a way, using raycasts to get typemasks is a server-side thing and you can change the player's crosshair in a weapon image's script(s) with this
if(isObject(%obj.client))
{
crossHair.setBitmap("[DIRECTORY TO IMAGE]");
}
So there must be a way to do it with raycasts, right?
And while crosshairs are a client thing, i think you might be able to force players to download the images by using the DecalData datablock, i think the old pill item did that for it's item icon