luczak11211
Wiek: 37 Na forum: 4121 dni Posty: 31
Piwa : 1
Kod: local polaczenie = dbConnect ( "sqlite", "db.db" )
if polaczenie then
outputDebugString("Wczytano pojazdy z przechowywalni")
else
outputDebugString("Nie wczytano pojazd?w z przechowywalni")
end
dbExec ( polaczenie, "CREATE TABLE IF NOT EXISTS Zapis ( Calyy INTEGER, Drzwii INTEGER, PP1 INTEGER, PL1 INTEGER, TP1 INTEGER, TL1 INTEGER, hpauta INTEGER, RS INTEGER, GS INTEGER, BS INTEGER, Tuning INTEGER, Przebieg INTEGER, ID INTEGER, Model INTEGER, Paintjob INTEGER, Paliwo INTEGER, Owner VARCHAR, color1 INTEGER, color2 INTEGER, color3 INTEGER, color4 INTEGER)" )
marker=createMarker(-1756.36,951.36,23.74,"cylinder",6,68,212,4,100)
odb=createMarker(-1748,960,24,"cylinder",1,255,0,0,100)
function oddajAutodoprzecho(e)
if source==marker then
if getElementType(e)=="vehicle" then
local idd=getElementData(e, "id")
local paliwo=getElementData(e, "pojazdy_paliwo")
if idd then
local owner=getElementData(e, "wlasciciel")
local model=getElementModel(e)
local paint=getVehiclePaintjob(e)
local przeb = getElementData ( e, "pojazd_przebieg" )
local upgrade = getVehicleTuning (e)
local c1,c2,c3,c4 = getVehicleColor ( e )
local rs,gs,bs = getVehicleHeadLightColor(e)
local autohp = getElementHealth(e)
local pp1,pl1,tp1,tl1 = getVehicleWheelStates(e)
local caly = {}
for i = 0,6 do table.insert(caly, getVehiclePanelState(e, i)) end
local caly = table.concat(caly, ",")
local drzwi = {}
for i = 0,5 do table.insert(drzwi, getVehicleDoorState(e, i)) end
local drzwi = table.concat(drzwi, ",")
dbExec( polaczenie,"INSERT INTO `Zapis` ( Calyy, Drzwii, PP1, PL1, TP1, TL1, hpauta, RS, GS, BS, Przebieg, Tuning, color1, color2 ,color3, color4, ID, Model,Paintjob,Paliwo,Owner) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",caly,drzwi,pp1,pl1,tp1,tl1, autohp, rs, gs, bs,przeb,upgrade,c1,c2,c3,c4,idd,model,paint,paliwo,owner)
destroyElement(e)
outputChatBox("Schowa?e? sw?j pojazd do przechowywalni aut.")
end
end
elseif source==odb then
if getElementType(e)=="vehicle" then
local q = dbQuery( polaczenie,"SELECT * FROM `Zapis` WHERE `Owner`=?", getPlayerName(e))
local w = dbPoll(q,-1)
dbFree(q)
for _,v in ipairs(w)do
end
end
end
end
addEventHandler("onMarkerHit", root, oddajAutodoprzecho)
addCommandHandler("odbierz",function(plr,cmd,idd)
if idd then
if isElementWithinMarker(plr,odb) then
local q = dbQuery( polaczenie,"SELECT * FROM `Zapis` WHERE `ID`=?",idd)
local w = dbPoll(q,-1)
dbFree(q)
local auto=createVehicle(w[1].Model,-1770.47,958.27,24.64,0.2,0.0,180.0)
warpPedIntoVehicle(plr, auto)
setElementData(auto, "pojazdy_paliwo", w[1].Paliwo)
setElementData(auto, "id", w[1].ID)
setVehiclePaintjob(auto,w[1].Paintjob)
setElementData(auto,"wlasciciel", w[1].Owner)
setElementData ( auto, "pojazdy_przebieg", w[1].Przebieg)
setVehicleColor ( auto, w[1].color1, w[1].color2, w[1].color3, w[1].color4 )
setVehicleTuning ( auto, w[1].Tuning)
setVehicleHeadLightColor(auto, w[1].RS, w[1].GS, w[1].BS)
setElementHealth(auto, tonumber(w[1].hpauta))
setVehicleWheelStates(auto, w[1].PP1, w[1].PL1, w[1].TP1, w[1].TL1)
for i,v in ipairs(w[1].Calyy) do
setVehiclePanelState(auto, i-1, tonumber(v))
end
for i,v in ipairs(w[1].Drzwii) do
setVehicleDoorState(auto, i-1, tonumber(v))
end
dbExec( polaczenie,"DELETE FROM `Zapis` WHERE `ID`=?",idd)
if idd==getElementData(auto, "id") then
end
end
end
end)
function info(plr)
outputChatBox("Aby odebra? swoje auto wpisz /odbierz <ID Auta>", plr)
end
addEventHandler("onMarkerHit", odb, info)
function getVehicleTuning ( veh )
local i
local vehPanel = ''
for i=0, 15 do
local vb = ''
if i>0 then
vb = vehPanel..';'
end
vehPanel = vb.. getVehicleUpgradeOnSlot (veh, i)
end
return vehPanel
end
function setVehicleTuning ( veh, arr )
if arr then
local arrx = split(arr, string.byte(";"))
local i
for i=0, 15 do
addVehicleUpgrade ( veh, arrx[i] )
end
end
return true
end
Jak to podpi?? pod baz? MySgl?