diff --git a/ND_Core/server/events.lua b/ND_Core/server/events.lua index 57fdb8e..dc780e9 100644 --- a/ND_Core/server/events.lua +++ b/ND_Core/server/events.lua @@ -34,7 +34,7 @@ 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', `phone_number` VARCHAR(20) NULL DEFAULT NULL, `groups` LONGTEXT NULL DEFAULT '[]', `last_location` LONGTEXT NULL DEFAULT '[]', `clothing` LONGTEXT NULL DEFAULT '[]', PRIMARY KEY (`character_id`) USING BTREE);") + 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) @@ -53,6 +53,8 @@ end) -- Update the character info when edited. RegisterNetEvent("ND:editCharacter", function(newCharacter) local player = source + local characters = NDCore.Functions.GetPlayerCharacters(player) + if not characters[newCharacter.id] then return end NDCore.Functions.UpdateCharacterData(newCharacter.id, newCharacter.firstName, newCharacter.lastName, newCharacter.dob, newCharacter.gender, newCharacter.twt, newCharacter.job) end) @@ -67,6 +69,8 @@ end) -- add a player to the table. RegisterNetEvent("ND:setCharacterOnline", function(id) local player = source + local characters = NDCore.Functions.GetPlayerCharacters(player) + if not characters[id] then return end NDCore.Functions.SetActiveCharacter(player, id) end) @@ -83,6 +87,7 @@ AddEventHandler("playerDropped", function() if character then NDCore.Functions.UpdateLastLocation(character.id, character.lastLocation) end + TriggerEvent("ND:characterUnloaded", player) character = nil end)