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

Wysłany: 2018-06-25, 20:03


Kulegg







Wiek: 46
Na forum: 3266 dni
Posty: 283

Piwa: 20

Respekt: 50

Witam, mam problem gdy? mam w urz?dzie dodan? prac? tunera w sf, ale jak klikam Wybierz prace czyli powinno mnie doda? do tunera, jest 0 os?b dodanych i jest 30 slot?w, a mnie nie doda?o i nic nie pisze, natomiast przycisk zwolnij sie dzia?a i jest info tzn ze dzia.a

KOD:

-- Od?wie?anie tabeli


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

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

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


setTimer(function()
    local result = exports['pystories-db']:dbGet("SELECT * from pystories_jobs WHERE actived<NOW() - INTERVAL 1 DAY;")
    if result and #result > 0 then
    for i,v in pairs(result) do
        exports['pystories-db']:dbSet("DELETE FROM pystories_jobs WHERE code=? and uid=?? and actived=?",v.code,v.uid,v.actived)
        exports['pystories-db']:dbSet("UPDATE pystories_office set spaces=spaces-1 where code=?",v.code)
        outputDebugString("pystories-offices.s_selectjob.lua> Wyczyszczono prace z nieaktywnych os?b!")
    end
    end
end, 86400000, 0) -- 86400000 24h 86400000


addEvent("jobs:download", true)
addEventHandler("jobs:download", resourceRoot, refreshing)

addEvent("jobs:hire", true)
addEventHandler("jobs:hire", resourceRoot, function(_,name,code)
    -- Pobieramy UID gracza
    local uid=getElementData(client,"player:sid")
    if not uid then return end
    -- Sprawdzamy czy kto? istnieje w jakie? frakcji
    local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_jobs WHERE uid=?", uid)
    if #result > 0 then 
        outputChatBox("* Ju? jeste? w jakie? pracy zatrudniony(a).", client, 255, 0, 0)
        return
    end
    -- Sprawdzamy czy praca ma jakie? wolne miejsca
    local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_office WHERE code=?", code)
    if #result > 0 then
        if result[1].spaces == result[1].maxspaces then
            outputChatBox("* W tej pracy nie ma wolnych miejsc.", client, 255, 0, 0)
            return
        end
    end
    -- Dodajemy gracza do frakcji i nast?pnie od?wie?amy wniki dodajemym dodatkowe miejsca itp.
    local query=exports["pystories-db"]:dbSet("INSERT pystories_jobs (code,uid) VALUES (?,?)", code, uid)
    if query then
        exports["pystories-db"]:dbSet("UPDATE pystories_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:sid")
    if not uid then return end
    -- Sprawdzamy czy kto? istnieje w jakie? frakcji
    local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_jobs WHERE uid=?", uid)
    if #result > 0 then
        -- Sprawdzamy czy praca ma jakie? wolne miejsca
        local query=string.format("SELECT * FROM pystories_office WHERE code=%q", result[1].code)
        local result2=exports["pystories-db"]:pobierzWyniki(query)
        if #result2 > 0 then
            if result2["spaces"] == 0 then
                outputChatBox("* Wyst?pi? b??d, poniewa? nie by?e? zatrudniony?", client, 255, 0, 0)
                return
            end
        end
        -- Usuwamy gracza z frakcji i nast?pnie od?wie?amy wniki usuwamy miejsce itp.
        local result3=exports["pystories-db"]:dbSet("DELETE FROM pystories_jobs WHERE code=? AND uid=?", result[1].code, uid)
        if query then
            exports["pystories-db"]:dbSet("UPDATE pystories_office SET spaces=? WHERE code=?", result2["spaces"]-1, result[1].code)
            outputChatBox("* Zwolni?e?(a?) si? ze sta?ej pracy w "..name, client)
            refreshing(client)
        end
    else
        outputChatBox("* Nie jeste? w ?adnej pracy zatrudniony(a).", client, 255, 0, 0)
    end
end )


oraz c_selectjob:


local marker=createMarker(358.67, 163.15, 1008.38-1, "cylinder", 1.2, 255, 255, 255, 155)
setElementInterior(marker, 3)
setElementDimension(marker, 1)

local t=createElement("text")
setElementPosition(t,358.67, 163.15, 1008.38)
setElementInterior(t,3)
setElementDimension(t,1)
setElementData(t,"name","Wyb?r pracy")

local wm={}
wm.window=guiCreateWindow(0.19, 0.22, 0.65, 0.55, "Do??czenie do pracy", true)
guiWindowSetSizable(wm.window, false)
guiWindowSetMovable(wm.window, false)
guiSetVisible(wm.window, false)
wm.gridlist=guiCreateGridList(0.02, 0.07, 0.95, 0.74, true, wm.window)
guiGridListAddColumn(wm.gridlist, "Nazwa", 0.5)
guiGridListAddColumn(wm.gridlist, "Miejsca", 0.3)
guiGridListAddColumn(wm.gridlist, "SRP", 0.2)
wm.submit=guiCreateButton(0.03, 0.83, 0.31, 0.14, "Wybierz", true, wm.window)
wm.close=guiCreateButton(0.66, 0.83, 0.31, 0.14, "Zamknij", true, wm.window)
wm.leave=guiCreateButton(0.39, 0.84, 0.22, 0.12, "Zwolnij si?", true, wm.window)

addEventHandler("onClientGUIClick", root, function()
    if source == wm.submit then
        local selectedRow=guiGridListGetSelectedItem(wm.gridlist)
        if selectedRow < 0 then return end
        local name=guiGridListGetItemText(wm.gridlist, selectedRow, 1)
        local code=guiGridListGetItemData(wm.gridlist, selectedRow, 1)
        local spaces=tonumber(guiGridListGetItemData(wm.gridlist, selectedRow, 2))
        local maxspaces=tonumber(guiGridListGetItemData(wm.gridlist, selectedRow, 3))
        local reputation=tonumber(guiGridListGetItemText(wm.gridlist, selectedRow, 3))
        if spaces >= maxspaces then
            outputChatBox("* Brak wolnych miejsc.", 255, 0, 0)
            return
        end
        if reputation > getElementData(localPlayer,"player:srp") then
            outputChatBox("* Nie posiadasz wymaganego srp.", 255, 0, 0)
            return
        end
        triggerServerEvent("jobs:hire", resourceRoot, el, name, code)
    end
    if source == wm.close then
        if guiGetVisible(wm.window) == true then
            showCursor(false)
            guiSetVisible(wm.window, false)
        end
    end
    if source == wm.leave then
        local selectedRow=guiGridListGetSelectedItem(wm.gridlist)
        if selectedRow < 0 then return end
        local name=guiGridListGetItemText(wm.gridlist, selectedRow, 1)
        local code=guiGridListGetItemData(wm.gridlist, selectedRow, 1)
        local spaces=tonumber(guiGridListGetItemData(wm.gridlist, selectedRow, 2))
        if spaces < 0 then return end
        triggerServerEvent("jobs:slow", resourceRoot, el, name, code)
    end
end)

addEvent("jobs:refresh", true)
addEventHandler("jobs:refresh", resourceRoot, function(result)
    guiGridListClear(wm.gridlist)
    for i,v in pairs(result) do
        local row=guiGridListAddRow(wm.gridlist)
        guiGridListSetItemText(wm.gridlist, row, 1, v.name, false, false)
        guiGridListSetItemData(wm.gridlist, row, 1, v.code, false, false)
        guiGridListSetItemText(wm.gridlist, row, 2, v.spaces.."/"..v.maxspaces, false, false)
        guiGridListSetItemData(wm.gridlist, row, 2, v.spaces)
        guiGridListSetItemText(wm.gridlist, row, 3, v.reputation, false, false)
        guiGridListSetItemData(wm.gridlist, row, 3, v.maxspaces)
    end
end)

addEventHandler("onClientMarkerHit", marker, function(el,md)
    if el~=localPlayer then return end
    if guiGetVisible(wm.window) == false then
        showCursor(true)
        guiSetVisible(wm.window, true)
        triggerServerEvent("jobs:download", resourceRoot, el)
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-06-25, 20:10


PatryKK.

Emeryt LUA






Wiek: 27
Na forum: 3202 dni
Posty: 1059
Nick w MP: PatryKK.

Piwa: 2331

Respekt: 331,5
Respekt: 331,5Respekt: 331,5Respekt: 331,5

Czy masz w bazie danych takie tabele jak pystories-jobs I pystories-office?

Podpis
GG:75080675
- ✔
- ✔
- ✔
- ✔

Aktualny projekt: BRAK
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-06-25, 20:11


Kulegg







Wiek: 46
Na forum: 3266 dni
Posty: 283

Piwa: 20

Respekt: 50

Tak

[ Dodano: 2018-06-25, 20:13 ]
Db3 pokazuje cos takiego: https://imgur.com/a/ZHSoDvF

[ Dodano: 2018-06-25, 20:31 ]
Pomo?e kto??

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-06-26, 19:07


Mezo.

Mod-Team






Wiek: 25
Na forum: 3352 dni
Posty: 548
Nick w MP: Mezo

Piwa: 6085

Respekt: 517
Respekt: 517

Upewnij si? ?e code tunera jest tak samo dodane jak w pystories-office.
Czyli np tuner jest oznaczony codem = tuner-sf to tak samo musi byc w tabeli pystories-office dodane, nie moze byc np w skrypcie tunera inny code a w bazie inny.

Podpis
- Na forum pomagam na miarę swoich możliwości, oraz bezpłatnie.
- Jeżeli potrzebujesz pomocy, pisz do mnie w prywatnej wiadomości, pomoc uzyskasz szybciej.
Współpraca - [email protected]


Użytkownik - 19.08.2017
GTAO MEMBER - 29.03.2019
Support-Team - 03.02.2019 - 07.05.2019
Moderator - 07.05.2019 - 02.08.2020
Mod-Team - 02.08.2020 - 25.03.2022

Postaw piwo autorowi tego posta
 

 
Tagi: tuner :: kłopot
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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