Wysłany: 2017-07-20, 09:46
BH|LeFeS
DayZ is EPIC!
Wiek: 21 Na forum: 3508 dni Posty: 82
Nick w MP: LeFeS
Piwa : 7
Tak wi?c chcia?em si? zwolni? z Tunera, i tu nagle nic. ?adnego komunikatu wog?le si? nic nie pokazuje, chcia?bym to naprawi?. Prosz? o pomoc
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["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_office")
if result and #result > 0 then
triggerClientEvent(client, "jobs:refresh", resourceRoot, result)
end
end
setTimer(function()
local result=exports["ogrpg-db"]:pobierzTabeleWynikow("SELECT * FROM ogrpg_jobs")
if (result) then
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 (result2) then
local query2=string.format("UPDATE ogrpg_office SET spaces=%d WHERE code=%q", result2["spaces"]-1, vv["code"])
exports["ogrpg-db"]:dbSet(query2)
--local query2=string.format("UPDATE ogrpg_office SET spaces=%d WHERE code=%q", result2["spaces"]+1, vv["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("ogrpg-offices.s_selectjob> 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.spaces, result2.code)
exports["ogrpg-db"]:dbSet("DELETE FROM ogrpg_jobs WHERE code=? AND uid=? AND actived=?<NOW()", resulte.code, resulte.uid, resulte.actived)
outputDebugString("Wyczyszczono prace!")
outputServerLog("Wyczyszczono prace!")
end
end
end
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:uid")
if not uid then return end
-- Sprawdzamy czy kto? istnieje w jakie? pracy
local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_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["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.", 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["ogrpg-db"]:dbSet("INSERT ogrpg_jobs (code,uid) VALUES (?,?)", code, uid)
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 kto? istnieje w jakie? frakcji
local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_jobs WHERE uid=?", uid)
if #result > 0 then
-- Sprawdzamy czy praca ma jakie? wolne 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?(a?) zatrudniony(a)?", client, 255, 0, 0)
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].code, uid)
if query then
exports["ogrpg-db"]:dbSet("UPDATE ogrpg_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 )
Wysłany: 2017-07-20, 15:32
BoCzKu
Mapper & Lua
Wiek: 24 Na forum: 3465 dni Posty: 87
Nick w MP: BoKu
Piwa : 331
Daj te "od?wie?enie tabelki" nie w Kod tylko Lua...
Podaj b??dy z /debugscript 3
Wysłany: 2017-07-20, 18:02
BH|LeFeS
DayZ is EPIC!
Wiek: 21 Na forum: 3508 dni Posty: 82
Nick w MP: LeFeS
Piwa : 7
B??du z Debugscriptu.
[2017-07-20 17:59] ERROR: ogrpg-offices/selectjobs/s_selectjob.lua:109: attempt to get length of local 'result2' (a boolean value) [DUP x5]
[2017-07-20 17:59] ERROR: [skrypty-glowne]/ogrpg-offices/selectjobs/s_selectjob.lua:108: call: failed to call 'ogrpg-db:pobierzWyniki' [string "?"] [DUP x5]
Kod: local result3=exports["ogrpg-db"]:dbSet("DELETE FROM ogrpg_jobs WHERE code=? AND uid=?", result[1].code, uid)
if query then
exports["ogrpg-db"]:dbSet("UPDATE ogrpg_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 )
[ Dodano : 2017-07-20, 18:02 ]
nie umiem to w [lua] dawa? xD
Tagi: wybór :: pracy
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: