function getPositionBackOfElement(element, meters)
if (not element or not isElement(element)) then return false end
local meters = (type(meters) == "number" and meters) or 3
local posX, posY, posZ = getElementPosition(element)
local _, _, rotation = getElementRotation(element)
posX = posX + math.sin(math.rad(rotation)) * meters
posY = posY - math.cos(math.rad(rotation)) * meters
rot = rotation - math.cos(math.rad(rotation))
return posX, posY, posZ , rot
end
function getPositionFrontOfElement(element, meters)
if (not element or not isElement(element)) then return false end
local meters = (type(meters) == "number" and meters) or 3
local posX, posY, posZ = getElementPosition(element)
local _, _, rotation = getElementRotation(element)
posX = posX - math.sin(math.rad(rotation)) * meters
posY = posY + math.cos(math.rad(rotation)) * meters
rot = rotation + math.cos(math.rad(rotation))
return posX, posY, posZ , rot
end
function isPlayerBehindPlayer( source,player )
local x,y,z = getElementPosition( source )
local x1,y1,z1 = getElementPosition( player )
local cx,cy,cz=getPositionBackOfElement(source, 500)
local dist = getDistanceBetweenPoints3D( x,y,z,cx,cy,cz )
local dist1 = getDistanceBetweenPoints3D( x1,y1,z1,cx,cy,cz )
if dist1<dist then return true end
return false
end
function isPlayerInFrontPlayer( source,player )
local x,y,z = getElementPosition( source )
local x1,y1,z1 = getElementPosition( player )
local cx,cy,cz=getPositionFrontOfElement(source, 500)
local dist = getDistanceBetweenPoints3D( x,y,z,cx,cy,cz )
local dist1 = getDistanceBetweenPoints3D( x1,y1,z1,cx,cy,cz )
if dist1<dist then return true end
return false
end
يتحقق اذا كان اللاعب اللي تبي قدام او ورا اللاعب اللي تبي