hi guys i want the target for exactly team particular
code :
function makeTargetFollow ( target )
if ( target ) and ( getElementType(target) == "player" ) then
local x,y,z = getElementPosition( source )
local tx,ty,tz = getElementPosition( target )
if ( getDistanceBetweenPoints3D( x,y,z,tx,ty,tz ) <= 7 ) then
toggleAllControls( target, false )
setControlState( target, "forwards", true)
setTimer( updateRotation, 500, 0, source, target )
end
end
end
addEventHandler( "onPlayerTarget", root, makeTargetFollow )
function updateRotation( player, target )
if ( isElement(player) ) and ( isElement(target) ) then
local x,y = getElementPosition( player )
local tx,ty = getElementPosition( target )
local rot = findRotation(tx,ty,x,y)
setElementRotation ( target, 0, 0, rot )
end
end
function findRotation(x1,y1,x2,y2)
local t = -math.deg(math.atan2(x2-x1,y2-y1))
if t < 0 then t = t + 360 end;
return t;
end