Jump to content

Xbom

Members
  • Posts

    1
  • Joined

  • Last visited

Details

  • Gang
    NOTHING
  • Location
    Space
  • Occupation
    Test my scripts in the city
  • Interests
    Programming & Gaming

Xbom's Achievements

I ordered some spaghetti with marinara sauce and I got egg noodles and ketchup. I'm an average nobody.

I ordered some spaghetti with marinara sauce and I got egg noodles and ketchup. I'm an average nobody. (2/54)

0

Reputation

  1. Hola a todos alguien me podría ayudar con este script, no se ejecuta me da error boolean en setElementData, soy nuevo haciendo script con lua y aún no sé cómo funciona del todo el setElementData local number1 function SpawnVehPos(player, command , model) local db = exports.db:getConnection() local x,y,z = getElementPosition(player) x =x + 2 dbExec(db, 'INSERT INTO vehicles ( model , x , y , z) VALUES ( ?, ?, ?, ?) ', model, x, y, z) createVehicle(model,x,y,z) number1 = tonumber(model) if (number1 <400 or number1 >611) then outputChatBox('ERROR') else outputChatBox('Car created ') end if (not db) then outputDebugString("Error: Failed to establish connection to the MySQL database server") else outputDebugString("Success: Connected to the MySQL database server") end end 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 addCommandHandler('car',SpawnVehPos) addEventHandler('onResourceStart',resourceRoot,function() local db = exports.db:getConnection() dbQuery(loadAllVehicles, db, 'SELECT * FROM vehicles') end) addEventHandler('onResourceStop',resourceRoot,function() local vehicles = getElementsByType('vehicle') local db = exports.db:getConnection() for index , i 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...