added event to create table if it doesn't exist

This commit is contained in:
HakkoDevelopment
2022-07-16 17:40:44 -06:00
committed by GitHub
parent b553fb283e
commit 527302ac4a

View File

@@ -1,5 +1,14 @@
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6 -- For support join my discord: https://discord.gg/Z9Mxu72zZ6
-- Creating database tables
AddEventHandler('onResourceStart', function(resourceName)
if (GetCurrentResourceName() ~= resourceName) then
return
end
MySQL.query("CREATE TABLE IF NOT EXISTS characters ( `character_id` INT(10) NOT NULL AUTO_INCREMENT, `license` VARCHAR(200) NOT NULL DEFAULT '0', `first_name` VARCHAR(50) NULL DEFAULT NULL, `last_name` VARCHAR(50) NULL DEFAULT NULL, `dob` VARCHAR(50) NULL DEFAULT NULL, `gender` VARCHAR(50) NULL DEFAULT NULL, `twt` VARCHAR(50) NULL DEFAULT NULL, `job` VARCHAR(50) NULL DEFAULT NULL, `cash` INT(10) NULL DEFAULT '0', `bank` INT(10) NULL DEFAULT '0', PRIMARY KEY (`character_id`) USING BTREE);")
print('^4ND_Core ^0Database structure validated!')
end)
-- Getting all the characters the player has and returning them to the client. -- Getting all the characters the player has and returning them to the client.
RegisterNetEvent("ND:GetCharacters", function() RegisterNetEvent("ND:GetCharacters", function()
local player = source local player = source
@@ -40,4 +49,4 @@ end)
AddEventHandler("playerDropped", function() AddEventHandler("playerDropped", function()
local player = source local player = source
NDCore.Players[player] = nil NDCore.Players[player] = nil
end) end)