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

Wysłany: 2018-03-07, 23:22


Yami

Mapper / Uczeń LUA






Wiek: 25
Na forum: 3200 dni
Posty: 379

Piwa: 97

Respekt: 235
Respekt: 235Respekt: 235

Siemka
Bo mam ma?y problem, ot?? posiadam hud i gdy wchodz? na serwer to gdy ju? wejde na niego ale nawet si? jeszcze nie zaloguje to wida? hud z pieni?dzmi itd.
I st?d pytanie, czy da sie zrobi? ?e dopiero po zalogowaniu by sie pokazywa?, i je?li tak to jak?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-03-08, 00:53


.RiV







Wiek: 26
Na forum: 3729 dni
Posty: 554
Nick w MP: Split

Piwa: 2598

Respekt: 597,8
Respekt: 597,8

Przy otwieraniu panelu logowania ustaw graczowi warto??

setElementData(localPlayer, "loguje_sie", true)


Przy zamykaniu panelu logowania usu? graczowi warto??

setElementData(localPlayer, "loguje_sie", false)


Przy renderingu hud'u wstaw warunek

if getElementData(localPlayer, "loguje_sie") then return nil end


Podpis

Autor OGRPG, na scenie MTA od 2012 roku.




Użytkownik: 08.08.2016
GTAO Member: 06.02.2017
Support-Team: 17.06.2017 & 01.06.2019 - 18.11.2019
Moderator: 14.01.2018 - 09.08.2018

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-03-08, 17:00


Yami

Mapper / Uczeń LUA






Wiek: 25
Na forum: 3200 dni
Posty: 379

Piwa: 97

Respekt: 235
Respekt: 235Respekt: 235

A gdzie to dok?adnie doda??
S-Side

function findPlayer(plr,cel)
    local target=nil
    if (tonumber(cel) ~= nil) then
        target=getElementByID("p"..cel)
    else -- podano fragment nicku
        for _,thePlayer in ipairs(getElementsByType("player")) do
            if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), cel:lower(), 1, true) then
                if (target) then
                    outputChatBox("Znaleziono wiecej niz jednego gracza o pasujacym nicku, podaj wiecej liter.", plr)
                    return nil
                end
                target=thePlayer
            end
        end
    end
    return target
end

local function findFreeValue(tablica_id)
    table.sort(tablica_id)
    local wolne_id=0
    for i,v in ipairs(tablica_id) do
        if (v==wolne_id) then wolne_id=wolne_id+1 end
        if (v>wolne_id) then return wolne_id end
    end
    return wolne_id
end

function assignPlayerID(plr)
    local gracze=getElementsByType("player")
    local tablica_id = {}
    for i,v in ipairs(gracze) do
        local lid=getElementData(v, "id")
        if (lid) then
            table.insert(tablica_id, tonumber(lid))
        end
    end
    local free_id=findFreeValue(tablica_id)
    
    setElementData(plr,"id", free_id)
    setElementID(plr, "p" .. free_id)
    return free_id
end

function getPlayerID(plr)
    if not plr then return "" end
    local id=getElementData(plr,"id")
    if (id) then
        return id
    else
        return assignPlayerID(plr)
    end
    
end

addEventHandler ("onPlayerJoin", getRootElement(), function()
    assignPlayerID(source)
end)


C-Side

local fontm = dxCreateFont("font.otf", 16)

--SKALOWANIE GUI--
local screenW, screenH = guiGetScreenSize()
local w, h = (screenW/1920), (screenH/1080)

local ranga = "brak"
--------------------------------------------
addEventHandler("onClientRender", root, function()
    setPlayerHudComponentVisible("all", false)
    local hp = math.floor(getElementHealth(localPlayer))
    local nickname =  getPlayerName(localPlayer)
    local money = getPlayerMoney(localPlayer)
    dxDrawImage(1600*w, 50*h, 301*w, 130*h, "images/bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawText(nickname.."[#00fff2"..getElementData(localPlayer, "id").."#FFFFFF]", 3500*w, 60*h, 0, 0, tocolor(255, 255, 255, 255), 1, fontm, 'center', 'top', false, false, false, true)
    dxDrawText(hp.."%", 1830*w, 103*h, 0, 0, tocolor(255, 255, 255, 255), 0.8, fontm, 'left', 'top', false, false, false, true)
    dxDrawText(money.."$", 1660*w, 103*h, 0, 0, tocolor(255, 255, 255, 255), 0.8, fontm, 'left', 'top', false, false, false, true)    
    if getElementData(localPlayer, "rank") == 1 then
        ranga = "#FFFFFFGracz"
    end
    if getElementData(localPlayer, "rank") == 2 then
        ranga = "#40ff23Moderator"
    end
    dxDrawText(ranga, 3490*w, 150*h, 0, 0, tocolor(255, 255, 255, 255), 0.8, fontm, 'center', 'top', false, false, false, true)
end)



Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-03-08, 17:42


jagoreq







Wiek: 24
Na forum: 3362 dni
Posty: 221
Nick w MP: dwd

Piwa: 18

Respekt: 66,3

Ostrzeżeń: 20%
local fontm = dxCreateFont("font.otf", 16)

--SKALOWANIE GUI--
local screenW, screenH = guiGetScreenSize()
local w, h = (screenW/1920), (screenH/1080)

local ranga = "brak"
--------------------------------------------
addEventHandler("onClientRender", root, function()
    if getElementData(localPlayer, "p:logged") == true then
        setPlayerHudComponentVisible("all", false)
        local hp = math.floor(getElementHealth(localPlayer))
        local nickname =  getPlayerName(localPlayer)
        local money = getPlayerMoney(localPlayer)
        dxDrawImage(1600*w, 50*h, 301*w, 130*h, "images/bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText(nickname.."[#00fff2"..getElementData(localPlayer, "id").."#FFFFFF]", 3500*w, 60*h, 0, 0, tocolor(255, 255, 255, 255), 1, fontm, 'center', 'top', false, false, false, true)
        dxDrawText(hp.."%", 1830*w, 103*h, 0, 0, tocolor(255, 255, 255, 255), 0.8, fontm, 'left', 'top', false, false, false, true)
        dxDrawText(money.."$", 1660*w, 103*h, 0, 0, tocolor(255, 255, 255, 255), 0.8, fontm, 'left', 'top', false, false, false, true)    
        if getElementData(localPlayer, "rank") == 1 then
            ranga = "#FFFFFFGracz"
        end
        if getElementData(localPlayer, "rank") == 2 then
            ranga = "#40ff23Moderator"
        end
        dxDrawText(ranga, 3490*w, 150*h, 0, 0, tocolor(255, 255, 255, 255), 0.8, fontm, 'center', 'top', false, false, false, true)
    end
end)


teraz jak masz edate p:logged na true to widzisz hud, a jak na false to nie widzisz hudu.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-03-08, 17:44


Hiroszekk







Wiek: 24
Na forum: 3453 dni
Posty: 113
Nick w MP: Hiroszek

Piwa: 845

Respekt: -84,3

Ostrzeżeń: 20%
Je?eli korzystasz z OG to kod poni?ej powinien poprawi?, doda?em
    if not getElementData(localPlayer,"player:logged") then return end

ElementData "player:logged" dodaje si? w og po zalogowaniu.


local fontm = dxCreateFont("font.otf", 16)

--SKALOWANIE GUI--
local screenW, screenH = guiGetScreenSize()
local w, h = (screenW/1920), (screenH/1080)

local ranga = "brak"
--------------------------------------------
addEventHandler("onClientRender", root, function()
    if not getElementData(localPlayer,"player:logged") then return end
    setPlayerHudComponentVisible("all", false)
    local hp = math.floor(getElementHealth(localPlayer))
    local nickname =  getPlayerName(localPlayer)
    local money = getPlayerMoney(localPlayer)
    dxDrawImage(1600*w, 50*h, 301*w, 130*h, "images/bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawText(nickname.."[#00fff2"..getElementData(localPlayer, "id").."#FFFFFF]", 3500*w, 60*h, 0, 0, tocolor(255, 255, 255, 255), 1, fontm, 'center', 'top', false, false, false, true)
    dxDrawText(hp.."%", 1830*w, 103*h, 0, 0, tocolor(255, 255, 255, 255), 0.8, fontm, 'left', 'top', false, false, false, true)
    dxDrawText(money.."$", 1660*w, 103*h, 0, 0, tocolor(255, 255, 255, 255), 0.8, fontm, 'left', 'top', false, false, false, true)    
    if getElementData(localPlayer, "rank") == 1 then
        ranga = "#FFFFFFGracz"
    end
    if getElementData(localPlayer, "rank") == 2 then
        ranga = "#40ff23Moderator"
    end
    dxDrawText(ranga, 3490*w, 150*h, 0, 0, tocolor(255, 255, 255, 255), 0.8, fontm, 'center', 'top', false, false, false, true)
end)


Je?eli nie korzystasz z og nadawaj dla gracza po zalogowaniu element date "player:logged".

Postaw piwo autorowi tego posta
 

 
Tagi: widocznośc :: huda
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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