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

Wysłany: 2017-07-04, 21:11


Hiroszekk







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

Piwa: 845

Respekt: -84,3

Ostrzeżeń: 20%
Mam taki oto b??d w db3:
ERROR: [ogrpg]/ogrpg-offices/selectjobs/s_selectjob.lua:118: attempt to get length of local 'result2' (a nil value)
Kod s_selectjob.lua:



-- Od?wie?anie tabeli


function getyesterday()
    local realTime=getRealTime()
    date=string.format("%04d-%02d-%02d"realTime.year+1900realTime.month+1realTime.monthday-1)
    return date
end

function getday()
    local realTime=getRealTime()
    date=string.format("%04d-%02d-%02d"realTime.year+1900realTime.month+1realTime.monthday)
    return date
end

function refreshing(client)
    local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_office")
    if result and #result > 0 then
        triggerClientEvent(client"jobs:refresh"resourceRootresult)
    end
end


setTimer(function()
    local result exports['ogrpg-db']:dbGet("SELECT * from ogrpg_jobs WHERE actived<NOW() - INTERVAL 1 DAY;")
    if result and #result > 0 then
    for i,v in pairs(result) do
        exports['ogrpg-db']:dbSet("DELETE FROM ogrpg_jobs WHERE code=? and uid=?? and actived=?",v.code,v.uid,v.actived)
        exports['ogrpg-db']:dbSet("UPDATE ogrpg_office set spaces=spaces-1 where code=?",v.code)
        outputDebugString("Wyczyszczono prace z nieaktywnych os?b!")
    end
    end
--[[
        local result=exports["ogrpg-db"]:pobierzTabeleWynikow("SELECT * FROM ogrpg_jobs")
        if (resultthen
            for ii,vv in ipairs(result) do
                --if vv["code"] ~= "SAPD" then
                    if vv["actived"] ~= getyesterday() and vv["actived"] ~= getday() then
                        local query=string.format("SELECT * FROM ogrpg_office WHERE code=%q"vv["code"])
                        local result2=exports["ogrpg-db"]:pobierzWyniki(query)
                        if (result2then
                            local query2=string.format("UPDATE ogrpg_office SET spaces=%d WHERE code=%q"result2["spaces"]-1vv["code"])
                            exports["ogrpg-db"]:dbSet(query2)
                            --local query2=string.format("UPDATE ogrpg_office SET spaces=%d WHERE code=%q"result2["spaces"]+1vv["code"])
                            --exports["ogrpg-db"]:dbSet(query2)
                            local query3=string.format("DELETE FROM ogrpg_jobs WHERE code=%q AND uid=%d AND actived=%q LIMIT 1;"vv["code"], vv["uid"], vv["actived"])
                            exports["ogrpg-db"]:dbSet(query3)
                            outputDebugString("Wyczyszczono prace z nieaktywnych os?b!")
                        end
                    end
                --end
            end
        end
    if #result > 0 then
        outputServerLog(tostring(result.actived))
        for key,resulte in pairs(result) do
                outputServerLog("INFO 2:"..tostring(resulte.actived))
                if resulte.code ~= "SAPD" then
                    if resulte.actived ~= getyesterday and resulte.actived ~= getday then
                        local result2=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_office WHERE code=?"resulte.code)
                        if #result2 > 0 then
                            exports["ogrpg-db"]:dbSet("UPDATE ogrpg_office SET spaces=spaces+1 WHERE code=?"result2.spacesresult2.code)
                            exports["ogrpg-db"]:dbSet("DELETE FROM ogrpg_jobs WHERE code=? AND uid=? AND actived=?<NOW()"resulte.coderesulte.uidresulte.actived)
                            outputDebugString("Wyczyszczono prace!")
                            outputServerLog("Wyczyszczono prace!")
                        end
                    end
                end
            end
--]]        --end
end864000000) -- 86400000 24h 86400000


addEvent("jobs:download"true)
addEventHandler("jobs:download"resourceRootrefreshing)

addEvent("jobs:hire"true)
addEventHandler("jobs:hire"resourceRoot, function(_,name,code)
    -- Pobieramy UID gracza
    local uid=getElementData(client,"player:uid")
    if not uid then return end
    -- Sprawdzamy czy ktoistnieje w jakiefrakcji
    local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_jobs WHERE uid=?"uid)
    if #result > 0 then 
        outputChatBox("* Ju? jeste? w jakie? frakcji."client25500)
        return
    end
    -- Sprawdzamy czy praca ma jakiewolne miejsca
    local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_office WHERE code=?"code)
    if #result > 0 then
        if result[1].spaces == result[1].maxspaces then
            outputChatBox("* W tej pracy nie ma wolnych miejsc."client25500)
            return
        end
    end
    -- Dodajemy gracza do frakcji i nast?pnie od?wie?amy wniki dodajemym dodatkowe miejsca itp.
    local query=exports["ogrpg-db"]:dbSet("INSERT ogrpg_jobs (code,uid) VALUES (?,?)"codeuid)
    if query then
        exports["ogrpg-db"]:dbSet("UPDATE ogrpg_office SET spaces=spaces+1 WHERE code=?"code)
        outputChatBox("* Otrzymujesz sta?? prac? w "..name..""client)
        refreshing(client)
    end
end)

addEvent("jobs:slow"true)
addEventHandler("jobs:slow"resourceRoot, function(_,name,code)
    -- Pobieramy UID gracza
    local uid=getElementData(client,"player:uid")
    if not uid then return end
    -- Sprawdzamy czy ktoistnieje w jakiefrakcji
    local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_jobs WHERE uid=?"uid)
    if #result > 0 then
        -- Sprawdzamy czy praca ma jakiewolne miejsca
        local query=string.format("SELECT * FROM ogrpg_office WHERE code=%q"result[1].code)
        local result2=exports["ogrpg-db"]:pobierzWyniki(query)
        if #result2 > 0 then
            if result2["spaces"] == 0 then
                outputChatBox("* Wyst?pi? b??d, poniewa? nie by?e? zatrudniony?"client25500)
                return
            end
        end
        -- Usuwamy gracza z frakcji i nast?pnie od?wie?amy wniki usuwamy miejsce itp.
        local result3=exports["ogrpg-db"]:dbSet("DELETE FROM ogrpg_jobs WHERE code=? AND uid=?"result[1].codeuid)
        if query then
            exports["ogrpg-db"]:dbSet("UPDATE ogrpg_office SET spaces=? WHERE code=?"result2["spaces"]-1result[1].code)
            outputChatBox("* Zwolni?e? si? ze sta?ej pracy w "..nameclient)
            refreshing(client)
        end
    else
        outputChatBox("* Nie jeste? w ?adnej frakcji."client25500)
    end
end )







I kod kt?ry odpowiada za zwalnianie:

addEvent("jobs:slow"true)
addEventHandler("jobs:slow"resourceRoot, function(_,name,code)
    -- Pobieramy UID gracza
    local uid=getElementData(client,"player:uid")
    if not uid then return end
    -- Sprawdzamy czy ktoistnieje w jakiefrakcji
    local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_jobs WHERE uid=?"uid)
    if #result > 0 then
        -- Sprawdzamy czy praca ma jakiewolne miejsca
        local query=string.format("SELECT * FROM ogrpg_office WHERE code=%q"result[1].code)
        local result2=exports["ogrpg-db"]:pobierzWyniki(query)
        if #result2 > 0 then
            if result2["spaces"] == 0 then
                outputChatBox("* Wyst?pi? b??d, poniewa? nie by?e? zatrudniony?"client25500)
                return
            end
        end
        -- Usuwamy gracza z frakcji i nast?pnie od?wie?amy wniki usuwamy miejsce itp.
        local result3=exports["ogrpg-db"]:dbSet("DELETE FROM ogrpg_jobs WHERE code=? AND uid=?"result[1].codeuid)
        if query then
            exports["ogrpg-db"]:dbSet("UPDATE ogrpg_office SET spaces=? WHERE code=?"result2["spaces"]-1result[1].code)
            outputChatBox("* Zwolni?e? si? ze sta?ej pracy w "..nameclient)
            refreshing(client)
        end
    else
        outputChatBox("* Nie jeste? w ?adnej frakcji."client25500)
    end
end )



Pomo?e kto? ? Daje piwko i repke

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-04, 21:13


amited







Wiek: 26
Na forum: 3714 dni
Posty: 1233
Nick w MP: Amited

Piwa: 512

Respekt: 466
Respekt: 466

wrzu? to w pastebin albo gdzie? gdzie s? policzone linijki

Podpis
"amited" napisał/a:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-07-04, 21:17


Hiroszekk







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

Piwa: 845

Respekt: -84,3

Ostrzeżeń: 20%
Postaw piwo autorowi tego posta
 

 
Tagi: zwalnianie :: tunera
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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