Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2020-04-23, 11:42


ADISEQ

Uczeń Lua






Wiek: 21
Na forum: 2952 dni
Posty: 130
Nick w MP: ADISEQ

Piwa: 18

Respekt: 50

Witaj
. Mam proste pytanie. Co zrobi? z tym kodem aby nametagi by?y te? widzialne dla nas samych?
Oto kod:

local sw,sh=guiGetScreenSize()
local timer = false

--local nametagFont = "default"
local nametagFont = dxCreateFont( "f/droid-sans.ttf", 11)
local auta = dxCreateFont( "f/droid-sans.ttf", 10)
if not nametagFont then nametagFont = "default-bold" end
local fontHeight=dxGetFontHeight(1, nametagFont)
local nametagScale = 1
local nametagAlpha = 255
local nametagColor =
{
    r = 255,
    g = 255,
    b = 255
} 

local hp_width=math.floor(sw/20)
if hp_width<50 then hp_width=50 end
local hp_height=math.floor(hp_width/10)

local gsize=sw>800 and 32 or 16


local ourlevel=0
local ourfid=""



setTimer(function()
  ourlevel=getElementData(localPlayer, "level") or 0
  ourfid=getElementData(localPlayer, "player:faction") or ""
end, 15000, 0)

function korona()
    local rootx, rooty, rootz = getCameraMatrix()
    for i, player in ipairs(getElementsByType("player",root,true)) do
        if getElementDimension(localPlayer)==getElementDimension(player) and getElementInterior(localPlayer)==getElementInterior(player) then
            if getElementAlpha(player) < 1 then
            if not getElementData(localPlayer,"player:admin") == true then return end
            end
            local x,y,z = getPedBonePosition(player,6)
            if x and y and z then
                local distance = getDistanceBetweenPoints3D(rootx, rooty, rootz, x, y, z)
                if(distance <= 22) then
                    if isLineOfSightClear( rootx,rooty,rootz, x,y,z, true, false, false, true, false, false, true,localPlayer ) then
                        if getElementData(player,"Ryjek") then
                            if(distance <= 12) then
                                dxDrawMaterialLine3D(x,y,z+1.25,x,y,z+0.35,img,1.1,white)
                            end
                        end
                    end
                end
            end
        end
    end
end

addEventHandler("onClientMinimize", root, function()
    localPlayer:setData("player:minimalized", getTickCount())
    localPlayer:setData("player:tick", getTickCount())
    timer = Timer(function() localPlayer:setData("player:tick", getTickCount()) end, 1000, 0)
end)

addEventHandler("onClientRestore", root, function()
    localPlayer:setData("player:minimalized", false)
    if timer and timer.valid then timer:destroy() end
end)

addEventHandler("onClientRender", root, function()
  local rootx, rooty, rootz = getCameraMatrix()--getElementPosition(getLocalPlayer())
        for i, vehicle in ipairs(getElementsByType("vehicle", root, true)) do
            local opis=getElementData(vehicle,"opis")
            local poziom=tonumber(getElementData(vehicle,"poziom"))
            if poziom then
                opis= (opis and opis or "") .. " zape?nienie: " ..math.floor(math.max(math.min(poziom,100),0)+0.5).."%"
            end
            if (opis) then
            local x,y,z=getElementPosition(vehicle)
            local distance = getDistanceBetweenPoints3D(rootx, rooty, rootz, x, y, z)
            local kierowca=getVehicleController(vehicle)
            if (distance<=15 or (kierowca and kierowca==localPlayer)) then
                local sx,sy = getScreenFromWorldPosition(x,y,z, 200)
                if (sx and sy) then
                    dxDrawText(opis, sx-(sw/5),sy,sx+(sw/5),sy, tocolor(255,255,255,155), 1.0, "default-small", "center","center",false,true)
                end
            end
            end
        end
        
        local ctrl=getKeyState("lalt") or getKeyState("ralt") or getKeyState("lctrl") or getKeyState("rctrl")

        for i, player in ipairs(getElementsByType("player",root,true)) do
            if player ~= localPlayer and (getElementAlpha(player)>50 or ourlevel>1 or getElementDimension(player)==901) then
                local x,y,z = getPedBonePosition(player,8)

                local sx, sy = getScreenFromWorldPosition(x, y, z+0.5)
                if sx then
                        local distance = getDistanceBetweenPoints3D(rootx, rooty, rootz, x, y, z)
                        if getElementAlpha(player) < 1 and not getElementData(localPlayer,"player:admin") then
                        return end
                        
                        local name = "["..getElementData(player, "id").."] "..getPlayerName(player)..""
                        local distance = getDistanceBetweenPoints3D(rootx, rooty, rootz, x, y, z)

                        local fX = math.floor(sx)
                        local fY = math.floor(sy)

                        local alpha = 120

                        if(distance <= 35) then
                            local minimalized = ""
                            local minimal = player:getData("player:minimalized")
                                if minimal then 
                                local tick = player:getData("player:tick")
                                if tick then
                                    local tick = tick - minimal
                                    local sekundy=math.floor(tick/1000) or 0
                                    local godziny = string.format("%02.f", math.floor(sekundy/3600));
                                    local minuty = string.format("%02.f", math.floor(sekundy/60 - (godziny*60)));
                                    local secs = string.format("%02.f", math.floor(sekundy - godziny*3600 - minuty *60));
                                    minimalized = "zminimalizowany(a) od: "..godziny.."h "..minuty.."m "..secs.."s" 
                                    end
                            end
                            local org=getElementData(player,"player:organization")
                            if (ctrl) then
                                local fname=getElementData(player, "player:faction")
                                if (fname) then
                                    dxDrawText(fname, fX, fY+16, fX, fY+16, tocolor(255,255,255,200), nametagScale*0.9, nametagFont, "center", "center")
                                end
                                if org and org.nazwa then
                                    dxDrawText(org.nazwa, fX, fY+15, fX, fY+15, tocolor( 0,   0,  0, 150), nametagScale*1, nametagFont, "center", "center")
                                end
                            end

                            local level = tonumber(getElementData(player, "player:level"))
                            local p_level = tonumber(getElementData(player, "premium:level"))
                            if level == 1 then
                                dxDrawText(minimalized.."", fX, fY, fX, fY, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("["..getElementData(player, "id").."] "..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."", fX+1, fY+1, fX+1, fY+1, tocolor(0,0,0, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("#FFFFFF[#01bf34"..getElementData(player, "id").."#FFFFFF] #FFFFFF"..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."", fX, fY, fX, fY, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("[Moderator]", fX+1, fY-15, fX+1, fY-15, tocolor(0,0,0, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("#FFFFFF[#01bf34Moderator#FFFFFF]", fX, fY-16, fX, fY-16, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                            elseif level == 2 then
                                dxDrawText(minimalized.."\n\n\n\n\n\n", fX, fY, fX, fY, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("["..getElementData(player, "id").."] "..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."", fX+1, fY+1, fX+1, fY+1, tocolor(0,0,0, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("#FFFFFF[#ff0000"..getElementData(player, "id").."#FFFFFF] #FFFFFF"..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."", fX, fY, fX, fY, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("[Administrator]", fX+1, fY-15, fX+1, fY-15, tocolor(0,0,0, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("#FFFFFF[#ff0000Administrator#FFFFFF]", fX, fY-16, fX, fY-16, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                            elseif level == 3 then
                                dxDrawText(minimalized.."\n\n\n\n\n\n", fX, fY, fX, fY, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("["..getElementData(player, "id").."] "..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."", fX+1, fY+1, fX+1, fY+1, tocolor(0,0,0, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("#FFFFFF[#a31303"..getElementData(player, "id").."#FFFFFF] #FFFFFF"..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."", fX, fY, fX, fY, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("[RCON]", fX+1, fY-15, fX+1, fY-15, tocolor(0,0,0, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("#FFFFFF[#a31303RCON#FFFFFF]", fX, fY-16, fX, fY-16, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                            elseif level == 4 then
                                dxDrawText(minimalized.."\n\n\n\n\n\n", fX, fY, fX, fY, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("["..getElementData(player, "id").."] "..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."", fX+1, fY+1, fX+1, fY+1, tocolor(0,0,0, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("#FFFFFF[#8f00ff"..getElementData(player, "id").."#FFFFFF] #FFFFFF"..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."", fX, fY, fX, fY, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("[W?a?ciciel]", fX+1, fY-15, fX+1, fY-15, tocolor(0,0,0, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("#FFFFFF[#8f00ffW?a?ciciel#FFFFFF]", fX, fY-16, fX, fY-16, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                            elseif level == 5 then
                                dxDrawText(minimalized.."\n\n\n\n\n\n", fX, fY, fX, fY, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("["..getElementData(player, "id").."] "..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."", fX+1, fY+1, fX+1, fY+1, tocolor(0,0,0, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("#FFFFFF[#00A693"..getElementData(player, "id").."#FFFFFF] #FFFFFF"..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."", fX, fY, fX, fY, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("[Opiekun]", fX+1, fY-15, fX+1, fY-15, tocolor(0,0,0, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("#FFFFFF[#00A693Opiekun#FFFFFF]", fX, fY-16, fX, fY-16, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                            elseif p_level == 1 then
                                dxDrawText(minimalized.."\n\n\n\n\n\n", fX, fY, fX, fY, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("["..getElementData(player, "id").."] "..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."", fX+1, fY+1, fX+1, fY+1, tocolor(0,0,0, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("#FFFFFF[#f6a104"..getElementData(player, "id").."#FFFFFF] #FFFFFF"..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."", fX, fY, fX, fY, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("[Premium]", fX+1, fY-15, fX+1, fY-15, tocolor(0,0,0, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText("#FFFFFF[#f6a104Premium#FFFFFF]", fX, fY-16, fX, fY-16, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                            else
                                dxDrawText(""..minimalized.."\n\n["..getElementData(player, "id").."] "..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."", fX+1, fY+1, fX+1, fY+1, tocolor(0,0,0, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                                dxDrawText(""..minimalized.."\n\n#FFFFFF[#FFFFFF"..getElementData(player, "id").."#FFFFFF] #FFFFFF"..getPlayerName(player):gsub("#%x%x%x%x%x%x","").."", fX, fY, fX, fY, tocolor(255, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                            end
                            if getElementData(player,"mute:player") then
                            dxDrawText("[Wyciszony]", fX+1, fY-31, fX+1, fY-31, tocolor(0, 0, 0, alpha), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                            dxDrawText("#FFFFFF[#FFFF00Wyciszony#FFFFFF]", fX, fY-32, fX, fY-32, tocolor(0, 255, 255, 255), nametagScale, nametagFont, "center", "center",false,false,false,true,true)
                            end



                            if ourfid=="SAMC" then -- pokazujemy hp innych graczy
                                dxDrawRectangle(fX-hp_width/2-1, fY+fontHeight, hp_width+2, hp_height+2, tocolor(27,27,27,155))
                                local hp=getElementHealth(player)
                                if hp>100 then hp=100 end
                                local hhp_width=(hp*hp_width/100)
                                dxDrawRectangle(fX-hp_width/2, fY+fontHeight+1, hhp_width, hp_height, tocolor(255,5,5,155))
                            end

                            local opis=getElementData(player, "opis")
                            if opis then
                                local alpha=255-getDistanceBetweenPoints2D(sw/2,sh/2,sx,sy)

                                if alpha>5 then
                                    local sx, sy = getScreenFromWorldPosition(x, y, z-0.5)
                                    if sx and sy then
                                        dxDrawText(opis, sx-(sw/10),sy,sx+(sw/10),sy, tocolor(255,255,255,alpha), 1.0, "default-small", "center","center",false,true)
                                    end
                                end
                            end
                        end
                end
            end
        end    

        for i, ped in ipairs(getElementsByType("ped",root,true)) do
            local name=getElementData(ped,"name")
            if name then
                local x,y,z = getElementPosition(ped)
                local sx, sy = getScreenFromWorldPosition(x, y, z + 1)

                if sx then
                    local distance = getDistanceBetweenPoints3D(rootx, rooty, rootz, x, y, z)

                    local fX = sx
                    local fY = sy

                    local alpha = 120

                    if(distance <= 8 and isLineOfSightClear(rootx,rooty,rootz,x,y,z,false,false,false)) then
                        dxDrawText(name, fX, fY, fX, fY, tocolor(0, 0, 0, alpha), nametagScale, nametagFont, "center", "center")                    
                    end
                end
            end
        end  

        for i,vehicle in ipairs(getElementsByType("vehicle")) do
        local x,y,z=getElementPosition(vehicle)
        local sx,sy=getScreenFromWorldPosition(x,y,z)
        if sx and sy then
            local desc=getElementData(vehicle,"vehicle:desc")
            if desc then
                local veh = getPedOccupiedVehicle(localPlayer)
                local distance=getDistanceBetweenPoints3D(rootx,rooty,rootz,x,y,z)
                if distance <= 25 then
                    if isLineOfSightClear( rootx,rooty,rootz, x,y,z, true, true, false, true, false, true, true,vehicle ) then
                        dxDrawText(desc:gsub("#%x%x%x%x%x%x",""), sx-(sw/10)+1,sy+1,sx+(sw/10)+1,sy+1, tocolor(0,0,0,alpha), 1.0, auta, "center","center",false,true,false,true)
                    dxDrawText(desc:gsub("#%x%x%x%x%x%x",""), sx-(sw/10),sy,sx+(sw/10),sy, tocolor(255,255,255,alpha), 1.0, auta, "center","center",false,true,false,true)
                    end
                end
            end
        end
    end
end)

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
    function()
        for k, v in ipairs(getElementsByType("player")) do
            setPlayerNametagShowing ( v, false )
        end
    end
)

addEventHandler("onClientPlayerJoin", root, 
--addEventHandler("onClientPlayerSpawn", getRootElement(), 
    function()
        setPlayerNametagShowing ( source, false )
    end
)

fileDelete("nametags_c.lua")



Licz? na szybk? odpowied?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-04-23, 12:31


Szyszka947

ASP NET Core / Lua






Wiek: 19
Na forum: 2720 dni
Posty: 288

Piwa: 16

Respekt: 90

Zamie? to:

 if player ~= localPlayer and (getElementAlpha(player)>50 or ourlevel>1 or getElementDimension(player)==901) then

na to:

 if (getElementAlpha(player)>50 or ourlevel>1 or getElementDimension(player)==901) then


Komentarz Wilq dodany 2020-04-23, 13:39Poprawiłem tagi LUA, żeby to było czytelne.
Ostatnio zmieniony przez Wilq 2020-04-23, 13:39, w całości zmieniany 2 razy  
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
ADISEQ
Wysłany: 2020-04-23, 22:02


ADISEQ

Uczeń Lua






Wiek: 21
Na forum: 2952 dni
Posty: 130
Nick w MP: ADISEQ

Piwa: 18

Respekt: 50

Dzi?kuj? bardzo. Wszytko dzia?a daj? ci piwko+reputacj? za pomoc :roll:

Postaw piwo autorowi tego posta
 

 
Tagi: nametagi
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Nametagi Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku