- local baza = dbConnect ("sqlite", "test.db")
- if baza then outputChatBox ("jest okej") end
- -------------------------------------------
- function pobierzHandling (element, wartosc)
- if isElement (element) and getElementType (element) == "vehicle" and type (wartosc) == "string" then
- local handlingTable = getVehicleHandling (element)
- local value = handlingTable[wartosc]
- if value then
- return value
- end
- end
- end
- -------------------------------------------
- dbExec (baza, "CREATE TABLE IF NOT EXISTS pojazdy ( model INTEGER, wlasciciel TEXT, x INTEGER, y INTEGER, z INTEGER, rotx INTEGER, roty INTEGER, rotz INTEGER, color1 INTEGER, color2 INTEGER, color3 INTEGER, color4 INTEGER, color5 INTEGER, color6 INTEGER, paliwo INTEGER, opis_gielda TEXT, przebieg INTEGER, stan_swiatel TEXT, stan_silnika BOOLEAN, reczny BOOLEAN, paintjob INTEGER, hr INTEGER, hg INTEGER, hb INTEGER, t0 INTEGER, t1 INTEGER, t2 INTEGER, t3 INTEGER, t4 INTEGER, t5 INTEGER, t6 INTEGER, t7 INTEGER, t8 INTEGER, t9 INTEGER, t10 INTEGER, t11 INTEGER, t12 INTEGER, t13 INTEGER, t14 INTEGER, t15 INTEGER, t16 INTEGER, instalacja_audio TEXT, rejestracja TEXT, h_zawieszenie TEXT, h_predkosc TEXT, h_hamulce TEXT, h_przyspieszenie TEXT, wariant INTEGER, tunesprezarka TEXT, tunenaped TEXT, tunehamulce TEXT, tuneniskiepodwozie TEXT, tunewysokienadwozie TEXT) ")
- -- local jajo = dbQuery (baza, "INSERT INTO pojazdy (model, x, y, z) VALUES (429, -2408.89844, -597.22626, 132.6484)")
- -- if jajo then outputChatBox ("Wciąż jest okej") end
- --[[ function wczytaj ()
- local wczytywanie = dbQuery (baza, "SELECT * FROM pojazdy")
- local wynik = dbPoll (wczytywanie, -1)
- for k, v in ipairs (wynik) do
- createVehicle (v["model"], v["x"], v["y"], v["z"])
- end
- end
- addEventHandler ("onResourceStart", resourceRoot, wczytaj)
- ]]--
- function zapisz ()
- for k, v in ipairs (getElementsByType("vehicle")) do
- local id = getElementData (v, "car_owner")
- if id then
- local samochod = getElementModel (v)
- local wlasciciel1 = getElementData (v, "car_owner")
- local x1, y1, z1 = getElementPosition (v)
- local rotx1, roty1, rotz1 = getElementRotation (v)
- local color11, color21, color31, color41, color51, color61 = getVehicleColor (v)
- local paliwo1 = getElementData (v, "pojazd_paliwo")
- local przebieg1 = getElementData (v, "pojazd_przebieg")
- local reczny2 = isElementFrozen (v)
- local stan_swiatel1 = getVehicleOverrideLights (v)
- local stan_silnika1 = tostring(getVehicleEngineState (v))
- local opis_gielda1 = getElementData (v, "pojazd_opis") or ""
- --- TUNING
- local paintjob1 = getVehiclePaintjob (v)
- local r1, g1, b1 = getVehicleHeadLightColor (v)
- sav = {}
- for i=0, 16 do
- local upgrade = getVehicleUpgradeOnSlot(v, i)
- sav[i] = upgrade or 0
- end
- local plate_text1 = getVehiclePlateText (v)
- local zawieszenie1 = pobierzHandling (v, "suspensionLowerLimit")
- local predkosc_max1 = pobierzHandling (v, "maxVelocity")
- local hamulce1 = pobierzHandling (v, "brakeDeceleration")
- local przyspieszenie1 = pobierzHandling (v, "engineAcceleration")
- local wariant1 = getVehicleVariant (v)
- local freeze = "true"
- local tune_sprezarka1 = getElementData (v, "tune:sprezarka") or 0
- local tune_naped1 = getElementData (v, "tune:naped") or 0
- local tune_hamulce1 = getElementData (v, "tune:hamulce") or 0
- local tune_niskienadwozie1 = getElementData (v, "tune:niskienadwozie") or 0
- local tune_wysokienadwozie1 = getElementData (v, "tune:wysokienadwozie") or 0
- local instalacja_audio1 = getElementData (v, "tune:audio") or 0
- local zapis = dbQuery (baza, "INSERT INTO pojazdy (model, wlasciciel, x, y, z, rotx, roty, rotz, color1, color2, color3, color4, color5, color6, paliwo, opis_gielda, przebieg, stan_swiatel, stan_silnika, reczny, paintjob, hr, hg, hb, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, instalacja_audio, rejestracja, h_zawieszenie, h_predkosc, h_hamulce, h_przyspieszenie, wariant, tunesprezarka, tunenaped, tunehamulce, tuneniskiepodwozie, tunewysokienadwozie) VALUES ("..samochod..", "..id..", "..x1..", "..y1..", "..z1..", "..rotx1..", "..roty1..", "..'255'..", "..'255'..", "..'255'..", "..'255'..", "..'255'..", "..'255'..", "..'255'..", "..paliwo1..", "..opis_gielda1..", "..przebieg1..", "..stan_swiatel1..", "..stan_silnika1..", "..freeze..", "..paintjob1..", "..r1..", "..g1..", "..b1..", "..sav[0]..", "..sav[1]..", "..sav[2]..", "..sav[3]..", "..sav[4]..", "..sav[5]..", "..sav[6]..", "..sav[7]..", "..sav[8]..", "..sav[9]..", "..sav[10]..", "..sav[11]..", "..sav[12]..", "..sav[13]..", "..sav[14]..", "..sav[15]..", "..sav[16]..", "..instalacja_audio1..", "..plate_text1..", "..zawieszenie1..", "..predkosc_max1..", "..hamulce1..", "..przyspieszenie1..", "..wariant1..", "..tune_sprezarka1..", "..tune_naped1..", "..tune_hamulce1..", "..tune_niskienadwozie1..", "..tune_wysokienadwozie1..")")
- if zapis then outputChatBox ("** Zapisywanie zakończone") else outputChatBox ("** Wystąpił błąd podczas zapisywania pojazdów.") end
- end
- end
- end
- addEventHandler ("onResourceStart", resourceRoot, zapisz)