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

Wysłany: 2016-05-05, 23:02


FaydenFX.







Wiek: 27
Na forum: 4197 dni
Posty: 246
Nick w MP: faydn

Piwa: 11

Respekt: 45,3

Witam, pom?g? by kto? zmieni? logi serwerowe i raporty tak, ?eby nie by?y na MySQL , tylko ACL? ;x




local xtext=nil
local gameView={"Logi serwerowe"}
local reportView={"Lista raport?w"}
local sx,sy=guiGetScreenSize()

addEventHandler("onClientRender", root, function()
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "RCON" ) ) then
    concat=table.concat(gameView, "\n")
    dxDrawText(concat, sx*(10+1)/1024, sy*(279+1)/768, sx*(326+1)/1024, sy*(497+1)/768, tocolor(0, 0, 0, 255), 1.00, "default", "left", "top", false, true)
    dxDrawText(concat, sx*(10)/1024, sy*(279)/768, sx*(326)/1024, sy*(497)/768, white, 1.00, "default", "left", "top", false, true)
end)

function renderingInfo()
dxDrawRectangle(sx*(258)/1024, sy*(0)/768, sx*(500)/1024, sy*(23)/768, tocolor(0, 0, 0, 155), false)
    dxDrawText(xtext, sx*(258+1)/1024, sy*(0+1)/768, sx*(758+1)/1024, sy*(23+1)/768, tocolor(0, 0, 0, 255), 1.00, "default", "center", "center", false, true)
    dxDrawText(xtext, sx*(258)/1024, sy*(0)/768, sx*(758)/1024, sy*(23)/768, tocolor(255, 0, 0, 255), 1.00, "default", "center", "center", false, true)
end

addEventHandler("onClientRender", root, function()
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "RCON" ) ) then
    local tt={}
    for i,v in ipairs(reportView) do
        if v[1] then table.insert(tt,v[1]) end
    end
    concat=table.concat(tt, "\n")
    dxDrawText(concat, sx*(698+1)/1024, sy*(278+1)/768, sx*(1014+1)/1024, sy*(496+1)/768, tocolor(0, 0, 0, 255), 1.00, "default", "right", "top", false, true)
    dxDrawText(concat, sx*(698)/1024, sy*(278)/768, sx*(1014)/1024, sy*(496)/768, tocolor(255, 255, 255, 255), 1.00, "default", "right", "top", false, true)
end)

addEvent("admin:addText", true)
addEventHandler("admin:addText", root, function(text)
    table.insert(gameView, text)    
    if #gameView > 10 then
        table.remove(gameView, 1)
    end
end)

addEvent("admin:addReport", true)
addEventHandler("admin:addReport", root, function(text,id)
    table.insert(reportView, {text,id})
    if #reportView > 10 then
        table.remove(reportView, 1)
    end
end)

addEvent("admin:removeReport", true)
addEventHandler("admin:removeReport", root, function(id)
    for i=#reportView, 1, -1 do
        if reportView[i][2] == id then
            table.remove(reportView,i)
        end
    end
end)

addEvent("admin:rendering", true)
addEventHandler("admin:rendering", root, function(text)
    xtext=text
    addEventHandler("onClientRender", root, renderingInfo)
    setTimer(function()
        removeEventHandler("onClientRender", root, renderingInfo)
    end, 5000, 1)
end)


Zrobi?em tak, lecz nic nie wy?wietla.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-05-06, 01:07


Prezes.







Wiek: 28
Na forum: 4511 dni
Posty: 75
Nick w MP: Prezes.

Piwa: 17

Respekt: 60

Najlepiej b?dzie Ci zrobi? tak:

S-side;

function onAdminLogin()
local accName = getAccountName(getPlayerAccount(source))
    if accName and isObjectInACLGroup ("user."..accName, aclGetGroup("RCON")) then
    setElementData(source,"auth:admin",true)
    end
end
addEventHandler("onPlayerLogin",root,onAdminLogin)


c-side:

local xtext=nil
local gameView={"Logi serwerowe"}
local reportView={"Lista raport?w"}
local sx,sy=guiGetScreenSize()

addEventHandler("onClientRender", root, function()
    if getElementData(localPlayer,"auth:admin") then
    concat=table.concat(gameView, "\n")
    dxDrawText(concat, sx*(10+1)/1024, sy*(279+1)/768, sx*(326+1)/1024, sy*(497+1)/768, tocolor(0, 0, 0, 255), 1.00, "default", "left", "top", false, true)
    dxDrawText(concat, sx*(10)/1024, sy*(279)/768, sx*(326)/1024, sy*(497)/768, white, 1.00, "default", "left", "top", false, true)
end
end)

function renderingInfo()
dxDrawRectangle(sx*(258)/1024, sy*(0)/768, sx*(500)/1024, sy*(23)/768, tocolor(0, 0, 0, 155), false)
    dxDrawText(xtext, sx*(258+1)/1024, sy*(0+1)/768, sx*(758+1)/1024, sy*(23+1)/768, tocolor(0, 0, 0, 255), 1.00, "default", "center", "center", false, true)
    dxDrawText(xtext, sx*(258)/1024, sy*(0)/768, sx*(758)/1024, sy*(23)/768, tocolor(255, 0, 0, 255), 1.00, "default", "center", "center", false, true)
end

addEventHandler("onClientRender", root, function()
   if getElementData(localPlayer,"auth:admin") then
    local tt={}
    for i,v in ipairs(reportView) do
        if v[1] then table.insert(tt,v[1]) end
    end
    concat=table.concat(tt, "\n")
    dxDrawText(concat, sx*(698+1)/1024, sy*(278+1)/768, sx*(1014+1)/1024, sy*(496+1)/768, tocolor(0, 0, 0, 255), 1.00, "default", "right", "top", false, true)
    dxDrawText(concat, sx*(698)/1024, sy*(278)/768, sx*(1014)/1024, sy*(496)/768, tocolor(255, 255, 255, 255), 1.00, "default", "right", "top", false, true)
end
end)

addEvent("admin:addText", true)
addEventHandler("admin:addText", root, function(text)
    table.insert(gameView, text)    
    if #gameView > 10 then
        table.remove(gameView, 1)
    end
end)

addEvent("admin:addReport", true)
addEventHandler("admin:addReport", root, function(text,id)
    table.insert(reportView, {text,id})
    if #reportView > 10 then
        table.remove(reportView, 1)
    end
end)

addEvent("admin:removeReport", true)
addEventHandler("admin:removeReport", root, function(id)
    for i=#reportView, 1, -1 do
        if reportView[i][2] == id then
            table.remove(reportView,i)
        end
    end
end)

addEvent("admin:rendering", true)
addEventHandler("admin:rendering", root, function(text)
    xtext=text
    addEventHandler("onClientRender", root, renderingInfo)
    setTimer(function()
        removeEventHandler("onClientRender", root, renderingInfo)
    end, 5000, 1)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-05-06, 13:03


FaydenFX.







Wiek: 27
Na forum: 4197 dni
Posty: 246
Nick w MP: faydn

Piwa: 11

Respekt: 45,3

debug w
        if reportView[i:1][2] == id then
name expected near '1'

[ Dodano: 2016-05-06, 14:13 ]
Kto? co??

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-05-06, 18:41


Prezes.







Wiek: 28
Na forum: 4511 dni
Posty: 75
Nick w MP: Prezes.

Piwa: 17

Respekt: 60

Sprawd? tak.


addEvent("admin:removeReport", true)
addEventHandler("admin:removeReport", root, function(id)
    for i=#reportView, 1, -1 do
        if (reportView[i][2] and reportView[i][2] == id) then -- Znaczniki ?le pokazuj? powinno by? samo i w nawiasach kwadratowych
            table.remove(reportView,i)
        end
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-05-06, 19:35


FaydenFX.







Wiek: 27
Na forum: 4197 dni
Posty: 246
Nick w MP: faydn

Piwa: 11

Respekt: 45,3

ten sam zn?w debug w
 if (reportView[i:1][2] and reportView[i:2][2] == id) then


;v

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-05-06, 20:50


Prezes.







Wiek: 28
Na forum: 4511 dni
Posty: 75
Nick w MP: Prezes.

Piwa: 17

Respekt: 60

Tag lua ?le pokazuje, sprawd? czy masz wpisane

if (reportView[i][2] and reportView[i][2] == id) then

Postaw piwo autorowi tego posta
 

 
Tagi: logi :: serwerowe :: itp.
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