Jump to content

HeavyMetal

Members
  • Posts

    67
  • Joined

  • Last visited

Everything posted by HeavyMetal

  1. i dont want to be annoying but, how to get the value? and not table: 045D8820 from a table? anyway to convert this table code into the value? any function for that? thanks
  2. thanks, and you know how to retrieve the value of a table? and not its location code?
  3. i already saw this page,but im having the problem when i use what says on it, anyway, what means when a variable haves # before it? i know that is something related to tables, but what exactly this does?
  4. im with some problems here, i have a database witch have the player name, and a number related to it, everytime i use: result = executeSQLQuery("SELECT Name FROM owners WHERE Dim=?", 1) it work nice in the code but when i need to read this using a chat box: outputChatBox("Welcome "..tostring(result).."",player)] it says: Welcome table: 045D8820 how can i return the real value, and not a "table"?
  5. i need a nice way to keep a value of a variable "INT i" even if the server/resource has been restarted or stopped, so it can keep counting the number of players that already used a service in game. what is the better way to do that?
  6. i found the problem,it was the marker,it was using the "OnClientMarkerHit", so it was not setting the interior and dimension on a way the server could recognize (i guess), well, so i changed to "OnMarkerHit" and now im running it server side, now everything is working! thanks ! i learned a lot with you guys doing this script! i hope this topic helps more people with this problem! thanks very much for all the help
  7. im running it server side because the sql table commands are server side, it worked, it said true, and them 2 in the second test
  8. i know, but for some reason it is returning the dimension and interior the car was created, not its current one, example: if i create a car on dimension 0, interior 0 it will be saved on 0 0 , even if i take it to dimension and interior 1, but if i create it on interior and dimension 1 it works, only if i dont take it to the 0 again, because it will be saved on 1(where it was created), is there anyway to "update" the getElementByType? or something like this?
  9. thanks! it is now working but only when the car is created on the dimension and interior, when it is changed from one to another it dont work, is there anything that need to be updated when the vehicle is changed from dimension or interior, or something to get the current dimension/interior?
  10. [2013-02-10 00:28:34] Stopping garage_project [2013-02-10 00:28:34] Dropping DB table vehiclesaverb [2013-02-10 00:28:34] ERROR: garage_project\garagesave.lua:46: attempt to concatenate global 'Dimension' (a nil value)
  11. 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
  12. still with the same problem , this last one worked for you?
  13. 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
  14. 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.
  15. 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?
  16. 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
  17. i started learning lua 4 days ago, and im almost finishing my first resource, the only thing that is avoiding you from learning is that u conviced your self you cant, change that and you will see how it is easy
  18. 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?
  19. 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 )
×
×
  • Create New...