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

Wysłany: 2020-12-04, 14:44


xyzzzikk

.gg






Wiek: 18
Na forum: 2774 dni
Posty: 175
Nick w MP: aspyk

Piwa: 6499

Respekt: 30,5

Nada?em hud'owi elementdate "hud" po wci?ni?ciu f2 powinnen znika? lecz nie znika

--last edit

local sxsy guiGetScreenSize()
setPlayerHudComponentVisible("all"false)
setPlayerHudComponentVisible("radar"true)

function sw(value)
    return sx*value/1920    
end
            
function sh(value)    
    return sy*value/1080
end

setElementData(localPlayer"hud"true)
local font dxCreateFont("gtav.ttf"sw(20))
local font2 dxCreateFont("normal.ttf"sw(14))
local pos={
    server = { 2700= -525825627},
    imgHud = { 0019201080},
    imgKolo = { 00115115}
}
local images={
    hud dxCreateTexture('img/hud.png''argb'false'clamp'),
    pasek dxCreateTexture('img/pasek.png''argb'false'clamp'),
    kolo dxCreateTexture(':rn_avatars/kolo.png''argb'false'clamp'),
}


function render()
    local player={
        name getPlayerName(localPlayer),
        money przecinek(getElementData(localPlayer"player:money") or 0)
    }
        
    dxDrawImage(sw(pos["imgHud"].x), sh(pos["imgHud"].y), sw(pos["imgHud"].w), sh(pos["imgHud"].h), images.hud000tocolor(255,255,255,200), false)
    dxDrawImage(sw(pos["imgHud"].x), sh(pos["imgHud"].y), sw(pos["imgHud"].w), sh(pos["imgHud"].h), images.pasek000tocolor(255,255,255,200), false)
    dxDrawImage(sw(pos["imgHud"].x+1535), sh(pos["imgHud"].y+63), sw(pos["imgKolo"].w), sh(pos["imgKolo"].h), images.kolo000tocolor(255,255,255,200), false)
    exports["rn_avatars"]:dxCreateAvatar(sw(pos["imgHud"].x+1535), sh(pos["imgHud"].y+63), sw(pos["imgKolo"].w), sh(pos["imgKolo"].h))

  dxDrawText(player.namesw(pos["server"].1160), sw(pos["server"].2), sw(pos["server"].w), sw(pos["server"].h), tocolor(230230230255), 1.00font,"left","center"truetruetruetruetrue)
   dxDrawText(""..player.money.." PLN"sw(pos["server"].x), sw(pos["server"].240), sw(pos["server"].w+1025), sw(pos["server"].h), tocolor(230230230255), 1.00font2"right""center"truetruetruetruetrue)
    if getElementData(localPlayer"player:premiumplus"then 
        dxDrawText("#fcdf03Premium+"sw(pos["server"].125), sw(pos["server"].2), sw(pos["server"].w), sw(pos["server"].h), tocolor(230230230255), 1.00font"center""center"truetruetruetruetrue)
   end
end
addEventHandler("onClientRender"rootrender)

bindKey("F2""down", function()
    if getElementData(localPlayer"hud"then
        setElementData(localPlayer"hud"false)
        showChat(false)
    else
        setElementData(localPlayer"hud"true)
        showChat(true)
    end
end)

function przecinek(liczba)  
    local format liczba  
    while true do      
        formatstring.gsub(format"^(-?%d+)(%d%d%d)"'%1,%2')    
        if ( k==then      
            break  
        end  
    end  
    return format
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-04, 14:57


Szypki_exe







Wiek: 21
Na forum: 3239 dni
Posty: 172

Piwa: 1426

Respekt: 150
Respekt: 150Respekt: 150

w kodzie nie masz uwzgl?dnionego znikania hudu, to tylko elementdata
je?li chcesz przesta? renderowa? hud to zastosuj w funkcji binda poprostu

Więcej informacji znajdziesz w Wikipedii MTA:

removeEventHandler


Więcej informacji znajdziesz w Wikipedii MTA:

onClientRender

i nast?pnie pojawi? go mo?esz identycznie tylko zamiast remove stosujesz

Więcej informacji znajdziesz w Wikipedii MTA:

addEventHandler

b?d? mo?esz u?y?

Więcej informacji znajdziesz w Wikipedii MTA:

onClientElementDataChange


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-04, 15:24


EnoNeK







Wiek: 21
Na forum: 3287 dni
Posty: 39
Nick w MP: EnoNeK

Piwa: 54

Respekt: 200
Respekt: 200Respekt: 200

Czyli w praktyce z elementdat?
--last edit

local sxsy guiGetScreenSize()
setPlayerHudComponentVisible("all"false)
setPlayerHudComponentVisible("radar"true)

function sw(value)
    return sx*value/1920    
end
            
function sh(value)    
    return sy*value/1080
end

setElementData(localPlayer"hud"true)
local font dxCreateFont("gtav.ttf"sw(20))
local font2 dxCreateFont("normal.ttf"sw(14))
local pos={
    server = { 2700= -525825627},
    imgHud = { 0019201080},
    imgKolo = { 00115115}
}
local images={
    hud dxCreateTexture('img/hud.png''argb'false'clamp'),
    pasek dxCreateTexture('img/pasek.png''argb'false'clamp'),
    kolo dxCreateTexture(':rn_avatars/kolo.png''argb'false'clamp'),
}


function render()
if getElementData(localPlayer"hud"then
    local player={
        name getPlayerName(localPlayer),
        money przecinek(getElementData(localPlayer"player:money") or 0)
    }
        
    dxDrawImage(sw(pos["imgHud"].x), sh(pos["imgHud"].y), sw(pos["imgHud"].w), sh(pos["imgHud"].h), images.hud000tocolor(255,255,255,200), false)
    dxDrawImage(sw(pos["imgHud"].x), sh(pos["imgHud"].y), sw(pos["imgHud"].w), sh(pos["imgHud"].h), images.pasek000tocolor(255,255,255,200), false)
    dxDrawImage(sw(pos["imgHud"].x+1535), sh(pos["imgHud"].y+63), sw(pos["imgKolo"].w), sh(pos["imgKolo"].h), images.kolo000tocolor(255,255,255,200), false)
    exports["rn_avatars"]:dxCreateAvatar(sw(pos["imgHud"].x+1535), sh(pos["imgHud"].y+63), sw(pos["imgKolo"].w), sh(pos["imgKolo"].h))

  dxDrawText(player.namesw(pos["server"].1160), sw(pos["server"].2), sw(pos["server"].w), sw(pos["server"].h), tocolor(230230230255), 1.00font,"left","center"truetruetruetruetrue)
   dxDrawText(""..player.money.." PLN"sw(pos["server"].x), sw(pos["server"].240), sw(pos["server"].w+1025), sw(pos["server"].h), tocolor(230230230255), 1.00font2"right""center"truetruetruetruetrue)
    if getElementData(localPlayer"player:premiumplus"then 
        dxDrawText("#fcdf03Premium+"sw(pos["server"].125), sw(pos["server"].2), sw(pos["server"].w), sw(pos["server"].h), tocolor(230230230255), 1.00font"center""center"truetruetruetruetrue)
   end
end
end
addEventHandler("onClientRender"rootrender)

bindKey("F2""down", function()
    if getElementData(localPlayer"hud"then
        setElementData(localPlayer"hud"false)
        showChat(false)
    else
        setElementData(localPlayer"hud"true)
        showChat(true)
    end
end)

function przecinek(liczba)  
    local format liczba  
    while true do      
        formatstring.gsub(format"^(-?%d+)(%d%d%d)"'%1,%2')    
        if ( k==then      
            break  
        end  
    end  
    return format
end


Postaw piwo autorowi tego posta
 

 
Tagi: hud :: nie :: znika
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » hud nie znika 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