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

Wysłany: 2016-02-25, 11:26


andrzej80

Amator Lua :D






Wiek: 29
Na forum: 3778 dni
Posty: 74
Nick w MP: andrzej80

Piwa: 1

Respekt: 50

Witam, mam problem z dxScoreboard - pr?buj? doda? kolumn? z ID poni?szym kodem - kolumna jest, ale nie ma id :/

call(getResourceFromName("scoreboard"), "scoreboardAddColumn""ID")

addEventHandler("onClientRender"root,
    function ()
        id getElementData(plr,"id")
        setElementData(plr"ID"tonumber(id))
    end
)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-25, 11:39


#404







Wiek: 26
Na forum: 4772 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%
andrzej80, a kto to jest plr?

U?yj zmiennej pod kt?r? zawsze po stronie client'a kryje si? gracz czyli localPlayer.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-25, 11:44


andrzej80

Amator Lua :D






Wiek: 29
Na forum: 3778 dni
Posty: 74
Nick w MP: andrzej80

Piwa: 1

Respekt: 50

call(getResourceFromName("scoreboard"), "scoreboardAddColumn""ID")

addEventHandler("onClientRender"root,
    function ()
        id getElementData(localPlayer,"id")
        setElementData(localPlayer"ID"tonumber(id))
    end
)


Tak te? nie dzia?a :/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-25, 11:50


_Wicek_

Majstersztyk






Wiek: 25
Na forum: 4260 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1841

Respekt: 360,5
Respekt: 360,5Respekt: 360,5Respekt: 360,5Respekt: 360,5

Ostrzeżeń: 40%
Strona Servera


addEventHandler("onResourceStart"resourceRoot,
    function ()
    for _,v in ipairs(getElementsByType("player")) do
        local punkty getElementData(v,"ID")
    end
end)


Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-25, 12:03


andrzej80

Amator Lua :D






Wiek: 29
Na forum: 3778 dni
Posty: 74
Nick w MP: andrzej80

Piwa: 1

Respekt: 50

Nadal nic :/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-25, 12:11


_Wicek_

Majstersztyk






Wiek: 25
Na forum: 4260 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1841

Respekt: 360,5
Respekt: 360,5Respekt: 360,5Respekt: 360,5Respekt: 360,5

Ostrzeżeń: 40%
andrzej80, A mo?e tak , masz ju? przydzielon? elementDat? na ID ?

Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-25, 12:19


andrzej80

Amator Lua :D






Wiek: 29
Na forum: 3778 dni
Posty: 74
Nick w MP: andrzej80

Piwa: 1

Respekt: 50

Dodam, ?e to mam po??czone z system nadawania id :D

Mo?e podam ca?y kod:

function findPlayer(plr,cel)
    local target=nil
    if (tonumber(cel) ~= nilthen
        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(), 1truethen
                if (targetthen
                    outputChatBox("> Znaleziono wi?cej ni? jednego gracza o pasuj?cym nicku, podaj wi?cej 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_idthen wolne_id=wolne_id+1 end
        if (v>wolne_idthen 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 (lidthen
            table.insert(tablica_idtonumber(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 (idthen
        return id
    else
        return assignPlayerID(plr)
    end
    
end

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


call(getResourceFromName("scoreboard"), "scoreboardAddColumn""ID")

addEventHandler("onResourceStart"resourceRoot,
    function ()
    for _,v in ipairs(getElementsByType("player")) do
        local punkty getElementData(v,"ID")
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-25, 12:22


_Wicek_

Majstersztyk






Wiek: 25
Na forum: 4260 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1841

Respekt: 360,5
Respekt: 360,5Respekt: 360,5Respekt: 360,5Respekt: 360,5

Ostrzeżeń: 40%
addEventHandler("onResourceStart"resourceRoot,
    function ()
    call(getResourceFromName("scoreboard"),"addScoreboardColumn","ID")
    for _,v in ipairs(getElementsByType("player")) do
        local id_gracza getElementData(v,"id")
    end
end)


Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-25, 12:30


andrzej80

Amator Lua :D






Wiek: 29
Na forum: 3778 dni
Posty: 74
Nick w MP: andrzej80

Piwa: 1

Respekt: 50

Nadal tak samo - kolumna si? tworzy, id nie wy?wietla :?

[ Dodano: 2016-02-25, 16:32 ]
Okej, do zamkni?cia, poszuka?em podobnych problem?w na gtaO, i metod? pr?b i b??d?w uda?o si? :D

Postaw piwo autorowi tego posta
 

 
Tagi: kolumna :: scoreboard
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