Jump to content

Itashi

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Itashi

  1. lmao I didn't saw that you are a staff here! thanks so much for your help it took me more than 3 hours without any result... and here you go gave me the answer! thanks again you can close this
  2. Thanks amigo alot do you think that you can help me more with some stuff? I'm just chillin and trying to learn more MTA:SA development if yes here is my discord: Itashi#2850
  3. Hello guys I just wanna know what I messed up in my script I'm facing this error for hours!! ERROR: vehicles/vehicles.Lua:35: attempt to call global 'SetElementData' (a nil value) and here is my whole code: function createVehicleForPlayer(player, command, model) local db = exports.db:getConnection() local x, y, z = getElementPosition(player) y = y + 5 dbExec(db, 'INSERT INTO vehicles (model, x, y, z) VALUES (?, ?, ?, ?)', model, x, y, z) local vehicleObject = createVehicle(model, x, y, z) outputChatBox ( "Command Syntax: /makeveh [module id]", getRootElement(), 255, 255, 0, true ) dbQuery(function (queryHandle) local results = dbPoll(queryHandle, 0) local result = results[1] SetElementData(vehicleObject, "id", vehicle.id) end, db, 'SELECT id FROM vehicles ORDER BY id DESC LIMIT 1') end addCommandHandler('makeveh', createVehicleForPlayer, false, false) function loadAllVehicles(queryHandle) local results = dbPoll(queryHandle, 0) for index, vehicle in pairs(results) do local vehicleObject = createVehicle(vehicle.model, vehicle.x, vehicle.y, vehicle.z) SetElementData(vehicleObject, "id", vehicle.id) end end addEventHandler('onResourceStart', resourceRoot, function() local db = exports.db:getConnection() dbQuery(loadAllVehicles, db, 'SELECT * FROM vehicles') end) addEventHandler('onResourceStop', resourceRoot, function() local vehicles = getElementByType('vehicle') for index, vehicle in pairs(vehicles) do local id = getElementData(vehicle, 'id') local x, y, z = getElementPosition(vehicle) dbExec(db, 'UPDATE vehicles SET x = ?, y = ?, z = ? WHERE id = ?', x, y, z, id) end end)
×
×
  • Create New...