Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2016-07-04, 12:39


flimbo123







Wiek: 33
Na forum: 5776 dni
Posty: 93
Nick w MP: Flimbo

Piwa: 190

Respekt: 60

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.

Screenshoot:

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-07-04, 14:21


_Wicek_

Majstersztyk






Wiek: 25
Na forum: 4260 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1841

Respekt: 360,5
Respekt: 360,5Respekt: 360,5Respekt: 360,5Respekt: 360,5

Ostrzeżeń: 40%
Bez kodu nic nie zrobimy....

Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-07-04, 19:11


luki123luki123

Place Game






Wiek: 28
Na forum: 5275 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

flimbo123, oraz lepsz? grafik? daj bo nic nie wida? na tym zdj?ciu.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-07-05, 13:20


flimbo123







Wiek: 33
Na forum: 5776 dni
Posty: 93
Nick w MP: Flimbo

Piwa: 190

Respekt: 60

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`")
    tablee={}
    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"]
        for _,v in ipairs(getVehicleUpgrades(v))do
            table.insert(tablee,v)
        end
        local tuning=table.concat(tablee,",")
        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=split(v.tuning,","," ")
        for _,value in ipairs(tuning)do
            addVehicleUpgrade(car,value)
        end
    end
end)







>> Kliknijcie na zdj?cie ?eby je zobaczy? w full rozdzielczo?ci.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-07-06, 00:56


Jacob

Głupiomądry






Wiek: 28
Na forum: 5502 dni
Posty: 967
Nick w MP: Jacob

Piwa: 786

Respekt: 212,3
Respekt: 212,3Respekt: 212,3

zamie? to
local tuning=table.concat(tablee,",")

na
local tuning=toJSON(tablee)

i
tuning=split(v.tuning,","," ")

na
tuning=fromJSON(v.tuning)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-07-06, 16:24


flimbo123







Wiek: 33
Na forum: 5776 dni
Posty: 93
Nick w MP: Flimbo

Piwa: 190

Respekt: 60

Jacob,

w konsoli wyskakuje mi

[16:23] ERROR: privcar\server.lua:61: bad argument #1 to 'ipairs' (table expe
cted, got nil)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-07-06, 16:39


Jacob

Głupiomądry






Wiek: 28
Na forum: 5502 dni
Posty: 967
Nick w MP: Jacob

Piwa: 786

Respekt: 212,3
Respekt: 212,3Respekt: 212,3

A co w bazie si? zapisuje?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-07-06, 20:57


flimbo123







Wiek: 33
Na forum: 5776 dni
Posty: 93
Nick w MP: Flimbo

Piwa: 190

Respekt: 60

Jacob,
Dodam ?e usun??o wszystkie dotychczasowe rekordy w bazie, tzn wszystkie auta za wyj?tkiem tego jednego.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-07-06, 21:46


Jacob

Głupiomądry






Wiek: 28
Na forum: 5502 dni
Posty: 967
Nick w MP: Jacob

Piwa: 786

Respekt: 212,3
Respekt: 212,3Respekt: 212,3

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)

Ja bym u?y? czego? takiego.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-07-07, 13:36


flimbo123







Wiek: 33
Na forum: 5776 dni
Posty: 93
Nick w MP: Flimbo

Piwa: 190

Respekt: 60

Dzi?kuj?, chyba dzia?a poprawnie. Leci zimne :piwo: dla ciebie, Jacob, lol

Postaw piwo autorowi tego posta
 

 
Tagi: zapis :: tuningu :: sqlite
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Zapis tuningu SQLite Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

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
Dodaj temat do Ulubionych
Wersja do druku