1
0
Fork 0
forked from Simnation/Main
Main/resources/[tools]/kq_propplacer/server/editable/init.lua

31 lines
1.2 KiB
Lua
Raw Permalink Normal View History

2025-06-07 08:51:21 +02:00
local function EnsureShellbuilderTableExists()
local query = [[
SELECT COUNT(*) as count
FROM information_schema.tables
WHERE table_name = 'kq_propplacer'
]]
local result = DB.SqlQuery(query)
if result and result[1] and result[1].count == 0 then
-- Table does not exist, create it
local createQuery = [[
CREATE TABLE IF NOT EXISTS `kq_propplacer` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`model` varchar(50) NOT NULL DEFAULT '0',
`coords` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`coords`)),
`rotation` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`rotation`)),
`metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
]]
DB.SqlMutate(createQuery)
print("^2kq_shellbuilder table created successfully.")
end
end
Citizen.CreateThread(function()
-- Call the function to ensure the table exists
Citizen.SetTimeout(500, EnsureShellbuilderTableExists)
end)