Jump to content

isElementVisibleTo


.:HyPeX:.

Recommended Posts

Are you that isElementVisibleTo is what you need? You're talking about a nametag script, so the element must be on the screen, not just visible.

From isElementVisibleTo wiki:

This does not check if the player can literally see the element, just that they are aware that it exists.

Perhaps this is what you need:

isElementOnScreen 

Link to comment
Are you that isElementVisibleTo is what you need? You're talking about a nametag script, so the element must be on the screen, not just visible.

From isElementVisibleTo wiki:

This does not check if the player can literally see the element, just that they are aware that it exists.

Perhaps this is what you need:

isElementOnScreen 

Great, i'll use that then xD

Link to comment
  
addEventHandler('onClientRender',root,function() 
for i,v in ipairs(getElementsByType('player')) do 
    local veh = getPedOccupiedVehicle(v) 
    if veh then 
        if isElementOnScreen(veh) then 
            local x,y,z = getElementPosition(veh) 
            local s = getElementRadius ( veh ) 
            local z = z+s/3 
            local sx,sy = getScreenFromWorldPosition(x,y,z) 
            local id = getElementData(v,"member_id") or 0 
            if not sx then return end 
            if not font then return end 
            dxDrawImage(sx-22-(dxGetTextWidth(getPlayerName(v):gsub("#%x%x%x%x%x%x",""),1,font)/2),sy-15,40,40,":avatars/saved/profile/photo-"..id..".png") 
            dxDrawText(getPlayerName(v),sx+20,sy,sx+20,sy,tocolor(255,255,255,255),1,font,"center","center",false,false,true,true) 
            dxDrawText(getPlayerName(v):gsub("#%x%x%x%x%x%x",""),sx+20,sy+1,sx+20,sy+1,tocolor(0,0,0,255),1.02,font,"center","center",false,false,false,true) 
            local hp = getElementHealth(v) 
            local width = dxGetTextWidth(getPlayerName(v):gsub("#%x%x%x%x%x%x",""),1,font) 
            dxDrawRectangle(sx-width/2+20,sy+15,width,8,tocolor(0,0,0,180)) 
            dxDrawRectangle(sx-width/2+2+20,sy+15+2,width-4,4,tocolor(0,255,0,180)) 
        end 
    end 
end 
end) 

I did this, but when the car moves (I'm testing on my own car) the text vibrates a lot and is kinda annoying. What could i do to fix this?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...