.:HyPeX:. Posted February 19, 2015 Share Posted February 19, 2015 Hello, is there any client-sided variant of isElementVisibleTo? i'd like to use a client-sided check for a nametags script. Greetz HyPeX Link to comment
.:HyPeX:. Posted February 20, 2015 Author Share Posted February 20, 2015 Bump, anyone? i thought of checking every sec and sending client a table, but that wouldnt be efficient at all... Link to comment
JR10 Posted February 20, 2015 Share Posted February 20, 2015 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
.:HyPeX:. Posted February 20, 2015 Author Share Posted February 20, 2015 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 Link to comment
.:HyPeX:. Posted February 20, 2015 Author Share Posted February 20, 2015 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
TAPL Posted February 20, 2015 Share Posted February 20, 2015 Try with onClientPreRender. Link to comment
.:HyPeX:. Posted February 20, 2015 Author Share Posted February 20, 2015 Try with onClientPreRender. Still. I belive it is related to getScreenFromWorldPosition as this function has a delay on startup. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now