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

Wysłany: 2017-12-21, 18:48


EvilXmik







Wiek: 28
Na forum: 3620 dni
Posty: 148
Nick w MP: EvilXmik

Piwa: 399

Respekt: 50

Witam mam takie pytanie jak zrobi? ?eby w tym skrypcie je?eli mam alphe 0 to nametag znika


srfont dxCreateFont("DFHEIMDU_id.ttf",16)

g_Root getRootElement()
g_ResRoot getResourceRootElement(getThisResource())
g_Players getElementsByType('player')
g_Me getLocalPlayer()
 
nametag = {}
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 100 --Distance until we're gone
local NAMETAG_ALPHA = 255 --The overall alpha level of the nametag
--The following arent actual pixel measurements, they're just proportional constraints
local NAMETAG_TEXT_BAR_SPACE 1
local NAMETAG_WIDTH 50
local NAMETAG_HEIGHT 5
local NAMETAG_TEXTSIZE 0.3
local NAMETAG_OUTLINE_THICKNESS 1.2
 
 
--
local NAMETAG_ALPHA_DIFF NAMETAG_DISTANCE NAMETAG_ALPHA_DISTANCE
NAMETAG_SCALE 1/NAMETAG_SCALE 800 g_screenY
 
-- 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 = { {00.8}, {0.81.2}, {9999} }
-- Make the text a bit brighter and fade more gradually
local textAlphaCurve = { {00}, {25100}, {120190}, {255190} }
 
setPedTargetingMarkerEnabled false ) 
 
function nametag.create player )
    nametags[player] = true
end
 
function nametag.destroy player )
    nametags[player] = nil
end

addEventHandler "onClientPreRender"g_Root,
    function()
        if getElementData(getLocalPlayer(), "state.hud") == "disabled" then
        return
        end
        -- Hideous quick fix --
        for i,player in ipairs(g_Players) do
            if isElement(playerthen
                if player ~= g_Me then
                    setPlayerNametagShowing playerfalse )
                    if not nametags[playerthen
                        nametag.create player )
                    end
                end
            end
        end
        if bHideNametags then
            return
        end
        local x,y,getCameraMatrix()
   
        for player in pairs(nametags) do
            while true do
                if not isElement(playerthen break end
                if getElementDimension(player) ~= getElementDimension(g_Methen break end
                local px,py,pz getElementPosition player )
                if not isLineOfSightClear(xyzpxpypztruefalsefalsetruefalsetruethen break end
                local pdistance getDistanceBetweenPoints3D x,y,z,px,py,pz )
                if pdistance <= NAMETAG_DISTANCE then
                    --Get screenposition
                    local sx,sy getScreenFromWorldPosition pxpypz+0.950.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)
                    scale math.evalCurve(maxScaleCurve,scale)
                    local textscale math.evalCurve(textScaleCurve,scale)
                    local textalpha math.evalCurve(textAlphaCurve,alpha)
                    local outlineThickness NAMETAG_OUTLINE_THICKNESS*(scale)
                    --Draw our text
                    local playerName getPlayerName(player):gsub("#%x%x%x%x%x%x","")
                    local r,g,getPlayerNametagColor(player)
                    local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2
                    local w dxGetTextWidth(playerNametextscale NAMETAG_TEXTSIZEsrfont) / 2
                    local myR getElementData(localPlayer"reputation.reputation")
                    local playerR getElementData(player"reputation.reputation")
                    
                    local drawX sx NAMETAG_WIDTH*scale/2
                    drawY sy offset
                    local width,height =  NAMETAG_WIDTH*scaleNAMETAG_HEIGHT*scale
                    dxDrawText playerNamesxsy offsetsxsy offsettocolor(0,0,0,255), textscale*NAMETAG_TEXTSIZEsrfont"center""bottom"falsefalsefalsetruetrue )
                        if myR and playerR then
                            if getElementData(localPlayer"reputation.criminal") == false and getElementData(player"reputation.criminal") == false then
                            rrrgrb 158210229
                            elseif getElementData(localPlayer"reputation.criminal") == true and getElementData(player"reputation.criminal") == false then
                            rrrgrb 2172531
                            elseif getElementData(localPlayer"reputation.criminal") == false and getElementData(player"reputation.criminal") == true then
                            rrrgrb 2172531
                            elseif getElementData(localPlayer"reputation.criminal") == true and getElementData(player"reputation.criminal") == true then
                            rrrgrb 24623189
                            end
                        else
                        rrrgrb rgb
                        end
                    dxDrawText playerNamesxsy offsetsxsy offsettocolor(rr,rg,rb,255), textscale*NAMETAG_TEXTSIZEsrfont"center""bottom"falsefalsefalsetruetrue )            
                    nameWidth dxGetTextWidth playerNametextscale*NAMETAG_TEXTSIZEsrfont )
                    teamWidth nameWidth
                    local team getPlayerTeam(player)
                        if team then
                        dxDrawText "["..getTeamName(team).."]"sxsy offset 6*scalesxsy offset 6*scaletocolor(0,0,0,255), textscale*NAMETAG_TEXTSIZE*0.75srfont"center""bottom"falsefalsefalsetruetrue )
                        dxDrawText "["..getTeamName(team).."]"sxsy offset 6*scalesxsy offset 6*scaletocolor(rr,rg,rb,255), textscale*NAMETAG_TEXTSIZE*0.75srfont"center""bottom"falsefalsefalsetruetrue )
                        teamWidth dxGetTextWidth "["..getTeamName(team).."]"textscale*NAMETAG_TEXTSIZE*0.75srfont )
                        end
                    local imageSize dxGetFontHeight textscale*NAMETAG_TEXTSIZEsrfont )
                        if getElementData(player"reputation.class") and fileExists ":reputation/class/classicon_"..getElementData(player"reputation.class")..".png" then
                           dxDrawImage sx math.max(nameWidth/2teamWidth/2) - imageSize 1*scalesy imageSizeimageSizeimageSize":reputation/class/classicon_"..getElementData(player"reputation.class")..".png" )
                           end
                           if getElementData(player"reputation.status") and fileExists ":reputation/reputation/goodevil_"..getElementData(player"reputation.status")..".png" then
                           dxDrawImage sx math.max(nameWidth/2teamWidth/2) + 1*scalesy imageSizeimageSizeimageSize":reputation/reputation/goodevil_"..getElementData(player"reputation.status")..".png" )
                           end 
                end
                break
            end
        end
    end
)
 
 
---------------THE FOLLOWING IS THE MANAGEMENT OF NAMETAGS-----------------
addEventHandler('onClientResourceStart'g_Root,
    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 sourcefalse )
        nametag.create source )
    end
)
 
addEventHandler "onClientPlayerQuit"g_Root,
    function()
        nametag.destroy source )
    end
)
 
-- Math functions
function math.lerp(from,to,alpha)
    return from + (to-from) * alpha
end
 
-- curve is { {x1y1}, {x2y2}, {x3y3} ... }
function math.evalCurvecurveinput )
    -- First value
    if input<curve[1][1then
        return curve[1][2]
    end
    -- Interp value
    for idx=2,#curve do
        if input<curve[idx][1then
            local x1 curve[idx-1][1]
            local y1 curve[idx-1][2]
            local x2 curve[idx][1]
            local y2 curve[idx][2]
            -- Find pos between input points
            local alpha = (input x1)/(x2 x1);
            -- Map to output points
            return math.lerp(y1,y2,alpha)
        end
    end
    -- Last value
    return curve[#curve][2]
end

function dxDrawColorText(straxaybxbycolorscalefont,alignX,alignY,clipwordBreakpostGUI)
  local pat "(.-)#(%x%x%x%x%x%x)"
  local secapcol str:find(pat1)
  local last 1
  while do
    if ~= or cap ~= "" then 
      local w dxGetTextWidth(capscalefont)
      dxDrawText(capaxayax wbycolorscalefont,alignX,alignY,clipwordBreakpostGUI)
      ax ax w
      color tocolor(tonumber("0x"..string.sub(col12)), tonumber("0x"..string.sub(col34)), tonumber("0x"..string.sub(col56)), 255)
    end
    last e+1
    secapcol str:find(patlast)
  end
  if last <= #str then
    cap str:sub(last)
    local w dxGetTextWidth(capscalefont)
    dxDrawText(capaxayax wbycolorscalefont,alignX,alignY,clipwordBreakpostGUI)
  end
end    


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-12-21, 18:50


Kalizman







Wiek: 23
Na forum: 3652 dni
Posty: 1394

Piwa: 4619

Respekt: 358,8
Respekt: 358,8Respekt: 358,8Respekt: 358,8Respekt: 358,8

Nadaj wtedy elementdata, i w nametagu np. sprawdzasz czy ma elementdat?, je?eli tak to ustaw tekst na alpha 0, lub jakie? inne sposoby...

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-12-22, 00:12


Eitho







Wiek: 24
Na forum: 3489 dni
Posty: 330
Nick w MP: Eitho

Piwa: 746

Respekt: 256,5
Respekt: 256,5Respekt: 256,5Respekt: 256,5

if getElementAlpha(player) == 0 then break end


spr?buj to wcisnac po
if getElementDimension(player) ~= getElementDimension(g_Methen break end


Podpis
good old days :]
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
EvilXmik
Wysłany: 2017-12-22, 00:33


EvilXmik







Wiek: 28
Na forum: 3620 dni
Posty: 148
Nick w MP: EvilXmik

Piwa: 399

Respekt: 50

dobra to dzia?a dzi?ki a dasz rade mi pom?c co zrb ?eby te? blip znika? ?


root getRootElement ()
color = { 0255}
players = {}
resourceRoot getResourceRootElement getThisResource () )

function onResourceStart resource )
      for idplayer in ipairsgetElementsByType "player" ) ) do
        if getElementData(player"player:admin"then
            createBlipAttachedTo player022550)
        else
            createBlipAttachedTo player02color[1], color[2], color[3] )
        end
    end
end

function onPlayerSpawn spawnpoint )
    if getElementData(source"player:admin"then
        createBlipAttachedTo source022550)
    else
        createBlipAttachedTo source02color[1], color[2], color[3] )
    end
end

function onPlayerQuit ()
    destroyBlipsAttachedTo source )
end

function onPlayerWasted totalammokillerkillerweapon )
    destroyBlipsAttachedTo source )
end

function outputChange(dataName,oldValue)
    if getElementType(source) == "player" and dataName == "player:admin" then    -- check if the element is a player
        local newValue getElementData(source,"duty") -- find the new value
        if newValue == true then
            destroyBlipsAttachedTo source )
            createBlipAttachedTo source022550)
        else
            destroyBlipsAttachedTo source )
            createBlipAttachedTo source02color[1], color[2], color[3] )
        end
    end
end
addEventHandler("onElementDataChange",getRootElement(),outputChange)
addEventHandler "onResourceStart"resourceRootonResourceStart )
addEventHandler "onPlayerSpawn"rootonPlayerSpawn )
addEventHandler "onPlayerQuit"rootonPlayerQuit )
addEventHandler "onPlayerWasted"rootonPlayerWasted )

function destroyBlipsAttachedTo(player)
    local attached getAttachedElements player )
    if ( attached then
        for k,element in ipairs(attached) do
            if getElementType element ) == "blip" then
                destroyElement element )
            end
        end
    end
end


Postaw piwo autorowi tego posta
 

 
Tagi: znikanie :: nametagu :: invie
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Znikanie nametagu na inv'ie 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