Jump to content

[HELP] I can't create a vehicle in a vehlib.

Recommended Posts

Part of the script:

if not data.update then
        local mQuery1 = mysql:query_insert_free("INSERT INTO vehicles_shop SET vehmtamodel='"..toSQL(data["mtaModel"]).."', vehbrand='"..toSQL(data["brand"]).."', vehmodel='"..toSQL(data["model"]).."', vehyear='"..toSQL(data["year"]).."', vehprice='"..toSQL(data["price"]).."', vehtax='"..toSQL(data["tax"]).."', createdby='"..toSQL(getElementData(client, "account:id")).."', notes='"..toSQL(data["note"]).."', enabled='"..toSQL(enabled).."', `spawnto`='"..toSQL(data["spawnto"]).."', `doortype` = " .. data.doortype)
        if not mQuery1 then
            outputDebugString("VEHICLE MANAGER / VEHICLE LIB / createVehicleRecord / DATABASE ERROR")
            outputChatBox("[VEHICLE MANAGER] Failed to create new vehicle #"..mQuery1.." in library.", client, 255,0,0)
            return false

Text displayed in the console:

[18:10:55] INFO: MYSQL ERROR 1292: Incorrect datetime value: '0000-00-00 00:00:00' for column 'updatedate' at row 1
[18:10:55] ERROR: vehicle-library\s_vehicle_library.lua:127: attempt to concatenate local 'mQuery1' (a boolean value)


Does anyone know how to solve this problem? Whenever I try to create the vehicle, nothing happens and it shows this error.

Link to comment

I apologize for the late reply. The database was created so that a friend sent me an empty database structure, which he used on the server and worked for him.

CREATE TABLE IF NOT EXISTS `vehicles_shop` (
  `vehmtamodel` int(11) DEFAULT '0',
  `vehbrand` text COLLATE utf8_czech_ci,
  `vehmodel` text COLLATE utf8_czech_ci,
  `vehyear` int(11) DEFAULT '2014',
  `vehprice` int(11) DEFAULT '0',
  `vehtax` int(11) DEFAULT '0',
  `createdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `createdby` int(11) NOT NULL DEFAULT '0',
  `updatedate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `updatedby` int(11) NOT NULL DEFAULT '0',
  `notes` text COLLATE utf8_czech_ci,
  `handling` varchar(1000) COLLATE utf8_czech_ci DEFAULT NULL,
  `duration` int(11) NOT NULL DEFAULT '1000',
  `enabled` int(1) NOT NULL DEFAULT '0',
  `spawnto` tinyint(2) NOT NULL DEFAULT '0',
  `doortype` tinyint(4) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id_UNIQUE` (`id`)


Link to comment

@DatPsychopath Glad that you have responded! It looks like the issue does indeed stem from your MySQL table init query. Take a look at the following line:

  `updatedate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',

The timestamp value of 0000-00-00 00:00:00 is outside of the range from '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC. Change the line to

  `updatedate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,

because it does make sense that the SQL table entry was updated at the same time as it was created. If you have some weird code that checks if the database was never updated then you might have to adjust it too (I doubt it).

I hope that you have no problem reinitializing that database. Maybe you might have to dump it beforehand if you already have data stored inside of it.

Links for reference:

* https://dev.mysql.com/doc/refman/8.0/en/datetime.html

Good luck with your scripting project! 😄

Edited by The_GTA
  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...