Witam, mam problem z zapisem tuningu. Kiedy montuj? tuning do tylko jednego auta, w momencie zapisu samochod?w zapisuje on te? dla wszystkich aut wy?ej w tabeli.
local db=dbConnect("sqlite","save.db")
dbExec(db,"CREATE TABLE IF NOT EXISTS `Save` (ID INTEGER, Model INTEGER, owner VARCHAR, c1 INTEGER, c2 INTEGER, c3 INTEGER, c4 INTEGER, c5 INTEGER, c6 INTEGER, tuning VARCHAR, x VARCHAR, y VARCHAR, z VARCHAR, przebieg INTEGER, hp INTEGER, paliwo INTEGER, rot INTEGER, driveType INTEGER, numberOfGears INTEGER, maxVelocity INTEGER, engineAcceleration INTEGER, steeringLock INTEGER)")
addCommandHandler("save",function(plr)
dbExec(db,"DELETE FROM `Save`")
for _,v in ipairs(getElementsByType("vehicle"))do
local owner=getElementData(v,"owner") or "Brak"
local c1,c2,c3,c4,c5,c6=getVehicleColor(v,true)
local model=getElementModel(v)
local id=getElementData(v,"v:id") or math.random(1,100)
local hp=getElementHealth(v)
local przebieg=getElementData(v,"przeb") or 0
local paliwo=getElementData(v,"fuel") or 0
local x1,y1,z1=getElementPosition(v)
local _,_,rot1=getVehicleRotation(v)
local x=getElementData(v,"x") or x1
local y=getElementData(v,"y") or y1
local z=getElementData(v,"z") or z1
local rot=getElementData(v,"rot") or rot1
local hd = getVehicleHandling(v)
local driveType = hd["driveType"]
local numberOfGears = hd["numberOfGears"]
local maxVelocity = hd["maxVelocity"]
local engineAcceleration = hd["engineAcceleration"]
local steeringLock = hd["steeringLock"]
local tuning = toJSON(getVehicleUpgrades(v))
dbExec(db,"INSERT INTO `Save` (ID,Model,owner,c1,c2,c3,c4,c5,c6,przebieg,hp,paliwo,tuning,x,y,z,rot,driveType,numberOfGears,maxVelocity,engineAcceleration,steeringLock) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",id,model,owner,c1,c2,c3,c4,c5,c6,przebieg,hp,paliwo,tuning,x,y,z,rot,driveType,numberOfGears,maxVelocity,engineAcceleration,steeringLock)
end
end)
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),function()
local q=dbQuery(db,"SELECT * FROM `Save`")
local x=dbPoll(q,-1)
dbFree(q)
for _,v in ipairs(x)do
local car=createVehicle(v.Model,v.x,v.y,v.z)
setVehicleColor(car,v.c1,v.c2,v.c3,v.c4,v.c5,v.c6)
setElementData(car,"owner",v.owner)
setElementData(car,"przeb",v.przebieg)
setElementData(car,"fuel",v.paliwo)
setElementData(car,"v:id",v.ID)
setElementHealth(car,v.hp)
setElementData(car,"x",v.x)
setElementData(car,"y",v.y)
setElementData(car,"z",v.z)
setElementData(car,"rot",v.rot)
setVehicleRotation(car,0,0,v.rot)
setVehicleHandling(car,"driveType",v.driveType)
setVehicleHandling(car,"numberOfGears",v.numberOfGears)
setVehicleHandling(car,"maxVelocity",v.maxVelocity)
setVehicleHandling(car,"engineAcceleration",v.engineAcceleration)
setVehicleHandling(car,"steeringLock",v.steeringLock)
tuning=fromJSON(v.tuning)
for _,value in ipairs(tuning)do
addVehicleUpgrade(car,value)
end
end
end)
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach