if(isPackage(CrosshairTargeting)) deactivatePackage(CrosshairTargeting); package CrosshairTargeting { function GameConnection::SpawnPlayer(%this, %obj) { parent::SpawnPlayer(%this, %obj); %client = %obj.client; crosshairTarget(%obj); if (isObject(%client)) { cancel(%client.crosshairTargetLoop); crossHair.setBitmap("Base/client/ui/crosshair"); } } function Armor::onDisabled(%this, %pl, %enabled) { %client = %pl.client; if (isObject(%client)) { cancel(%client.crosshairTargetLoop); crossHair.setBitmap("Base/client/ui/crosshair"); } return Parent::onDisabled(%this, %pl, %enabled); } function GameConnection::onClientLeaveGame(%client) { cancel(%client.crosshairTargetLoop); return parent::onClientLeaveGame(%client); } }; activatePackage(CrosshairTargeting); function crosshairTarget(%this, %obj) { %client = %obj.client; if (isObject(%client.crosshairTargetLoop)) cancel(%client.crosshairTargetLoop); %eye = %client.getEyePoint(); %ev = %client.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") { if(isObject(%client)) { //enemy crosshair testing crossHair.setBitmap("Add-Ons/Server_DynamicCrosshair/crossHair_targeted"); } } else if (%type $= "VEHICLE") { if(isObject(%client)) { //ally crosshair testing crossHair.setBitmap("Add-Ons/Server_DynamicCrosshair/crossHair_ally"); } } else { if(isObject(%client)) { //base crosshair to revert to crossHair.setBitmap("base/client/ui/crossHair"); } } } %client.crosshairTargetLoop = schedule(30, 0, crosshairTarget, %this, %obj); }