Facebook
From Botched Anoa, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 204
  1. local baza = dbConnect ("sqlite", "test.db")
  2. if baza then outputChatBox ("jest okej") end
  3.  
  4. -------------------------------------------
  5. function pobierzHandling (element, wartosc)
  6.         if isElement (element) and getElementType (element) == "vehicle" and type (wartosc) == "string" then
  7.            local handlingTable = getVehicleHandling (element)
  8.            local value = handlingTable[wartosc]
  9.            if value then
  10.               return value
  11.            end
  12.         end
  13. end
  14. -------------------------------------------
  15.  
  16. 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) ")
  17. -- local jajo = dbQuery (baza, "INSERT INTO pojazdy (model, x, y, z) VALUES (429, -2408.89844, -597.22626, 132.6484)")
  18. -- if jajo then outputChatBox ("Wciąż jest okej") end
  19.  
  20.  
  21. --[[ function wczytaj ()
  22. local wczytywanie = dbQuery (baza, "SELECT * FROM pojazdy")
  23. local wynik = dbPoll (wczytywanie, -1)
  24. for k, v in ipairs (wynik) do
  25.     createVehicle (v["model"], v["x"], v["y"], v["z"])
  26. end
  27. end
  28. addEventHandler ("onResourceStart", resourceRoot, wczytaj)
  29. ]]--
  30.  
  31. function zapisz ()
  32. for k, v in ipairs (getElementsByType("vehicle")) do
  33.      local id = getElementData (v, "car_owner")
  34.      if id then
  35.          local samochod = getElementModel (v)
  36.          local wlasciciel1 = getElementData (v, "car_owner")
  37.          local x1, y1, z1 = getElementPosition (v)
  38.          local rotx1, roty1, rotz1 = getElementRotation (v)
  39.          local color11, color21, color31, color41, color51, color61 = getVehicleColor (v)
  40.          local paliwo1 = getElementData (v, "pojazd_paliwo")
  41.          local przebieg1 = getElementData (v, "pojazd_przebieg")
  42.          local reczny2 = isElementFrozen (v)
  43.          local stan_swiatel1 = getVehicleOverrideLights (v)
  44.          local stan_silnika1 = tostring(getVehicleEngineState (v))
  45.          local opis_gielda1 = getElementData (v, "pojazd_opis") or ""
  46.  
  47.          --- TUNING
  48.    
  49.          local paintjob1 = getVehiclePaintjob (v)
  50.          local r1, g1, b1 = getVehicleHeadLightColor (v)
  51.          
  52.          sav = {}
  53.        
  54.              for i=0, 16 do
  55.                local upgrade = getVehicleUpgradeOnSlot(v, i)
  56.                sav[i] = upgrade or 0
  57.              end
  58.          local plate_text1 = getVehiclePlateText (v)
  59.          local zawieszenie1 = pobierzHandling (v, "suspensionLowerLimit")
  60.          local predkosc_max1 = pobierzHandling (v, "maxVelocity")
  61.          local hamulce1 = pobierzHandling (v, "brakeDeceleration")
  62.          local przyspieszenie1 = pobierzHandling (v, "engineAcceleration")
  63.          local wariant1 = getVehicleVariant (v)
  64.          local freeze = "true"
  65.          local tune_sprezarka1 = getElementData (v, "tune:sprezarka") or 0
  66.          local tune_naped1 = getElementData (v, "tune:naped") or 0
  67.          local tune_hamulce1 = getElementData (v, "tune:hamulce") or 0
  68.          local tune_niskienadwozie1 = getElementData (v, "tune:niskienadwozie") or 0
  69.          local tune_wysokienadwozie1 = getElementData (v, "tune:wysokienadwozie") or 0
  70.          local instalacja_audio1 = getElementData (v, "tune:audio") or 0
  71.          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..")")
  72.          if zapis then outputChatBox ("** Zapisywanie zakończone") else outputChatBox ("** Wystąpił błąd podczas zapisywania pojazdów.") end
  73.       end
  74. end
  75. end
  76. addEventHandler ("onResourceStart", resourceRoot, zapisz)