Wysłany: 2021-10-12, 00:45
etrnl
CLASSIC RPG
Wiek: 26 Na forum: 2199 dni Posty: 86
Nick w MP: anonymous
Piwa : 57
Kod: function pobierzDate(type,time)
realTime=getRealTime()
type=tostring(type)
time=tonumber(time)
if time < 0 then return end
if type == "m" then if time > 59 then return end value1=realTime.minute+time else value1=realTime.minute end
if type == "h" then if time > 23 then return end value2=realTime.hour+time else value2=realTime.hour end
if type == "d" then if time > 31 then return end value3=realTime.monthday+time else value3=realTime.monthday end
if type == "msc" then if time > 11 then return end value4=realTime.month+time else value4=realTime.month end
if value1 >= 60 then value1 = value1-60; value2=value2+1 end
if value2 >= 24 then value2 = value2-24; value3=value3+1 end
if value3 >= 31 then value3 = value3-31; value4=value4+1 end
date=string.format("%04d-%02d-%02d ", realTime.year+1900, value4+1, value3)
time=string.format("%02d:%02d:%02d", value2, value1, realTime.second)
return date..time
end
Tutaj ju? nie mam bladego poj?cia jak si? w og?le za to wzi??. By?by kto? w stanie zasugerowa? jak to poprawi?? np. zpj na 1 msc zadzia?a, ale na 6 msc ju? nie. chc? aby da?o si? nada? kare np. na 25h lub te 6msc a niestety przy nadaniu takiej timestamp do bazy leci 00-00-0000...
Stawiam piwko ;_)
Wysłany: 2021-10-12, 15:39
!ryzee
rebornMTA
Wiek: 19 Na forum: 2253 dni Posty: 111
Nick w MP: drakovskyy
Piwa : 55
Sprawdza?e? co masz ustawione w bazie danych? Mo?e co? ?le zrobi?e??
Wysłany: 2021-10-12, 16:02
etrnl
CLASSIC RPG
Wiek: 26 Na forum: 2199 dni Posty: 86
Nick w MP: anonymous
Piwa : 57
- ss struktury bazy
A tu za??czam przyk?adowy kod kary (zpj)
Kod: addCommandHandler("zpj", function(plr,cmd,cel,time,type,...)
if getElementData(plr,"player:admin") ~= true then return end
if getElementData(plr, "player:level") == 4 or 3 or 2 or 1 then
local reason=table.concat({...}, " ")
if not tonumber(time) then
outputChatBox("#FF0000* #FFFFFFPoprawne u?ycie: /zpj <nick/ID> <czas> <jednostka: m/h/d/msc> <pow?d>", plr,255,255,255,true)
return
end
local target=exports["ls-core"]:findPlayer(plr,cel)
if not target then
outputChatBox("#FF0000* #FFFFFFNie znaleziono podanego gracza.", plr, 255, 0, 0, true)
return
end
if isPedInVehicle(target) then
removePedFromVehicle(target)
end
result=pobierzDate(type,time)
if (string.len(reason)) < 3 then outputChatBox("#FF0000* #FFFFFFPow?d musi by? d?u?szy ni? 2 znaki.", plr, 255,255,255, true) return end
triggerClientEvent(root, "admin:rendering", root, ""..getPlayerName(target):gsub("#%x%x%x%x%x%x","").."("..getElementData(target,"id")..") otrzyma? zakaz prowadzenia pojazd?w (A,B,C) od "..getPlayerName(plr):gsub("#%x%x%x%x%x%x","").."("..getElementData(plr,"id")..")".." pow?d: "..reason.." ".."( "..time .."".. type .." )")
exports["ls-db"]:dbSet("INSERT INTO ls_punish (serial,reason,time,type) VALUES (?,?,?,?)", getPlayerSerial(target), reason, result, "prawko")
setElementData(plr, "player:zpj", true)
end
end)
Wysłany: 2021-10-13, 19:29
Matikmontana
Modern Stories
Wiek: 22 Na forum: 2473 dni Posty: 423
Nick w MP: Mazeusz*
Piwa : 1015
A nie lepiej zrobi? NOW() + INTERVAL ? przy exporcie do bazy danych?
Więcej szczegółów
Wystawiono 1 piw(a):etrnl
Wysłany: 2021-10-13, 22:03
etrnl
CLASSIC RPG
Wiek: 26 Na forum: 2199 dni Posty: 86
Nick w MP: anonymous
Piwa : 57
"Matikmontana" napisał/a :A nie lepiej zrobi? NOW() + INTERVAL ? przy exporcie do bazy danych?
Ale interval musia? by dodawa? po typie (minuty, godziny etc) to 3elseify by musia?y by? na export czy mi si? ?le wydaje?
Szukam najprostszego rozwi?zania, mo?e ten kod idzie ?atwo jako? przerobi? bo nie kumam go xD
Wysłany: 2021-10-16, 14:55
Matikmontana
Modern Stories
Wiek: 22 Na forum: 2473 dni Posty: 423
Nick w MP: Mazeusz*
Piwa : 1015
To zr?b tabele co? w podobie
tabela = {
["m"] = "MINUTE",
}
i u?yj NOW()+INTERVAL ? ?, czas, tabela[jednostka]
Wysłany: 2021-11-08, 23:56
etrnl
CLASSIC RPG
Wiek: 26 Na forum: 2199 dni Posty: 86
Nick w MP: anonymous
Piwa : 57
no nic, current_timestamp + INTERVAL " .. time .. " MINUTE
i elseif'ami sprawdzanie typ?w.
Dzi?ki matik, piwko leci, do zamkni?cia.
Tagi: pobieranie :: daty
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: