Gravestone Posted May 1, 2016 Share Posted May 1, 2016 (edited) *fixed* Edited May 3, 2016 by Guest Link to comment
Walid Posted May 1, 2016 Share Posted May 1, 2016 (edited) strings = { { "^%[[%w@]+%]", " " }, } nametags_Root = getRootElement() nametags_ResRoot = getResourceRootElement(getThisResource()) nametags_Players = getElementsByType('player') nametags_Me = getLocalPlayer() nametag = {} local nametags = {} local sWidth,sHeight = guiGetScreenSize() local Nametags_Hide = false local Nametags_Scale = 0.30 local Nametags_Alpha_Distance = 50 local Nametags_Distance = 200 local Nametags_Alpha = 255 local Nametags_Width = 50 local Nametags_Height = 20 local Nametags_Size = 0.3 Nametags_Scale = 1/Nametags_Scale * 800 / sHeight local maxScaleCurve = { {0, 0}, {3, 3}, {13, 5} } local textScaleCurve = { {0, 0.8}, {0.8, 1.2}, {99, 99} } local textAlphaCurve = { {0, 0}, {25, 100}, {120, 190}, {255, 190} } function nametags.Create ( player ) nametags[player] = true end function nametags.Destroy ( player ) nametags[player] = nil end addEventHandler ( "onClientRender", nametags_Root, function() local x,y,z = getCameraMatrix() for player in pairs(nametags) do while true do if not isElement(player) then break end if getElementDimension(player) ~= getElementDimension(nametags_Me) then break end local px,py,pz = getElementPosition ( player ) local bx, by, bz = getPedBonePosition( player, 5 ) if processLineOfSight(x, y, z, px, py, pz, true, false, false, true, false, true) then break end local playerDistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz ) if playerDistance <= Nametags_Distance then --Get screen position --local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 ) local sx,sy = getScreenFromWorldPosition( bx + 0, by, bz + 0.3 ) if not sx or not sy then break end --Calculate our components local scale = 1/(Nametags_Scale * (playerDistance / Nametags_Distance)) local alpha = ((playerDistance - Nametags_Alpha_Distance) / Nametags_Alpha_Diff) alpha = (alpha < 0) and Nametags_Alpha or Nametags_Alpha-(alpha*Nametags_Alpha) scale = math.evalCurve(maxScaleCurve,scale) local textScale = math.evalCurve(textScaleCurve,scale) local textAlpha = math.evalCurve(textAlphaCurve,alpha) local outlineThickness = Nametags_Outline_Thickness*(scale) --Requirements local team = getPlayerTeam(player) local offset = (scale) * Nametags_Text_Bar_Space/2 local playerName = getPlayerName(player) local r, g, b = getPlayerNametagColor(player) local chatState = isChatBoxInputActive(player) or isConsoleActive(player) local imageSize = dxGetFontHeight ( textScale*Nametags_Size, "arial" ) for k,v in ipairs (strings) do if string.find( string.lower ( playerName ),v[1]) then playerName = playerName:gsub ( v[1], v[2] ) end end --Draw our text dxDrawText ( playerName, sx+1, sy - offset+1, sx+1, sy - offset-1, tocolor(0,0,0,200), textScale*Nametags_Size*1, "arial", "center", "bottom", false, false, false, true, true ) -- Shadow dxDrawText ( playerName, sx, sy - offset, sx, sy - offset, tocolor(r,g,b,255), textScale*Nametags_Size*1, "arial", "center", "bottom", false, false, false, true, true ) nameWidth = dxGetTextWidth ( playerName, textScale*Nametags_Size, "arial" ) end end end end ) Edited May 1, 2016 by Guest Link to comment
Gravestone Posted May 1, 2016 Author Share Posted May 1, 2016 (edited) c Edited May 3, 2016 by Guest Link to comment
GTX Posted May 1, 2016 Share Posted May 1, 2016 Just change Nametags_Distance variable. Link to comment
Walid Posted May 1, 2016 Share Posted May 1, 2016 Can you make an example ? simply , as GTX said you can change the Nametags_Distance because you already have all those function. local Nametags_Distance = 200 Edit: Check my first post 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