IIYAMA code works only client side (getElementMatrix)
This function works client side & server side, I didn't made it but JR10 posted it once.
function getPositionInfrontOfElement ( element , meters )
if not element or not isElement ( element ) then
return false
end
if not meters then
meters = 3
end
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
return posX , posY , posZ
end
Usage:
local x,y,z = getPositionInfrontOfElement ( element , meters )
element = the element's position you want to get in front off
meters = how many units from the element it needs to check