There's a few little bugs in this, but I like it, it's original for GTA too
function showTextIcon()
local playerx,playery,playerz = getElementPosition ( getLocalPlayer() )
...
When you're drawing things in a 3d world, you need to use the camera position as the origin, not the player's position.
You also need an 'isElementOnScreen' check in there somewhere.