HeavyMetal Posted February 8, 2013 Share Posted February 8, 2013 im making a garage system for my server and now im on the part where i have to save the cars, it upgrades, color, interiors, and dimension, and something is wrong with the code and i cant find out what is it, when it works it always spawn in dimension 0, the setElementInterior command is working but it cords dont, and i dont know why the server is saying im trying to concatenate dimension that is a "nill" value, and a lot of other errors, this is not my code, im only changing it because im not experienced enought to make a thing like this by myself, i marked the parts where i changed it. (original code by: Blakmorg) function saveVehicles() executeSQLDropTable ( "vehiclesaverb" ) --i added the interior and dimension integer at the end executeSQLQuery("vehiclesaverb (VehicleID INTEGER, px REAL, py REAL, pz REAL, rx REAL, ry REAL, rz REAL, Color1 INTEGER, Color2 INTEGER, Health REAL, upgrades TEXT, paintjob INTEGER, Hood INTEGER, Trunk INTEGER, FrontLeft INTEGER, FrontRight INTEGER,RearLeft INEGER, RearRight INEGER, FrontLeftPanel INTEGER, FrontRightPanel Integer, RearLeftPanel Integer, RearRightPanel Integer,Windscreen Integer,FrontBumper Integer, RearBumper Integer,FLL Integer,FRL Integer,RLL Integer, RRL Integer, VehOvL Integer, HR Real,TR Real,FLR Real,FRR Real, RLR Real, RRR Real,WFL Integer, WRL Intger, WFR Integer, WRR Integer, VehSirena Integer, EngineState Integer, XTUR Real, YTUR Real, Interior Integer, Dimension Integer)" ) for i, vehicle in pairs (getElementsByType("vehicle")) do local px, py, pz = getElementPosition(vehicle) local rx, ry, rz = getElementRotation(vehicle) local color1, color2, color3, color4 = getVehicleColor(vehicle) local model = getElementModel(vehicle) local health = getElementHealth (vehicle) local tableUpgrades = getVehicleUpgrades(vehicle) local upgrades = table.concat(tableUpgrades, ",") local paintjob = getVehiclePaintjob(vehicle) local hood = getVehicleDoorState(vehicle,0) local trunk = getVehicleDoorState(vehicle,1) local frontleft = getVehicleDoorState(vehicle,2) local frontright = getVehicleDoorState(vehicle,3) local rearleft = getVehicleDoorState(vehicle,4) local rearright = getVehicleDoorState(vehicle,5) local frontleftpanel = getVehiclePanelState(vehicle,0) local frontrightpanel = getVehiclePanelState(vehicle,1) local rearleftpanel = getVehiclePanelState(vehicle,2) local rearrightpanel = getVehiclePanelState(vehicle,3) local windscreen = getVehiclePanelState(vehicle,4) local frontbumper = getVehiclePanelState(vehicle,5) local rearbumper = getVehiclePanelState(vehicle,6) local fll = tostring(getVehicleLightState(vehicle, 0)) local frl = tostring(getVehicleLightState(vehicle, 1)) local rll = tostring(getVehicleLightState(vehicle, 2)) local rrl = tostring( getVehicleLightState(vehicle, 3)) local VehOvL = getVehicleOverrideLights(vehicle) local hr = getVehicleDoorOpenRatio(vehicle,0) local tr = getVehicleDoorOpenRatio(vehicle,1) local flr = getVehicleDoorOpenRatio(vehicle,2) local frr = getVehicleDoorOpenRatio(vehicle,3) local rlr = getVehicleDoorOpenRatio(vehicle,4) local rrr = getVehicleDoorOpenRatio(vehicle,5) local wfl, wrl, wfr, wrr = getVehicleWheelStates ( vehicle ) if getVehicleSirensOn(vehicle)==true then getsirena=1 elseif getVehicleSirensOn(vehicle)==false then getsirena=0 else getsirena=2 end local sirena = getsirena if getVehicleEngineState ( vehicle )==true then estate=1 else estate=0 end local tengine=estate local xtur, ytur = getVehicleTurretPosition ( vehicle ) local interior = getElementInterior(vehicle) -- i added this line local dimension = getElementDimension(vehicle) -- and this one --added the interior and dimension again executeSQLInsert ( "vehiclesaverb","'"..model.."','"..px.."','"..py.."','"..pz.."','"..rx.."','"..ry.."','"..rz.."','"..color1.."','"..color2.."','"..health.."','"..upgrades.."','"..paintjob.."','"..hood.."','"..trunk.."','"..frontleft.."','"..frontright.."','"..rearleft.."','"..rearright.."','"..frontleftpanel.."','"..frontrightpanel.."','"..rearleftpanel.."','"..rearrightpanel.."','"..windscreen.."','"..frontbumper.."','"..rearbumper.."','"..fll.."','"..frl.."','"..rll.."','"..rrl.."','"..VehOvL.."','"..hr.."','"..tr.."','"..flr.."','"..frr.."','"..rlr.."','"..rrr.."','"..wfl.."','"..wrl.."','"..wfr.."','"..wrr.."','"..sirena.."','"..tengine.."','"..xtur.."','"..ytur.."','"..Interior.."',"'..Dimension..'"") end end addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), saveVehicles) period=get("garage_projeto.Period") if (period > 0) then setTimer(saveVehicles,period,0) end function createDatabase() -- added the same interior and dimension integers here too executeSQLCreateTable ( "vehiclesaverb", "VehicleID INTEGER, px REAL, py REAL, pz REAL, rx REAL, ry REAL, rz REAL, Color1 INTEGER, Color2 INTEGER, Health REAL, upgrades TEXT, paintjob INTEGER, Hood INTEGER, Trunk INTEGER, FrontLeft INTEGER, FrontRight INTEGER,RearLeft INEGER, RearRight INEGER, FrontLeftPanel INTEGER, FrontRightPanel Integer, RearLeftPanel Integer, RearRightPanel Integer,Windscreen Integer,FrontBumper Integer, RearBumper Integer,FLL Integer,FRL Integer,RLL Integer, RRL Integer, VehOvL Integer, HR Real,TR Real,FLR Real,FRR Real, RLR Real, RRR Real,WFL Integer, WRL Intger, WFR Integer, WRR Integer,VehSirena Integer,EngineState Integer, XTUR Real, YTUR Real,Interior Integer,Dimension Integer" ) --Getting datas local vehicles = executeSQLQuery("SELECT * FROM vehiclesaverb") --Spawning the vehicles for i, v in pairs (vehicles) do --i changed the spawn to a specific cord to avoid having the car falling before it interior is set --because the interior i pretend to use is z = 1000 local vehicle = createVehicle( v.VehicleID, -2102, 411, 94, v.rx, v.ry, v.rz ) setElementHealth ( vehicle, v.Health ) setVehicleColor ( vehicle, v.Color1, v.Color2, 0, 0 ) if ( v.paintjob ) then setVehiclePaintjob( vehicle, v.paintjob ) end local upgrades = split( v.upgrades, 44 ) for index, upgrade in pairs (upgrades) do addVehicleUpgrade( vehicle, upgrade ) end setVehicleDoorState ( vehicle, 0, v.Hood ) setVehicleDoorState ( vehicle, 1, v.Trunk ) setVehicleDoorState ( vehicle, 2, v.FrontLeft ) setVehicleDoorState ( vehicle, 3, v.FrontRight ) setVehicleDoorState ( vehicle, 4, v.RearLeft ) setVehicleDoorState ( vehicle, 5, v.RearRight ) setVehiclePanelState (vehicle,0,v.FrontLeftPanel) setVehiclePanelState (vehicle,1,v.FrontRightPanel) setVehiclePanelState (vehicle,2,v.RearLeftPanel) setVehiclePanelState (vehicle,3,v.RearRightPanel) setVehiclePanelState (vehicle,4,v.Windscreen) setVehiclePanelState (vehicle,5,v.FrontBumper) setVehiclePanelState (vehicle,6,v.RearBumper) setVehicleLightState (vehicle,0,v.FLL) setVehicleLightState (vehicle,1,v.FRL) setVehicleLightState (vehicle,2,v.RLL) setVehicleLightState (vehicle,3,v.RRL) setVehicleOverrideLights(vehicle, v.VehOvL) setVehicleDoorOpenRatio (vehicle,0,v.HR,0) setVehicleDoorOpenRatio (vehicle,1,v.TR,0) setVehicleDoorOpenRatio (vehicle,2,v.FLR,0) setVehicleDoorOpenRatio (vehicle,3,v.FRR,0) setVehicleDoorOpenRatio (vehicle,4,v.RLR,0) setVehicleDoorOpenRatio (vehicle,5,v.RRR,0) setVehicleWheelStates ( vehicle, v.WFL, v.WRL, v.WFR, v.WRR ) -- added this too setElementDimension(vehicle, v.Dimension) setElementInterior(vehicle, 1 ,v.px, v.py, v.pz) -- i added the saved cords here, so it go to the right place after spawned, but this is not happening too --. if v.VehSirena==1 then vsirena=true elseif v.VehSirena==0 then vsirena=false end if (v.VehSirena~=2) then setVehicleSirensOn(vehicle,vsirena) end if v.EngineState==1 then setVehicleEngineState(vehicle,true) else setVehicleEngineState(vehicle,false) end setVehicleTurretPosition ( vehicle, v.XTUR, v.YTUR ) end outputChatBox( #vehicles.." vehicles were created by Garage Master", getRootElement(), 0, 255, 0 ) outputDebugString ( #vehicles.." vehicles were created by Garage Master" ) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), createDatabase) addCommandHandler("cleargarages", function() destroyElement(getResourceRootElement()) executeSQLDropTable ( "vehiclesaverb" ) end ) Link to comment
Castillo Posted February 9, 2013 Share Posted February 9, 2013 You had many problems, first is that you aren't creating the table, you are executing a query which has no "CREATE TABLE" inside it, also, you had a problem on dimension/interior saving. function saveVehicles() executeSQLDropTable ( "vehiclesaverb" ) --i added the interior and dimension INT at the end executeSQLQuery ( "CREATE TABLE IF NOT EXISTS vehiclesaverb (VehicleID INT, px REAL, py REAL, pz REAL, rx REAL, ry REAL, rz REAL, Color1 INT, Color2 INT, Health REAL, upgrades TEXT, paintjob INT, Hood INT, Trunk INT, FrontLeft INT, FrontRight INT,RearLeft INEGER, RearRight INEGER, FrontLeftPanel INT, FrontRightPanel INT, RearLeftPanel INT, RearRightPanel INT,Windscreen INT,FrontBumper INT, RearBumper INT,FLL INT,FRL INT,RLL INT, RRL INT, VehOvL INT, HR Real,TR Real,FLR Real,FRR Real, RLR Real, RRR Real,WFL INT, WRL Intger, WFR INT, WRR INT, VehSirena INT, EngineState INT, XTUR Real, YTUR Real, Interior INT, Dimension INT)" ) for i, vehicle in pairs (getElementsByType("vehicle")) do local px, py, pz = getElementPosition(vehicle) local rx, ry, rz = getElementRotation(vehicle) local color1, color2, color3, color4 = getVehicleColor(vehicle) local model = getElementModel(vehicle) local health = getElementHealth (vehicle) local tableUpgrades = getVehicleUpgrades(vehicle) local upgrades = table.concat(tableUpgrades, ",") local paintjob = getVehiclePaintjob(vehicle) local hood = getVehicleDoorState(vehicle,0) local trunk = getVehicleDoorState(vehicle,1) local frontleft = getVehicleDoorState(vehicle,2) local frontright = getVehicleDoorState(vehicle,3) local rearleft = getVehicleDoorState(vehicle,4) local rearright = getVehicleDoorState(vehicle,5) local frontleftpanel = getVehiclePanelState(vehicle,0) local frontrightpanel = getVehiclePanelState(vehicle,1) local rearleftpanel = getVehiclePanelState(vehicle,2) local rearrightpanel = getVehiclePanelState(vehicle,3) local windscreen = getVehiclePanelState(vehicle,4) local frontbumper = getVehiclePanelState(vehicle,5) local rearbumper = getVehiclePanelState(vehicle,6) local fll = tostring(getVehicleLightState(vehicle, 0)) local frl = tostring(getVehicleLightState(vehicle, 1)) local rll = tostring(getVehicleLightState(vehicle, 2)) local rrl = tostring( getVehicleLightState(vehicle, 3)) local VehOvL = getVehicleOverrideLights(vehicle) local hr = getVehicleDoorOpenRatio(vehicle,0) local tr = getVehicleDoorOpenRatio(vehicle,1) local flr = getVehicleDoorOpenRatio(vehicle,2) local frr = getVehicleDoorOpenRatio(vehicle,3) local rlr = getVehicleDoorOpenRatio(vehicle,4) local rrr = getVehicleDoorOpenRatio(vehicle,5) local wfl, wrl, wfr, wrr = getVehicleWheelStates ( vehicle ) if getVehicleSirensOn(vehicle)==true then getsirena=1 elseif getVehicleSirensOn(vehicle)==false then getsirena=0 else getsirena=2 end local sirena = getsirena if getVehicleEngineState ( vehicle )==true then estate=1 else estate=0 end local tengine=estate local xtur, ytur = getVehicleTurretPosition ( vehicle ) local interior = getElementInterior(vehicle) -- i added this line local dimension = getElementDimension(vehicle) -- and this one --added the interior and dimension again executeSQLInsert ( "vehiclesaverb","'"..model.."','"..px.."','"..py.."','"..pz.."','"..rx.."','"..ry.."','"..rz.."','"..color1.."','"..color2.."','"..health.."','"..upgrades.."','"..paintjob.."','"..hood.."','"..trunk.."','"..frontleft.."','"..frontright.."','"..rearleft.."','"..rearright.."','"..frontleftpanel.."','"..frontrightpanel.."','"..rearleftpanel.."','"..rearrightpanel.."','"..windscreen.."','"..frontbumper.."','"..rearbumper.."','"..fll.."','"..frl.."','"..rll.."','"..rrl.."','"..VehOvL.."','"..hr.."','"..tr.."','"..flr.."','"..frr.."','"..rlr.."','"..rrr.."','"..wfl.."','"..wrl.."','"..wfr.."','"..wrr.."','"..sirena.."','"..tengine.."','"..xtur.."','"..ytur.."','"..interior.."','"..dimension.."'") end end addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), saveVehicles) period=get("Period") if (period > 0) then setTimer(saveVehicles,period,0) end function createDatabase() -- added the same interior and dimension INTs here too executeSQLCreateTable ( "vehiclesaverb", "VehicleID INT, px REAL, py REAL, pz REAL, rx REAL, ry REAL, rz REAL, Color1 INT, Color2 INT, Health REAL, upgrades TEXT, paintjob INT, Hood INT, Trunk INT, FrontLeft INT, FrontRight INT,RearLeft INEGER, RearRight INEGER, FrontLeftPanel INT, FrontRightPanel INT, RearLeftPanel INT, RearRightPanel INT,Windscreen INT,FrontBumper INT, RearBumper INT,FLL INT,FRL INT,RLL INT, RRL INT, VehOvL INT, HR Real,TR Real,FLR Real,FRR Real, RLR Real, RRR Real,WFL INT, WRL Intger, WFR INT, WRR INT,VehSirena INT,EngineState INT, XTUR Real, YTUR Real,Interior INT,Dimension INT" ) --Getting datas local vehicles = executeSQLQuery("SELECT * FROM vehiclesaverb") --Spawning the vehicles for i, v in pairs (vehicles) do --i changed the spawn to a specific cord to avoid having the car falling before it interior is set --because the interior i pretend to use is z = 1000 local vehicle = createVehicle( v.VehicleID, -2102, 411, 94, v.rx, v.ry, v.rz ) setElementHealth ( vehicle, v.Health ) setVehicleColor ( vehicle, v.Color1, v.Color2, 0, 0 ) if ( v.paintjob ) then setVehiclePaintjob( vehicle, v.paintjob ) end local upgrades = split( v.upgrades, 44 ) for index, upgrade in pairs (upgrades) do addVehicleUpgrade( vehicle, upgrade ) end setVehicleDoorState ( vehicle, 0, v.Hood ) setVehicleDoorState ( vehicle, 1, v.Trunk ) setVehicleDoorState ( vehicle, 2, v.FrontLeft ) setVehicleDoorState ( vehicle, 3, v.FrontRight ) setVehicleDoorState ( vehicle, 4, v.RearLeft ) setVehicleDoorState ( vehicle, 5, v.RearRight ) setVehiclePanelState (vehicle,0,v.FrontLeftPanel) setVehiclePanelState (vehicle,1,v.FrontRightPanel) setVehiclePanelState (vehicle,2,v.RearLeftPanel) setVehiclePanelState (vehicle,3,v.RearRightPanel) setVehiclePanelState (vehicle,4,v.Windscreen) setVehiclePanelState (vehicle,5,v.FrontBumper) setVehiclePanelState (vehicle,6,v.RearBumper) setVehicleLightState (vehicle,0,v.FLL) setVehicleLightState (vehicle,1,v.FRL) setVehicleLightState (vehicle,2,v.RLL) setVehicleLightState (vehicle,3,v.RRL) setVehicleOverrideLights(vehicle, v.VehOvL) setVehicleDoorOpenRatio (vehicle,0,v.HR,0) setVehicleDoorOpenRatio (vehicle,1,v.TR,0) setVehicleDoorOpenRatio (vehicle,2,v.FLR,0) setVehicleDoorOpenRatio (vehicle,3,v.FRR,0) setVehicleDoorOpenRatio (vehicle,4,v.RLR,0) setVehicleDoorOpenRatio (vehicle,5,v.RRR,0) setVehicleWheelStates ( vehicle, v.WFL, v.WRL, v.WFR, v.WRR ) -- added this too setElementDimension(vehicle, v.Dimension) setElementInterior(vehicle, 1 ,v.px, v.py, v.pz) -- i added the saved cords here, so it go to the right place after spawned, but this is not happening too --. if v.VehSirena==1 then vsirena=true elseif v.VehSirena==0 then vsirena=false end if (v.VehSirena~=2) then setVehicleSirensOn(vehicle,vsirena) end if v.EngineState==1 then setVehicleEngineState(vehicle,true) else setVehicleEngineState(vehicle,false) end setVehicleTurretPosition ( vehicle, v.XTUR, v.YTUR ) end outputChatBox( #vehicles.." vehicles were created by Garage Master", getRootElement(), 0, 255, 0 ) outputDebugString ( #vehicles.." vehicles were created by Garage Master" ) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), createDatabase) addCommandHandler("cleargarages", function() destroyElement(getResourceRootElement()) executeSQLDropTable ( "vehiclesaverb" ) end ) Link to comment
HeavyMetal Posted February 9, 2013 Author Share Posted February 9, 2013 (edited) in what function or line was the problem in? Edited February 9, 2013 by Guest Link to comment
Castillo Posted February 9, 2013 Share Posted February 9, 2013 I changed the following lines: executeSQLQuery ( "CREATE TABLE IF NOT EXISTS vehiclesaverb (VehicleID INT, px REAL, py REAL, pz REAL, rx REAL, ry REAL, rz REAL, Color1 INT, Color2 INT, Health REAL, upgrades TEXT, paintjob INT, Hood INT, Trunk INT, FrontLeft INT, FrontRight INT,RearLeft INEGER, RearRight INEGER, FrontLeftPanel INT, FrontRightPanel INT, RearLeftPanel INT, RearRightPanel INT,Windscreen INT,FrontBumper INT, RearBumper INT,FLL INT,FRL INT,RLL INT, RRL INT, VehOvL INT, HR Real,TR Real,FLR Real,FRR Real, RLR Real, RRR Real,WFL INT, WRL Intger, WFR INT, WRR INT, VehSirena INT, EngineState INT, XTUR Real, YTUR Real, Interior INT, Dimension INT)" ) executeSQLInsert ( "vehiclesaverb","'"..model.."','"..px.."','"..py.."','"..pz.."','"..rx.."','"..ry.."','"..rz.."','"..color1.."','"..color2.."','"..health.."','"..upgrades.."','"..paintjob.."','"..hood.."','"..trunk.."','"..frontleft.."','"..frontright.."','"..rearleft.."','"..rearright.."','"..frontleftpanel.."','"..frontrightpanel.."','"..rearleftpanel.."','"..rearrightpanel.."','"..windscreen.."','"..frontbumper.."','"..rearbumper.."','"..fll.."','"..frl.."','"..rll.."','"..rrl.."','"..VehOvL.."','"..hr.."','"..tr.."','"..flr.."','"..frr.."','"..rlr.."','"..rrr.."','"..wfl.."','"..wrl.."','"..wfr.."','"..wrr.."','"..sirena.."','"..tengine.."','"..xtur.."','"..ytur.."','"..interior.."','"..dimension.."'") Link to comment
HeavyMetal Posted February 9, 2013 Author Share Posted February 9, 2013 it is not giving errors anymore, and the cords are working , but the setElementInterior and the setElementDimension are still setting 0 all the time is there anything i did wrong with them? or with the way i added the interior and dimension to the sql? Link to comment
Castillo Posted February 9, 2013 Share Posted February 9, 2013 That's strange, because you are setting to load them all on interior 1, this line: setElementInterior(vehicle, 1 ,v.px, v.py, v.pz) Link to comment
HeavyMetal Posted February 9, 2013 Author Share Posted February 9, 2013 oh sorry, i changed this after i first posted, now it is setElementInterior(vehicle, v.interior) , dont now why, it still dont "remember" the dimension and interior,i cant understand, i added it exactly on the same way the creator did on all sql functions Link to comment
Castillo Posted February 9, 2013 Share Posted February 9, 2013 Well, your column name is called "Interior" and "Dimension", and you are doing "v.interior" lowercase "i". setElementInterior ( vehicle, v.Interior ) Link to comment
HeavyMetal Posted February 9, 2013 Author Share Posted February 9, 2013 still its not working, i searched on the wiki, and there its saying that some of the sql functions in this script are deprecated, is this a possible cause for the problem or the deprecated functions dont interfere with this kind of stuff? Link to comment
Castillo Posted February 9, 2013 Share Posted February 9, 2013 No, that isn't the problem. Add this line after setElementInterior: outputChatBox ( v.Interior ) Link to comment
HeavyMetal Posted February 9, 2013 Author Share Posted February 9, 2013 it is always saying a 0 for each rezzed car even if it was not on interior 0, i tested with 1,2 and 3 cars on interior 1, and it said 0, 0 0 , 0 0 0 , same happened to dimension. Link to comment
Castillo Posted February 9, 2013 Share Posted February 9, 2013 So, maybe is not saving the dimension/interior? Link to comment
HeavyMetal Posted February 10, 2013 Author Share Posted February 10, 2013 yes, thats the problem, i dont know why, i dont see any reason for this, the script seens right, and dont know what to do.. almost giving up Link to comment
Castillo Posted February 10, 2013 Share Posted February 10, 2013 function saveVehicles() executeSQLDropTable ( "vehiclesaverb" ) --i added the interior and dimension INT at the end executeSQLQuery ( "CREATE TABLE IF NOT EXISTS vehiclesaverb (VehicleID INT, px REAL, py REAL, pz REAL, rx REAL, ry REAL, rz REAL, Color1 INT, Color2 INT, Health REAL, upgrades TEXT, paintjob INT, Hood INT, Trunk INT, FrontLeft INT, FrontRight INT,RearLeft INEGER, RearRight INEGER, FrontLeftPanel INT, FrontRightPanel INT, RearLeftPanel INT, RearRightPanel INT,Windscreen INT,FrontBumper INT, RearBumper INT,FLL INT,FRL INT,RLL INT, RRL INT, VehOvL INT, HR Real,TR Real,FLR Real,FRR Real, RLR Real, RRR Real,WFL INT, WRL Intger, WFR INT, WRR INT, VehSirena INT, EngineState INT, XTUR Real, YTUR Real, Interior INT, Dimension INT)" ) for i, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do local px, py, pz = getElementPosition(vehicle) local rx, ry, rz = getElementRotation(vehicle) local color1, color2, color3, color4 = getVehicleColor(vehicle) local model = getElementModel(vehicle) local health = getElementHealth (vehicle) local tableUpgrades = getVehicleUpgrades(vehicle) local upgrades = table.concat(tableUpgrades, ",") local paintjob = getVehiclePaintjob(vehicle) local hood = getVehicleDoorState(vehicle,0) local trunk = getVehicleDoorState(vehicle,1) local frontleft = getVehicleDoorState(vehicle,2) local frontright = getVehicleDoorState(vehicle,3) local rearleft = getVehicleDoorState(vehicle,4) local rearright = getVehicleDoorState(vehicle,5) local frontleftpanel = getVehiclePanelState(vehicle,0) local frontrightpanel = getVehiclePanelState(vehicle,1) local rearleftpanel = getVehiclePanelState(vehicle,2) local rearrightpanel = getVehiclePanelState(vehicle,3) local windscreen = getVehiclePanelState(vehicle,4) local frontbumper = getVehiclePanelState(vehicle,5) local rearbumper = getVehiclePanelState(vehicle,6) local fll = tostring(getVehicleLightState(vehicle, 0)) local frl = tostring(getVehicleLightState(vehicle, 1)) local rll = tostring(getVehicleLightState(vehicle, 2)) local rrl = tostring( getVehicleLightState(vehicle, 3)) local VehOvL = getVehicleOverrideLights(vehicle) local hr = getVehicleDoorOpenRatio(vehicle,0) local tr = getVehicleDoorOpenRatio(vehicle,1) local flr = getVehicleDoorOpenRatio(vehicle,2) local frr = getVehicleDoorOpenRatio(vehicle,3) local rlr = getVehicleDoorOpenRatio(vehicle,4) local rrr = getVehicleDoorOpenRatio(vehicle,5) local wfl, wrl, wfr, wrr = getVehicleWheelStates ( vehicle ) if getVehicleSirensOn(vehicle)==true then getsirena=1 elseif getVehicleSirensOn(vehicle)==false then getsirena=0 else getsirena=2 end local sirena = getsirena if getVehicleEngineState ( vehicle )==true then estate=1 else estate=0 end local tengine=estate local xtur, ytur = getVehicleTurretPosition ( vehicle ) local interior = getElementInterior(vehicle) local dimension = getElementDimension(vehicle) executeSQLInsert ( "vehiclesaverb","'"..model.."','"..px.."','"..py.."','"..pz.."','"..rx.."','"..ry.."','"..rz.."','"..color1.."','"..color2.."','"..health.."','"..upgrades.."','"..paintjob.."','"..hood.."','"..trunk.."','"..frontleft.."','"..frontright.."','"..rearleft.."','"..rearright.."','"..frontleftpanel.."','"..frontrightpanel.."','"..rearleftpanel.."','"..rearrightpanel.."','"..windscreen.."','"..frontbumper.."','"..rearbumper.."','"..fll.."','"..frl.."','"..rll.."','"..rrl.."','"..VehOvL.."','"..hr.."','"..tr.."','"..flr.."','"..frr.."','"..rlr.."','"..rrr.."','"..wfl.."','"..wrl.."','"..wfr.."','"..wrr.."','"..sirena.."','"..tengine.."','"..xtur.."','"..ytur.."','"..interior.."','"..dimension.."'") end end addEventHandler ( "onResourceStop", resourceRoot, saveVehicles ) period = get ( "Period" ) if ( period > 0 ) then setTimer ( saveVehicles, period, 0 ) end function createDatabase() -- added the same interior and dimension INTs here too executeSQLCreateTable ( "vehiclesaverb", "VehicleID INT, px REAL, py REAL, pz REAL, rx REAL, ry REAL, rz REAL, Color1 INT, Color2 INT, Health REAL, upgrades TEXT, paintjob INT, Hood INT, Trunk INT, FrontLeft INT, FrontRight INT,RearLeft INEGER, RearRight INEGER, FrontLeftPanel INT, FrontRightPanel INT, RearLeftPanel INT, RearRightPanel INT,Windscreen INT,FrontBumper INT, RearBumper INT,FLL INT,FRL INT,RLL INT, RRL INT, VehOvL INT, HR Real,TR Real,FLR Real,FRR Real, RLR Real, RRR Real,WFL INT, WRL Intger, WFR INT, WRR INT,VehSirena INT,EngineState INT, XTUR Real, YTUR Real,Interior INT,Dimension INT" ) --Getting datas local vehicles = executeSQLQuery("SELECT * FROM vehiclesaverb") --Spawning the vehicles for i, v in ipairs (vehicles) do --i changed the spawn to a specific cord to avoid having the car falling before it interior is set --because the interior i pretend to use is z = 1000 local vehicle = createVehicle( v.VehicleID, v.px, v.py, v.pz, v.rx, v.ry, v.rz ) setElementHealth ( vehicle, v.Health ) setVehicleColor ( vehicle, v.Color1, v.Color2, 0, 0 ) if ( v.paintjob ) then setVehiclePaintjob( vehicle, v.paintjob ) end local upgrades = split( v.upgrades, 44 ) for index, upgrade in pairs (upgrades) do addVehicleUpgrade( vehicle, upgrade ) end setVehicleDoorState ( vehicle, 0, v.Hood ) setVehicleDoorState ( vehicle, 1, v.Trunk ) setVehicleDoorState ( vehicle, 2, v.FrontLeft ) setVehicleDoorState ( vehicle, 3, v.FrontRight ) setVehicleDoorState ( vehicle, 4, v.RearLeft ) setVehicleDoorState ( vehicle, 5, v.RearRight ) setVehiclePanelState (vehicle,0,v.FrontLeftPanel) setVehiclePanelState (vehicle,1,v.FrontRightPanel) setVehiclePanelState (vehicle,2,v.RearLeftPanel) setVehiclePanelState (vehicle,3,v.RearRightPanel) setVehiclePanelState (vehicle,4,v.Windscreen) setVehiclePanelState (vehicle,5,v.FrontBumper) setVehiclePanelState (vehicle,6,v.RearBumper) setVehicleLightState (vehicle,0,v.FLL) setVehicleLightState (vehicle,1,v.FRL) setVehicleLightState (vehicle,2,v.RLL) setVehicleLightState (vehicle,3,v.RRL) setVehicleOverrideLights(vehicle, v.VehOvL) setVehicleDoorOpenRatio (vehicle,0,v.HR,0) setVehicleDoorOpenRatio (vehicle,1,v.TR,0) setVehicleDoorOpenRatio (vehicle,2,v.FLR,0) setVehicleDoorOpenRatio (vehicle,3,v.FRR,0) setVehicleDoorOpenRatio (vehicle,4,v.RLR,0) setVehicleDoorOpenRatio (vehicle,5,v.RRR,0) setVehicleWheelStates ( vehicle, v.WFL, v.WRL, v.WFR, v.WRR ) -- added this too setElementDimension(vehicle, v.Dimension) setElementInterior(vehicle, v.Interior, v.px, v.py, v.pz) -- i added the saved cords here, so it go to the right place after spawned, but this is not happening too if v.VehSirena==1 then vsirena=true elseif v.VehSirena==0 then vsirena=false end if (v.VehSirena~=2) then setVehicleSirensOn(vehicle,vsirena) end if v.EngineState==1 then setVehicleEngineState(vehicle,true) else setVehicleEngineState(vehicle,false) end setVehicleTurretPosition ( vehicle, v.XTUR, v.YTUR ) end outputChatBox( #vehicles.." vehicles were created by Garage Master", getRootElement(), 0, 255, 0 ) outputDebugString ( #vehicles.." vehicles were created by Garage Master" ) end addEventHandler ( "onResourceStart", resourceRoot, createDatabase ) addCommandHandler ( "cleargarages", function ( ) destroyElement ( getResourceRootElement ( ) ) executeSQLDropTable ( "vehiclesaverb" ) end ) Link to comment
HeavyMetal Posted February 10, 2013 Author Share Posted February 10, 2013 (edited) still with the same problem , this last one worked for you? Edited February 10, 2013 by Guest Link to comment
Castillo Posted February 10, 2013 Share Posted February 10, 2013 Server side, and it worked here, I created a vehicle on an interior, restarted the script, the vehicle is created there. Link to comment
50p Posted February 10, 2013 Share Posted February 10, 2013 Make sure it saves properly. Open the database file and check if the data has saved. Link to comment
HeavyMetal Posted February 10, 2013 Author Share Posted February 10, 2013 where is the database file? Link to comment
Castillo Posted February 10, 2013 Share Posted February 10, 2013 \server\mods\deathmatch\registry.db Link to comment
HeavyMetal Posted February 10, 2013 Author Share Posted February 10, 2013 how can i open this file? Link to comment
50p Posted February 10, 2013 Share Posted February 10, 2013 http://sourceforge.net/projects/sqlitebrowser/ Link to comment
HeavyMetal Posted February 10, 2013 Author Share Posted February 10, 2013 all fields are in the database it is still loading on dimension 0 and interior 0, send me your meta or the way you used to open it and make it work Link to comment
50p Posted February 10, 2013 Share Posted February 10, 2013 all fields are in the database From what you said it doesn't mean it's stored in the database. Switch to "Browse data" tab and select your table, check the dimension and interior columns. Link to comment
HeavyMetal Posted February 10, 2013 Author Share Posted February 10, 2013 all 0 how to make it work? and detect things right? Link to comment
50p Posted February 10, 2013 Share Posted February 10, 2013 You SQL insert ends with: ..Interior.."',"'..Dimension..'"") but should be: ..Interior.."','"..Dimension.."'") Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now