22 Temmuz 2018, 11:57:32

Gönderen Konu: [YARDIM] Nametags Bind Kapatma  (Okunma sayısı 578 defa)

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

ConTra

  • Boş konuşacağına anlamlı sus daha iyidir.
  • Yeni Üye
  • *
  • İleti: 96
[YARDIM] Nametags Bind Kapatma
« : 25 Şubat 2017, 14:21:22 »
Nametags'da N tuşuna basınca araç üstündeki isim kapanıyor ama herkesin ismi kapanıyor ben sadece kendi aracmınki kapansın istiyorum nasıl yaparız ?

Kod: Lua
  1. font = "bankgothic"
  2. local fontScale = 1
  3. --
  4. local state = true
  5. bindKey("N", "down", function()
  6.      state = not state
  7. end)
  8.  
  9. nametag = {}
  10. local enabled = true
  11. local nametags = {}
  12. local g_screenX,g_screenY = guiGetScreenSize()
  13. local bHideNametags = false
  14.  
  15. local NAMETAG_SCALE = 0.3 --Overall adjustment of the nametag, use this to resize but constrain proportions
  16. local NAMETAG_ALPHA_DISTANCE = 50 --Distance to start fading out
  17. local NAMETAG_DISTANCE = 120 --Distance until we're gone
  18. local NAMETAG_ALPHA = 120 --The overall alpha level of the nametag
  19. --The following arent actual pixel measurements, they're just proportional constraints
  20. local NAMETAG_TEXT_BAR_SPACE = 2
  21. local NAMETAG_WIDTH = 42
  22. local NAMETAG_HEIGHT = 4.5
  23. local NAMETAG_TEXTSIZE = 0.30
  24. local NAMETAG_OUTLINE_THICKNESS = 0.8
  25. --
  26. local chaticon = true
  27. local NAMETAG_ALPHA_DIFF = NAMETAG_DISTANCE - NAMETAG_ALPHA_DISTANCE
  28. NAMETAG_SCALE = 1/NAMETAG_SCALE * 1100 / g_screenY  -- default was 800
  29.  
  30. TESTING_MY_NAME = 1
  31.  
  32. -- If 1, then your nametag will be shown
  33.  
  34. -- Ensure the name tag doesn't get too big
  35. local maxScaleCurve = { {0, 0}, {3, 3}, {13, 5} }
  36. -- Ensure the text doesn't get too small/unreadable
  37. local textScaleCurve = { {0, 0.8}, {0.8, 1.2}, {99, 99} }
  38. -- Make the text a bit brighter and fade more gradually
  39. local textAlphaCurve = { {0, 0}, {25, 100}, {120, 190}, {255, 190} }
  40.  
  41. function nametag.create ( player )
  42.    nametags[player] = true
  43. end
  44.  
  45. function nametag.destroy ( player )
  46.    nametags[player] = nil
  47. end
  48.  
  49. dxTextCache = {}
  50. dxTextShadowCache = {}
  51.  
  52. function dxDrawColoredText(str, ax, ay, bx, by, color, tcolor,  scale, font)
  53.    local rax = ax
  54.    if not dxTextShadowCache[str] then
  55.       dxTextShadowCache[str] = string.gsub( str, '#%x%x%x%x%x%x', '' )
  56.    end
  57.    dxDrawText(dxTextShadowCache[str], ax+1,ay+1,ax+1,by,tocolor(0,0,0, 0.8 * tcolor[4]),scale,font, "left", "bottom", false,false,false)
  58.    if dxTextCache[str] then
  59.       for id, text in ipairs(dxTextCache[str]) do
  60.          local w = text[2] * ( scale / text[4]  )
  61.          dxDrawText(text[1], ax + w, ay, ax + w, by, tocolor(text[3][1],text[3][2],text[3][3],tcolor[4]), scale, font, "left", "bottom", false,false,false)
  62.       end
  63.    else
  64.       dxTextCache[str] = {}
  65.       local pat = "(.-)#(%x%x%x%x%x%x)"
  66.       local s, e, cap, col = str:find(pat, 1)
  67.       local last = 1
  68.       local r = tcolor[1]
  69.       local g = tcolor[2]
  70.       local b = tcolor[3]
  71.       local textalpha = tcolor[4]
  72.       while s do
  73.          if cap == "" and col then
  74.             r = tonumber("0x"..col:sub(1, 2))
  75.             g = tonumber("0x"..col:sub(3, 4))
  76.             b = tonumber("0x"..col:sub(5, 6))
  77.             color = tocolor(r, g, b, textalpha)
  78.          end
  79.          if s ~= 1 or cap ~= "" then
  80.             local w = dxGetTextWidth(cap, scale, font)
  81.             dxDrawText(cap, ax, ay, ax + w, by, color, scale, font, "left", "bottom")
  82.             table.insert(dxTextCache[str], { cap, ax-rax, {r,g,b}, scale } )
  83.             ax = ax + w
  84.             r = tonumber("0x"..col:sub(1, 2))
  85.             g = tonumber("0x"..col:sub(3, 4))
  86.             b = tonumber("0x"..col:sub(5, 6))
  87.             color = tocolor( r, g, b, textalpha)
  88.          end
  89.          last = e + 1
  90.          s, e, cap, col = str:find(pat, last)
  91.       end
  92.       if last <= #str then
  93.          cap = str:sub(last)
  94.          local w = dxGetTextWidth(cap, scale, font)
  95.          dxDrawText(cap, ax, ay, ax + w, by, color, scale, font, "left", "bottom")
  96.          table.insert(dxTextCache[str], { cap, ax-rax, {r,g,b}, scale } )
  97.       end
  98.    end
  99. end
  100.  
  101. addEventHandler ( "onClientRender", g_Root,
  102.    function()
  103.         if not state then return end
  104.       -- Hideous quick fix --
  105.       for i,player in ipairs(g_Players) do
  106.          if player ~= g_Me or TESTING_MY_NAME == 1 then
  107.             setPlayerNametagShowing ( player, false )
  108.             if not nametags[player] then
  109.                nametag.create ( player )
  110.             end
  111.          end
  112.       end
  113.       if bHideNametags then
  114.          return
  115.       end
  116.       local x,y,z = getCameraMatrix()
  117.       if not enabled then return end
  118.       for player in pairs(nametags) do
  119.          while true do
  120.             if not isPedInVehicle(player) or isPlayerDead(player) then break end
  121.             local vehicle = getPedOccupiedVehicle(player)
  122.             local px,py,pz = getElementPosition ( vehicle )
  123.             local pdistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz )
  124.             if pdistance <= NAMETAG_DISTANCE then
  125.                --Get screenposition
  126.                local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 )
  127.                if not sx or not sy then break end
  128.                --Calculate our components
  129.                local scale = 1/(NAMETAG_SCALE * (pdistance / NAMETAG_DISTANCE))
  130.                local alpha = ((pdistance - NAMETAG_ALPHA_DISTANCE) / NAMETAG_ALPHA_DIFF)
  131.                alpha = (alpha < 0) and NAMETAG_ALPHA or NAMETAG_ALPHA-(alpha*NAMETAG_ALPHA)
  132.                local scale = math.evalCurve(maxScaleCurve,scale)
  133.                local textscale = math.evalCurve(textScaleCurve,scale)
  134.                local textalpha = math.evalCurve(textAlphaCurve,alpha)
  135.                local outlineThickness = NAMETAG_OUTLINE_THICKNESS*(scale)
  136.                --Draw chat icon
  137.                if getElementData(player, "isChatting") and chaticon then
  138.                  dxDrawImage(sx - 15 * scale, sy - 40 * scale, 30 * scale, 30 * scale, "img/nchat.png")
  139.                     end
  140.                --Draw our text
  141.                local r,g,b = 255,255,255
  142.                local team = getPlayerTeam(player)
  143.                if team then
  144.                   r,g,b = getTeamColor(team)
  145.                end
  146.                local h = dxGetFontHeight(0.5 * fontScale * textscale * NAMETAG_TEXTSIZE, font)
  147.                local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2
  148.                local w = dxGetTextWidth(getPlayerName(player), fontScale * textscale * NAMETAG_TEXTSIZE, font)/2
  149.                local a = getElementAlpha(getPedOccupiedVehicle(player))
  150.                dxDrawText(getPlayerName(player), sx+2, sy+1 - offset-2, sx+1, sy-1, tocolor(0, 0, 0, a), fontScale * textscale * NAMETAG_TEXTSIZE, font, "center", "bottom", false, false, false, true, true)
  151.                dxDrawText(getPlayerNametagText(player), sx, sy - offset, sx, sy, tocolor(r, g, b, a), fontScale * textscale * NAMETAG_TEXTSIZE, font, "center", "bottom", false, false, false, true, true)
  152.                --We draw three parts to make the healthbar.  First the outline/background
  153.                   local a = getElementAlpha(getPedOccupiedVehicle(player))
  154.                   local drawX = sx - NAMETAG_WIDTH*scale/2
  155.                   drawY = sy + offset
  156.                   local width,height =  NAMETAG_WIDTH*scale, NAMETAG_HEIGHT*scale
  157.                   dxDrawRectangle ( drawX, drawY, width, height, tocolor(0,0,0,0.6*a) )
  158.                   --Next the inner background
  159.                   local health = getElementHealth(vehicle)
  160.                   health = math.max(health - 250, 0)/750
  161.                   local p = -510*(health^2)
  162.                   local r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0)
  163.                   dxDrawRectangle (    drawX + outlineThickness,
  164.                                  drawY + outlineThickness,
  165.                                  width - outlineThickness*2,
  166.                                  height - outlineThickness*2,
  167.                                  tocolor(r,g,0,0.2*a)
  168.                               )
  169.                   --Finally, the actual health
  170.                   dxDrawRectangle (    drawX + outlineThickness,
  171.                                  drawY + outlineThickness,
  172.                                  health*(width - outlineThickness*2),
  173.                                  height - outlineThickness*2,
  174.                                  tocolor(r,g,0,0.4*a)
  175.                               )
  176.             end
  177.             break
  178.          end  
  179.       end
  180.    end
  181. )
  182.  
  183. addEventHandler('onClientResourceStart', g_ResRoot,
  184.    function()
  185.       for i,player in ipairs(getElementsByType"player") do
  186.          if player ~= g_Me then
  187.             nametag.create ( player )
  188.          end
  189.       end
  190.    end
  191. )
  192.  
  193. addEventHandler ( "onClientPlayerJoin", g_Root,
  194.    function()
  195.       if source == g_Me then return end
  196.       setPlayerNametagShowing ( source, false )
  197.       nametag.create ( source )
  198.    end
  199. )
  200.  
  201. addEventHandler ( "onClientPlayerQuit", g_Root,
  202.    function()
  203.       nametag.destroy ( source )
  204.    end
  205. )
  206.  
  207.  
  208. addEvent ( "onClientScreenFadedOut", true )
  209. addEventHandler ( "onClientScreenFadedOut", g_Root,
  210.    function()
  211.       bHideNametags = true
  212.    end
  213. )
  214.  
  215. addEvent ( "onClientScreenFadedIn", true )
  216. addEventHandler ( "onClientScreenFadedIn", g_Root,
  217.    function()
  218.       bHideNametags = false
  219.    end
  220. )
  221.  
  222. setTimer(
  223. function()
  224. if getElementData(getLocalPlayer(), "isChatting" ) ~= isChatBoxInputActive() then
  225.    setElementData(getLocalPlayer(), "isChatting", isChatBoxInputActive(), true)
  226. end
  227. end,
  228. 50,0 )
  229.  
  230. fileDelete("nametags.lua")
« Son Düzenleme: 25 Şubat 2017, 15:19:30 Gönderen: ConTra »
Linkleri Görebilmek İçin Kayıt Olun veya Giriş Yapın
 

MTASA-TURK | Türkiye'nin En Güncel MTA Platformu

[YARDIM] Nametags Bind Kapatma
« : 25 Şubat 2017, 14:21:22 »

Paradox

  • Kurucu
  • *
  • İleti: 649
  • SH Gaming
Ynt: [YARDIM]Nametags Bind Kapatma
« Yanıtla #1 : 25 Şubat 2017, 14:24:32 »
Kullandığın nametag'ı atarsan elimden geldiğince yardımcı olurum.
 

ConTra

  • Boş konuşacağına anlamlı sus daha iyidir.
  • Yeni Üye
  • *
  • İleti: 96
Ynt: [YARDIM]Nametags Bind Kapatma
« Yanıtla #2 : 25 Şubat 2017, 14:53:11 »
Linkleri Görebilmek İçin Kayıt Olun veya Giriş Yapın
Kullandığın nametag'ı atarsan elimden geldiğince yardımcı olurum.
PM'den ulaştırdım.
Linkleri Görebilmek İçin Kayıt Olun veya Giriş Yapın