mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
Update main.lua
Added database spam prevention
This commit is contained in:
@@ -93,17 +93,21 @@ RegisterNetEvent("newCharacter")
|
|||||||
AddEventHandler("newCharacter", function(newCharacter)
|
AddEventHandler("newCharacter", function(newCharacter)
|
||||||
local player = source
|
local player = source
|
||||||
local license = GetPlayerIdentifierFromType("license", player)
|
local license = GetPlayerIdentifierFromType("license", player)
|
||||||
exports.oxmysql:execute("SELECT MAX(character_id) AS nextID FROM characters WHERE license = ?", {license}, function(result)
|
exports.oxmysql:execute("SELECT character_id FROM characters WHERE license = ?", {GetPlayerIdentifierFromType("license", player)}, function(result)
|
||||||
if result then
|
if (result) and (config.characterLimit > #result) then
|
||||||
character_id = result[1].nextID
|
exports.oxmysql:execute("SELECT MAX(character_id) AS nextID FROM characters WHERE license = ?", {license}, function(result)
|
||||||
if not character_id then
|
if result then
|
||||||
character_id = 1
|
character_id = result[1].nextID
|
||||||
else
|
if not character_id then
|
||||||
character_id = character_id + 1
|
character_id = 1
|
||||||
end
|
else
|
||||||
exports.oxmysql:execute("INSERT INTO characters (license, character_id, first_name, last_name, dob, gender, twt, department, cash, bank) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", {license, character_id, newCharacter.firstName, newCharacter.lastName, newCharacter.dateOfBirth, newCharacter.gender, newCharacter.twtName, newCharacter.department, newCharacter.startingCash, newCharacter.startingBank}, function(id)
|
character_id = character_id + 1
|
||||||
if id then
|
end
|
||||||
TriggerClientEvent("returnNewCharacter", player, id, newCharacter)
|
exports.oxmysql:execute("INSERT INTO characters (license, character_id, first_name, last_name, dob, gender, twt, department, cash, bank) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", {license, character_id, newCharacter.firstName, newCharacter.lastName, newCharacter.dateOfBirth, newCharacter.gender, newCharacter.twtName, newCharacter.department, newCharacter.startingCash, newCharacter.startingBank}, function(id)
|
||||||
|
if id then
|
||||||
|
TriggerClientEvent("returnNewCharacter", player, id, newCharacter)
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user