[YARDIM] Nametags Bind Kapatma

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı ConTra

  • Boş konuşacağına anlamlı sus daha iyidir.
  • Yeni Üye
  • *
    • İleti: 88
: 25 Şubat 2017, 13:15:11
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
font = "bankgothic"
local fontScale = 1
--
local state = true
bindKey("N", "down", function()
     state = not state
end)

nametag = {}
local enabled = true
local nametags = {}
local g_screenX,g_screenY = guiGetScreenSize()
local bHideNametags = false

local NAMETAG_SCALE = 0.3 --Overall adjustment of the nametag, use this to resize but constrain proportions
local NAMETAG_ALPHA_DISTANCE = 50 --Distance to start fading out
local NAMETAG_DISTANCE = 120 --Distance until we're gone
local NAMETAG_ALPHA = 120 --The overall alpha level of the nametag
--The following arent actual pixel measurements, they're just proportional constraints
local NAMETAG_TEXT_BAR_SPACE = 2
local NAMETAG_WIDTH = 42
local NAMETAG_HEIGHT = 4.5
local NAMETAG_TEXTSIZE = 0.30
local NAMETAG_OUTLINE_THICKNESS = 0.8
--
local chaticon = true
local NAMETAG_ALPHA_DIFF = NAMETAG_DISTANCE - NAMETAG_ALPHA_DISTANCE
NAMETAG_SCALE = 1/NAMETAG_SCALE * 1100 / g_screenY  -- default was 800

TESTING_MY_NAME = 1

-- If 1, then your nametag will be shown

-- Ensure the name tag doesn't get too big
local maxScaleCurve = { {0, 0}, {3, 3}, {13, 5} }
-- Ensure the text doesn't get too small/unreadable
local textScaleCurve = { {0, 0.8}, {0.8, 1.2}, {99, 99} }
-- Make the text a bit brighter and fade more gradually
local textAlphaCurve = { {0, 0}, {25, 100}, {120, 190}, {255, 190} }

function nametag.create ( player )
   nametags[player] = true
end

function nametag.destroy ( player )
   nametags[player] = nil
end

dxTextCache = {}
dxTextShadowCache = {}

function dxDrawColoredText(str, ax, ay, bx, by, color, tcolor,  scale, font)
   local rax = ax
   if not dxTextShadowCache[str] then
      dxTextShadowCache[str] = string.gsub( str, '#%x%x%x%x%x%x', '' )
   end
   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)
   if dxTextCache[str] then
      for id, text in ipairs(dxTextCache[str]) do
         local w = text[2] * ( scale / text[4]  )
         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)
      end
   else
      dxTextCache[str] = {}
      local pat = "(.-)#(%x%x%x%x%x%x)"
      local s, e, cap, col = str:find(pat, 1)
      local last = 1
      local r = tcolor[1]
      local g = tcolor[2]
      local b = tcolor[3]
      local textalpha = tcolor[4]
      while s do
         if cap == "" and col then
            r = tonumber("0x"..col:sub(1, 2))
            g = tonumber("0x"..col:sub(3, 4))
            b = tonumber("0x"..col:sub(5, 6))
            color = tocolor(r, g, b, textalpha)
         end
         if s ~= 1 or cap ~= "" then
            local w = dxGetTextWidth(cap, scale, font)
            dxDrawText(cap, ax, ay, ax + w, by, color, scale, font, "left", "bottom")
            table.insert(dxTextCache[str], { cap, ax-rax, {r,g,b}, scale } )
            ax = ax + w
            r = tonumber("0x"..col:sub(1, 2))
            g = tonumber("0x"..col:sub(3, 4))
            b = tonumber("0x"..col:sub(5, 6))
            color = tocolor( r, g, b, textalpha)
         end
         last = e + 1
         s, e, cap, col = str:find(pat, last)
      end
      if last <= #str then
         cap = str:sub(last)
         local w = dxGetTextWidth(cap, scale, font)
         dxDrawText(cap, ax, ay, ax + w, by, color, scale, font, "left", "bottom")
         table.insert(dxTextCache[str], { cap, ax-rax, {r,g,b}, scale } )
      end
   end
end

addEventHandler ( "onClientRender", g_Root,
   function()
        if not state then return end
      -- Hideous quick fix --
      for i,player in ipairs(g_Players) do
         if player ~= g_Me or TESTING_MY_NAME == 1 then
            setPlayerNametagShowing ( player, false )
            if not nametags[player] then
               nametag.create ( player )
            end
         end
      end
      if bHideNametags then
         return
      end
      local x,y,z = getCameraMatrix()
      if not enabled then return end
      for player in pairs(nametags) do
         while true do
            if not isPedInVehicle(player) or isPlayerDead(player) then break end
            local vehicle = getPedOccupiedVehicle(player)
            local px,py,pz = getElementPosition ( vehicle )
            local pdistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz )
            if pdistance <= NAMETAG_DISTANCE then
               --Get screenposition
               local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 )
               if not sx or not sy then break end
               --Calculate our components
               local scale = 1/(NAMETAG_SCALE * (pdistance / NAMETAG_DISTANCE))
               local alpha = ((pdistance - NAMETAG_ALPHA_DISTANCE) / NAMETAG_ALPHA_DIFF)
               alpha = (alpha < 0) and NAMETAG_ALPHA or NAMETAG_ALPHA-(alpha*NAMETAG_ALPHA)
               local scale = math.evalCurve(maxScaleCurve,scale)
               local textscale = math.evalCurve(textScaleCurve,scale)
               local textalpha = math.evalCurve(textAlphaCurve,alpha)
               local outlineThickness = NAMETAG_OUTLINE_THICKNESS*(scale)
               --Draw chat icon
               if getElementData(player, "isChatting") and chaticon then
                 dxDrawImage(sx - 15 * scale, sy - 40 * scale, 30 * scale, 30 * scale, "img/nchat.png")
                    end
               --Draw our text
               local r,g,b = 255,255,255
               local team = getPlayerTeam(player)
               if team then
                  r,g,b = getTeamColor(team)
               end
               local h = dxGetFontHeight(0.5 * fontScale * textscale * NAMETAG_TEXTSIZE, font)
               local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2
               local w = dxGetTextWidth(getPlayerName(player), fontScale * textscale * NAMETAG_TEXTSIZE, font)/2
               local a = getElementAlpha(getPedOccupiedVehicle(player))
               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)
               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)
               --We draw three parts to make the healthbar.  First the outline/background
                  local a = getElementAlpha(getPedOccupiedVehicle(player))
                  local drawX = sx - NAMETAG_WIDTH*scale/2
                  drawY = sy + offset
                  local width,height =  NAMETAG_WIDTH*scale, NAMETAG_HEIGHT*scale
                  dxDrawRectangle ( drawX, drawY, width, height, tocolor(0,0,0,0.6*a) )
                  --Next the inner background
                  local health = getElementHealth(vehicle)
                  health = math.max(health - 250, 0)/750
                  local p = -510*(health^2)
                  local r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0)
                  dxDrawRectangle (    drawX + outlineThickness,
                                 drawY + outlineThickness,
                                 width - outlineThickness*2,
                                 height - outlineThickness*2,
                                 tocolor(r,g,0,0.2*a)
                              )
                  --Finally, the actual health
                  dxDrawRectangle (    drawX + outlineThickness,
                                 drawY + outlineThickness,
                                 health*(width - outlineThickness*2),
                                 height - outlineThickness*2,
                                 tocolor(r,g,0,0.4*a)
                              )
            end
            break
         end   
      end
   end
)

addEventHandler('onClientResourceStart', g_ResRoot,
   function()
      for i,player in ipairs(getElementsByType"player") do
         if player ~= g_Me then
            nametag.create ( player )
         end
      end
   end
)

addEventHandler ( "onClientPlayerJoin", g_Root,
   function()
      if source == g_Me then return end
      setPlayerNametagShowing ( source, false )
      nametag.create ( source )
   end
)

addEventHandler ( "onClientPlayerQuit", g_Root,
   function()
      nametag.destroy ( source )
   end
)


addEvent ( "onClientScreenFadedOut", true )
addEventHandler ( "onClientScreenFadedOut", g_Root,
   function()
      bHideNametags = true
   end
)

addEvent ( "onClientScreenFadedIn", true )
addEventHandler ( "onClientScreenFadedIn", g_Root,
   function()
      bHideNametags = false
   end
)

setTimer(
function()
if getElementData(getLocalPlayer(), "isChatting" ) ~= isChatBoxInputActive() then
   setElementData(getLocalPlayer(), "isChatting", isChatBoxInputActive(), true)
end
end,
50,0 )

fileDelete("nametags.lua")
« Son Düzenleme: 25 Şubat 2017, 14:13:19 Gönderen: ConTra »
Linki görebilmek için Kayıt olun yada Giriş yapın.
 


MTASATURK

[YARDIM] Nametags Bind Kapatma
« : 25 Şubat 2017, 13:15:11 »

Çevrimdışı Paradox

  • Kurucu
  • *
    • İleti: 684
  • SH Gaming
Yanıtla #1 : 25 Şubat 2017, 13:18:21
Kullandığın nametag'ı atarsan elimden geldiğince yardımcı olurum.
 


Çevrimdışı ConTra

  • Boş konuşacağına anlamlı sus daha iyidir.
  • Yeni Üye
  • *
    • İleti: 88
Yanıtla #2 : 25 Şubat 2017, 13:47:00
Linki görebilmek için Kayıt olun yada Giriş yapın.
Kullandığın nametag'ı atarsan elimden geldiğince yardımcı olurum.
PM'den ulaştırdım.
Linki görebilmek için Kayıt olun yada Giriş yapın.