Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.
GTAONLINE.PL
Tematy otagowane jako: daty
1. Pobieranie daty
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 ;_)
2. Dodawanie liczby do daty
Witam, mam pytanie odno?nie dzia?a? na datach(nie elementDatach tylko 2020-06-05 i zapisie w mysql).
Nie wiem jak mam ugry?? ten temat je?li chodzi o nadawanie bana(...) Pr?bowa?em wyizolowa? osobno minuty/godziny/dni i dodawa? ale nie osi?gn??em po??danego rezultatu.
Nie potrzebuj? gotowego kodu, wystarczy jak kto? mnie na prowadz, pozdrawiam.
3. Pobieranie el daty, lpg, fuel
Witam ot?? mam problem, mam system LPG z skygame, wszystko ?adnie ?miga, tylko jak zabezpieczy? to. ?e np mam pusty bak LPG, a paliwa np mam 5 litr?w, i prze??czam na paliwo, a pojazd dalej ga?nie pr?bowa?em za pomoc? element daty, lecz no nie dzia?a. Kod odpowiadaj?cy za ga?ni?cie silnika.
c_side

function zgasSilnik()
    for 
i,v in ipairs(getElementsByType("vehicle")) do
    
local data getElementData(v"vehicle:fuel")
    
local dataLPG getElementData(v"vehicle:LPG")
if 
not dataLPG then
if data then
    
if tonumber(data) < 0.2 then
    setVehicleEngineState
(vfalse)
end
end
end
if dataLPG then
if data then
    
if tonumber(dataLPG) < 0.2 then
    
if tonumber(data) < 0.2 then
    setVehicleEngineState
(vfalse)
end
end
end
end
end
end
setTimer
(zgasSilnik5000)
4. Zapis daty w bazie danych MYSQL
Witam chcia? bym by w panelu logowania zapisywa?a si? data ostatniego logowania danego gracza co do tego b?d? potrzebowa? ?
5. Przemienienie element daty z acl na duty frakcji SAPD
Cze??, postanowi?em brn?? dalej i bawi? si? w to a? mi si? nie uda zrobi? skryptu lub znale?? na gwiazdki tak jak pisa??m, uda?o si?, lecz jest to na acl a chce zrobic tak zeby elementdata byla na duty sapd, ogrpg

kod:

function visibleplayer )
    
local accName getAccountNamegetPlayerAccountplayer ) );
    if( 
isObjectInACLGroup'user.' .. accNameaclGetGroup'Admin' ) ) ) then
        triggerClientEvent
player'g_OnServerCallGUI'player );
    
end
end
addCommandHandler
'gwiazdki'visible );
6. element daty na bak
Witam ot??, mam taki kodzik na baki, dzia?a?o mi to kiedy?, lecz po dodaniu kolejnej element daty na bak nie dzia?a. Wszystko w bazie danych dzia?a, tylko nie zwi?ksza si? limit paliwa jak si? tankuje a ma si? element dat? na bak 90dm3. Nie ma ?adnego b??du w DB3.
function tankuj()
    if 
getPedOccupiedVehicle(localPlayerthen
        local limit 
35
        
if (getElementData(getPedOccupiedVehicle(localPlayer), "vehicle:bak") == "50dm3"then
            limit 
50
        end
        
if (getElementData(getPedOccupiedVehicle(localPlayer), "vehicle:bak") == "90dm3"then
            limit 
90
        end            
        
if (getElementData(getPedOccupiedVehicle(localPlayer), "vehicle:fuel") >= limitthen 
            
return 
        
end
        triggerServerEvent
("TANKUJ",localPlayer)
    
end
end
7. Dodawanie danej daty od 0 zawsze +1
Witam prosze o pomoc gdy? potrzebuje czego? co od 0 doda 1 i potem znowu +1 czyli 2. Kod poni?ej jaki element ma byc dodawany. Stawiam zimne Piwerko.

setElementData(source"Statystyka",1)
8. Ustawienie element daty dla pojazdu w colsphere
Mam taki kod:


--tworzenie colsphere
local colshape 
createColSphere(-138.174851079.5855719.152915)

addEventHandler("onClientGUIClick"resourceRoot, function()
    
local pojazdy=getElementsWithinColShape(colshape,"vehicle")
    if 
source == RH1.btncloseactive then
        guiSetVisible
(RH1.winfalse)
    elseif 
source == RH1.btnclosetxtactive then
        guiSetVisible
(RH1.winfalse)
    elseif 
source == RH1.btnmntactive then
        setElementData
(pojazdy"RH1MOUNTED"true)
    elseif 
source == RH1.btnmnttxtactive then
        setElementData
(pojazdy"RH1MOUNTED"true)
    elseif 
source == RH1.btndemntactive then
        setElementData
(pojazdy"RH1MOUNTED"false)
    elseif 
source == RH1.btndemnttxtactive then
        setElementData
(pojazdy"RH1MOUNTED"false)
    
end
end
)
i jak nada? t? element date dla pojazdu w tym colsphere?
9. Jak uzyc element daty w innym skrypcie
Witam borykam sie z takim problemem stworzylem sobie taki skrypt

function sprawdzel(plr)
    if 
getElementData (plr"player:faction") == 'SAMC' then
    outPutChatbox
("Masz ta element date"plr255255255)
end
end
addCommandHandler 
("sprawdzel"sprawdzel)

A w innym skrypcie mam setelementdata, i chcia?bym zeby ta element data dzialala w tym skrypcie
10. Nadawanie daty graczowi
Witam, mam problem chcia?bym nadac element date graczowi lecz to nie dzia?a :/

local Player2 
getLocalPlayer()
function 
noszepozw(plr)
    
setElementData(Player2"player:admin"3)
    
outputChatBox("Pomyslnie dales elementdate"plr255255255)
end
addCommandHandler
("noszekom"noszepozw)
11. Zapis elementu daty w account dacie
Hej, g?owie si? z tym od sporo czasu, pr?buje ca?y czas.

Potrzebuje aby zapisywa?o element daty do account daty, i go wczyta?o.

Mam tu jaki? kod:



    
function zapis (source)
    
local value "data"
    
local konto getPlayerAccount(source)
    
local dataa getElementData(source,value) or 0
    local acc 
setAccountData(konto,data,dataa)
end
addEventHandler
("onPlayerQuit"getRootElement(), zapis)

    function 
wczyt (source)
    
local value "score"
    
local konto getPlayerAccount(source)
    
local dataa getAccountData(konto,value) or 0
    local acc 
setElementData(source,data,dataa)
end
addEventHandler
("onPlayerLogin"getRootElement(), wczyt)



[ Dodano: 2017-08-11, 11:11 ]
ref
12. Przepisanie Element Daty
Witam mam 5 Lawet, I Jak zrobic aby kazda laweta miala osobny ID aby po wpisaniu np. /laweta (ID Lawety) (ID auta) Cos sie stalo, Wszystko dziala tylko nwm jak ta lawete przepisac

[lua]
local Laweta = {
{664.92, -458.41, 16.96, 359.9, 359.9, 91.6},
{664.92, -461.59, 16.96, 359.9, 359.9, 91.6},
{664.92, -464.59, 16.96, 359.9, 359.9, 91.6},
{664.92, -467.59, 16.96, 359.9, 359.9, 91.6},
{664.92, -470.59, 16.96, 359.9, 359.9, 91.6},
}

for i,v in pairs(Laweta) do
local vehicle=createVehicle(578, v[1], v[2], v[3])
addVehicleUpgrade(vehicle, 1025)
setElementRotation(vehicle, v[4], v[5], v[6])
removeVehicleSirens(vehicle)
addVehicleSirens(vehicle, 1, 2, true, true, true, false)
setVehicleSirens(vehicle, 1, 0.6, 3.6, 1.5, 0, 255, 0, 198.9, 198.9)
setVehicleHandling(vehicle, "engineAcceleration", getVehicleHandling ( vehicle ).engineAcceleration + 15.05 )
setVehicleHandling(vehicle, "maxVelocity", getVehicleHandling ( vehicle ).maxVelocity + 50.05 )
setVehicleHandling(vehicle, "maxVelocity", ((getVehicleHandling ( vehicle ).maxVelocity)*0.09)+getVehicleHandling ( vehicle ).maxVelocity )
setVehicleHandling(vehicle, "engineAcceleration", ((getVehicleHandling ( vehicle ).engineAcceleration)*0.09)+getVehicleHandling ( vehicle ).engineAcceleration )
setElementFrozen(vehicle, true)
setVehicleColor(vehicle,0, 48, 122,0,0,0)
setElementData(vehicle,"vehicle:rank",1)
setElementData(vehicle,"vehicle:d...
13. Pobieranie osób z element daty
Witam,
czy istnieje mo?liwo?? (je?eli tak to poprosz? przyk?ad) czy osoby posiadaj?ce tak? sam? element dat? mo?na wy?wietli? na czacie ile os?b (w postaci liczb) ma element dat??

Chodzi mi oto o pobranie os?b kt?re posiadaj? ELEMENT DAT? "SAPD".

Za pomoc piwo i respekt.
14. Nadawanie Daty
Mam problem poniewa? w skrypcie na mk robi?
Setowanie daty
setElementData(car, "vehicle:MK1", "TAK")
a na g?rze jest.
if getElementData(car, "vehicle:MK1", "TAK") then return end

I mam problem poniewa? to nie dzia?a i gracz wychodzi i wchodzi do auta a to mu ca?y czas to nadaje. i dodaje pr?dko??.
15. Nadawanie daty po wejsciu
Jak w tym skrypcie zrobi? ze po wejsciu na serwer jak gracz w tabeli ma 1 to daje mu date prezent a jak 0 to nie daje.

addEvent("sprawdz"true)
addEventHandler("sprawdz"root, function()
if 
getElementData(source"player:uid"then
local qr 
exports['ogrpg-db']:dbGet("SELECT * FROM ogrpg_users WHERE id=? AND prezent=?",getElementData(source,"player:uid"), "1")
if 
#qr == 1 then
setElementData(source"Prezent")
end
end
end
)
16. Dodawanie dni do daty
Czy jest jaka? funkcja kt?ra doda mi dan? liczb? do danej daty?

np. 6.9.2016 + 29 = 5.10.2016
17. Edytowanie daty MySQL - dodanie dni do pobranej wartosci
Witam mam problem w moim skrypcie :/
Chodzi o to ?e pobieram sobie dat? z bazy i otrzymuj? j? jako string w postaci
"2016-05-08 23:59:32" i teraz jak chc? doda? do tej daty przyk?adowo 2 dni to w jaki spos?b mam tego dokona?? Nie bardzo umiem sformatowa? sobie otrzyman? dat? ?eby wygl?da?o to np w ten spos?b:


local rok 
2016
local miesiac 
05
local dzien 
08
local godzina 
23
local minuta 
59
local sekunda 
32


Czy kto? wie jak to "przekonwertowa?" :shock:
Za pomoc oczywi?cie stawiam piwko :piwo:
18. pobranie daty colShape'a
Witam, chcia?bym pobra? dat? w tym kodzie colShapa do kt?rego wesz?em (nada?em mu ju? date)


function onClientColShapeHittheElementmatchingDimension )
    if ( 
theElement == getLocalPlayer() ) then 
    
    
--todo
    
    
    end
end
addEventHandler
("onClientColShapeHit",getRootElement(),onClientColShapeHit)
19. [DM] wyświetlanie daty
Witam, mam problem z wy?wietleniem daty i dni w systemie vip'a. Mianowicie mam zmienn? pVip[playerid] kt?rej przpisuje czas UNIX kt?ry b?dzie za 30 dni czyli co? takiego:
Kod:

pVip[playerid] = gettime()+60*60*24*30
no i chce wy?wietli? ten unix na normaln? dat? (tj. np. 13.01.2013) i pokaza? ile dni zosta?o do ko?ca.