mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-20 23:32:47 +01:00
REFACTORRRRRR
fuck you
This commit is contained in:
+18
-18
@@ -1,22 +1,22 @@
|
||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||
|
||||
NDCore = {}
|
||||
NDCore.selectedCharacter = nil
|
||||
NDCore.SelectedCharacter = nil
|
||||
NDCore.characters = {}
|
||||
NDCore.functions = {}
|
||||
NDCore.config = config
|
||||
NDCore.Functions = {}
|
||||
NDCore.Config = config
|
||||
|
||||
function GetCoreObject()
|
||||
return NDCore
|
||||
end
|
||||
|
||||
function NDCore.functions:getSelectedCharacter(cb)
|
||||
if not cb then return NDCore.selectedCharacter end
|
||||
cb(NDCore.selectedCharacter)
|
||||
function NDCore.Functions.GetSelectedCharacter(cb)
|
||||
if not cb then return NDCore.SelectedCharacter end
|
||||
cb(NDCore.SelectedCharacter)
|
||||
end
|
||||
|
||||
function NDCore.functions:getCharacters(cb)
|
||||
if not cb then return NDCore.selectedCharacter end
|
||||
function NDCore.Functions.GetCharacters(cb)
|
||||
if not cb then return NDCore.SelectedCharacter end
|
||||
cb(NDCore.characters)
|
||||
end
|
||||
|
||||
@@ -25,12 +25,12 @@ if config.enableRichPrecence then
|
||||
Citizen.CreateThread(function()
|
||||
SetDiscordAppId(config.appId)
|
||||
while true do
|
||||
if NDCore.selectedCharacter then
|
||||
SetRichPresence(" Playing : " .. config.serverName .. " as " .. NDCore.selectedCharacter.firstName .. " " .. NDCore.selectedCharacter.lastName)
|
||||
if NDCore.SelectedCharacter then
|
||||
SetRichPresence(" Playing : " .. config.serverName .. " as " .. NDCore.SelectedCharacter.firstName .. " " .. NDCore.SelectedCharacter.lastName)
|
||||
SetDiscordRichPresenceAsset(config.largeLogo)
|
||||
SetDiscordRichPresenceAssetText("Playing: " .. config.serverName)
|
||||
SetDiscordRichPresenceAssetSmall(config.smallLogo)
|
||||
SetDiscordRichPresenceAssetSmallText("Playing as: " .. NDCore.selectedCharacter.firstName .. " " .. NDCore.selectedCharacter.lastName)
|
||||
SetDiscordRichPresenceAssetSmallText("Playing as: " .. NDCore.SelectedCharacter.firstName .. " " .. NDCore.SelectedCharacter.lastName)
|
||||
SetDiscordRichPresenceAction(0, config.firstButtonName, config.firstButtonLink)
|
||||
SetDiscordRichPresenceAction(1, config.secondButtonName, config.secondButtonLink)
|
||||
end
|
||||
@@ -44,13 +44,13 @@ if config.customPauseMenu then
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
if NDCore.selectedCharacter then
|
||||
if NDCore.SelectedCharacter then
|
||||
if IsPauseMenuActive() then
|
||||
BeginScaleformMovieMethodOnFrontendHeader("SET_HEADING_DETAILS")
|
||||
AddTextEntry("FE_THDR_GTAO", config.serverName)
|
||||
ScaleformMovieMethodAddParamPlayerNameString(NDCore.selectedCharacter.firstName .. " " .. NDCore.selectedCharacter.lastName)
|
||||
PushScaleformMovieFunctionParameterString("Cash: $" .. tostring(NDCore.selectedCharacter.cash))
|
||||
PushScaleformMovieFunctionParameterString("Bank: $" .. tostring(NDCore.selectedCharacter.bank))
|
||||
ScaleformMovieMethodAddParamPlayerNameString(NDCore.SelectedCharacter.firstName .. " " .. NDCore.SelectedCharacter.lastName)
|
||||
PushScaleformMovieFunctionParameterString("Cash: $" .. tostring(NDCore.SelectedCharacter.cash))
|
||||
PushScaleformMovieFunctionParameterString("Bank: $" .. tostring(NDCore.SelectedCharacter.bank))
|
||||
EndScaleformMovieMethod()
|
||||
end
|
||||
end
|
||||
@@ -66,13 +66,13 @@ end)
|
||||
-- updates the money on the client.
|
||||
RegisterNetEvent("ND:updateMoney")
|
||||
AddEventHandler("ND:updateMoney", function(cash, bank)
|
||||
NDCore.selectedCharacter.cash = cash
|
||||
NDCore.selectedCharacter.bank = bank
|
||||
NDCore.SelectedCharacter.cash = cash
|
||||
NDCore.SelectedCharacter.bank = bank
|
||||
end)
|
||||
|
||||
RegisterNetEvent("ND:setCharacter")
|
||||
AddEventHandler("ND:setCharacter", function(character)
|
||||
NDCore.selectedCharacter = character
|
||||
NDCore.SelectedCharacter = character
|
||||
end)
|
||||
|
||||
-- Enables pvp if it's selected in the config.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||
|
||||
server_config = {
|
||||
-- discordServerToken = "OTAwODg1MDMxMDQ2Nzc0ODQ1.GU1TSC.Ed8D2_wcU-UQ1vZhe1khahgV8J3hLahOp4N1D8", -- discord bot token for permissions
|
||||
discordServerToken = "OTAwODg1MDMxMDQ2Nzc0ODQ1.GSjH8J.qI5WBsQRZsOp1wBUsjeeNmRAJ1tZxWnSvCjQOY",
|
||||
discordServerToken = "OTAwODg1MDMxMDQ2Nzc0ODQ1.GU1TSC.Ed8D2_wcU-UQ1vZhe1khahgV8J3hLahOp4N1D8", -- discord bot token for permissions
|
||||
guildId = "872496972454592523", -- discord guild id
|
||||
}
|
||||
+13
-19
@@ -1,49 +1,43 @@
|
||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||
|
||||
-- Getting all the characters the player has and returning them to the client.
|
||||
RegisterNetEvent("ND:getCharacters")
|
||||
AddEventHandler("ND:getCharacters", function()
|
||||
RegisterNetEvent("ND:GetCharacters", function()
|
||||
local player = source
|
||||
TriggerClientEvent("ND:returnCharacters", player, NDCore.functions:getPlayerCharacters(player))
|
||||
TriggerClientEvent("ND:returnCharacters", player, NDCore.Functions.GetPlayerCharacters(player))
|
||||
end)
|
||||
|
||||
-- Creating a new character.
|
||||
RegisterNetEvent("ND:newCharacter")
|
||||
AddEventHandler("ND:newCharacter", function(newCharacter)
|
||||
RegisterNetEvent("ND:newCharacter", function(newCharacter)
|
||||
local player = source
|
||||
NDCore.functions:createCharacter(player, newCharacter.firstName, newCharacter.lastName, newCharacter.dob, newCharacter.gender, newCharacter.twt, newCharacter.job, newCharacter.cash, newCharacter.bank)
|
||||
NDCore.Functions.CreateCharacter(player, newCharacter.firstName, newCharacter.lastName, newCharacter.dob, newCharacter.gender, newCharacter.twt, newCharacter.job, newCharacter.cash, newCharacter.bank)
|
||||
end)
|
||||
|
||||
-- Update the character info when edited.
|
||||
RegisterNetEvent("ND:editCharacter")
|
||||
AddEventHandler("ND:editCharacter", function(newCharacter)
|
||||
RegisterNetEvent("ND:editCharacter", function(newCharacter)
|
||||
local player = source
|
||||
NDCore.functions:updateCharacterData(newCharacter.id, newCharacter.firstName, newCharacter.lastName, newCharacter.dob, newCharacter.gender, newCharacter.twt, newCharacter.job)
|
||||
NDCore.Functions.UpdateCharacterData(newCharacter.id, newCharacter.firstName, newCharacter.lastName, newCharacter.dob, newCharacter.gender, newCharacter.twt, newCharacter.job)
|
||||
end)
|
||||
|
||||
-- Delete character from database.
|
||||
RegisterNetEvent("ND:deleteCharacter")
|
||||
AddEventHandler("ND:deleteCharacter", function(characterId)
|
||||
RegisterNetEvent("ND:deleteCharacter", function(characterId)
|
||||
local player = source
|
||||
NDCore.functions:deleteCharacter(characterId)
|
||||
NDCore.Functions.DeleteCharacter(characterId)
|
||||
end)
|
||||
|
||||
-- add a player to the table.
|
||||
RegisterNetEvent("ND:setCharacterOnline")
|
||||
AddEventHandler("ND:setCharacterOnline", function(id)
|
||||
RegisterNetEvent("ND:setCharacterOnline", function(id)
|
||||
local player = source
|
||||
NDCore.functions:setActiveCharacter(player, id)
|
||||
NDCore.Functions.SetActiveCharacter(player, id)
|
||||
end)
|
||||
|
||||
-- Disconnecting a player
|
||||
RegisterNetEvent("ND:exitGame")
|
||||
AddEventHandler("ND:exitGame", function()
|
||||
RegisterNetEvent("ND:exitGame", function()
|
||||
local player = source
|
||||
DropPlayer(player, "Disconnected.")
|
||||
end)
|
||||
|
||||
-- Remove player from NDCore.players table when they leave.
|
||||
-- Remove player from NDCore.Players table when they leave.
|
||||
AddEventHandler("playerDropped", function()
|
||||
local player = source
|
||||
NDCore.players[player] = nil
|
||||
NDCore.Players[player] = nil
|
||||
end)
|
||||
@@ -1,13 +1,13 @@
|
||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||
|
||||
-- Callback to update each selected character on the server.
|
||||
function NDCore.functions:getPlayers(players)
|
||||
if not cb then return NDCore.players end
|
||||
cb(NDCore.players)
|
||||
function NDCore.Functions.GetPlayers(players)
|
||||
if not cb then return NDCore.Players end
|
||||
cb(NDCore.Players)
|
||||
end
|
||||
|
||||
-- Used to retrive the players discord server nickname, discord name and tag, and the roles.
|
||||
function NDCore.functions:getUserDiscordInfo(discordUserId)
|
||||
function NDCore.Functions.GetUserDiscordInfo(discordUserId)
|
||||
local data
|
||||
PerformHttpRequest("https://discordapp.com/api/guilds/" .. server_config.guildId .. "/members/" .. discordUserId, function(errorCode, resultData, resultHeaders)
|
||||
if errorCode ~= 200 then
|
||||
@@ -32,7 +32,7 @@ function NDCore.functions:getUserDiscordInfo(discordUserId)
|
||||
end
|
||||
|
||||
-- Get player any identifier, available types: steam, license, xbl, ip, discord, live.
|
||||
function NDCore.functions:GetPlayerIdentifierFromType(type, player)
|
||||
function NDCore.Functions.GetPlayerIdentifierFromType(type, player)
|
||||
local identifierCount = GetNumPlayerIdentifiers(player)
|
||||
for count = 0, identifierCount do
|
||||
local identifier = GetPlayerIdentifier(player, count)
|
||||
@@ -44,9 +44,9 @@ function NDCore.functions:GetPlayerIdentifierFromType(type, player)
|
||||
end
|
||||
|
||||
-- This will return the server id and ND player data of a nearby player.
|
||||
function NDCore.functions:getNearbyPedToPlayer(player)
|
||||
function NDCore.Functions.GetNearbyPedToPlayer(player)
|
||||
local pedCoords = GetEntityCoords(GetPlayerPed(player))
|
||||
for targetId, targetInfo in pairs(NDCore.players) do
|
||||
for targetId, targetInfo in pairs(NDCore.Players) do
|
||||
local targetCoords = GetEntityCoords(GetPlayerPed(targetId))
|
||||
if #(pedCoords - targetCoords) < 2.0 and targetId ~= player then
|
||||
return targetId, targetInfo
|
||||
@@ -55,21 +55,21 @@ function NDCore.functions:getNearbyPedToPlayer(player)
|
||||
end
|
||||
|
||||
-- update the players money on the client kinda like a refresh.
|
||||
function NDCore.functions:updateMoney(player)
|
||||
function NDCore.Functions.UpdateMoney(player)
|
||||
local player = tonumber(player)
|
||||
MySQL.query("SELECT cash, bank FROM characters WHERE character_id = ?", {NDCore.players[player].id}, function(result)
|
||||
MySQL.query("SELECT cash, bank FROM characters WHERE character_id = ?", {NDCore.Players[player].id}, function(result)
|
||||
if result then
|
||||
local cash = result[1].cash
|
||||
local bank = result[1].bank
|
||||
NDCore.players[player].cash = cash
|
||||
NDCore.players[player].bank = bank
|
||||
NDCore.Players[player].cash = cash
|
||||
NDCore.Players[player].bank = bank
|
||||
TriggerClientEvent("ND:updateMoney", player, cash, bank)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Transfer money from one players bank account to another.
|
||||
function NDCore.functions:transferBank(amount, player, target)
|
||||
function NDCore.Functions.TransferBank(amount, player, target)
|
||||
local amount = tonumber(amount)
|
||||
local player = tonumber(player)
|
||||
local target = tonumber(target)
|
||||
@@ -91,27 +91,27 @@ function NDCore.functions:transferBank(amount, player, target)
|
||||
args = {"Error", "You can't send that amount."}
|
||||
})
|
||||
return false
|
||||
elseif NDCore.players[player].bank < amount then
|
||||
elseif NDCore.Players[player].bank < amount then
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {255, 0, 0},
|
||||
args = {"Error", "You don't have enough money."}
|
||||
})
|
||||
return false
|
||||
else
|
||||
MySQL.query.await("UPDATE characters SET bank = bank - ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||
NDCore.functions:updateMoney(player)
|
||||
MySQL.query.await("UPDATE characters SET bank = bank + ? WHERE character_id = ?", {amount, NDCore.players[target].id})
|
||||
NDCore.functions:updateMoney(target)
|
||||
MySQL.query.await("UPDATE characters SET bank = bank - ? WHERE character_id = ?", {amount, NDCore.Players[player].id})
|
||||
NDCore.Functions.UpdateMoney(player)
|
||||
MySQL.query.await("UPDATE characters SET bank = bank + ? WHERE character_id = ?", {amount, NDCore.Players[target].id})
|
||||
NDCore.Functions.UpdateMoney(target)
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {0, 255, 0},
|
||||
args = {"Success", "You paid " .. NDCore.players[target].firstName .. " " .. NDCore.players[target].lastName .. " $" .. amount .. "."}
|
||||
args = {"Success", "You paid " .. NDCore.Players[target].firstName .. " " .. NDCore.Players[target].lastName .. " $" .. amount .. "."}
|
||||
})
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
-- Give cash from one players wallet to another.
|
||||
function NDCore.functions:giveCash(amount, player, target)
|
||||
function NDCore.Functions.GiveCash(amount, player, target)
|
||||
local amount = tonumber(amount)
|
||||
local player = tonumber(player)
|
||||
local target = tonumber(target)
|
||||
@@ -133,30 +133,30 @@ function NDCore.functions:giveCash(amount, player, target)
|
||||
args = {"Error", "You can't give that amount."}
|
||||
})
|
||||
return false
|
||||
elseif NDCore.players[player].cash < amount then
|
||||
elseif NDCore.Players[player].cash < amount then
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {255, 0, 0},
|
||||
args = {"Error", "You don't have enough money."}
|
||||
})
|
||||
return false
|
||||
else
|
||||
MySQL.query.await("UPDATE characters SET cash = cash - ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||
NDCore.functions:updateMoney(player)
|
||||
MySQL.query.await("UPDATE characters SET cash = cash + ? WHERE character_id = ?", {amount, NDCore.players[target].id})
|
||||
NDCore.functions:updateMoney(target)
|
||||
MySQL.query.await("UPDATE characters SET cash = cash - ? WHERE character_id = ?", {amount, NDCore.Players[player].id})
|
||||
NDCore.Functions.UpdateMoney(player)
|
||||
MySQL.query.await("UPDATE characters SET cash = cash + ? WHERE character_id = ?", {amount, NDCore.Players[target].id})
|
||||
NDCore.Functions.UpdateMoney(target)
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {0, 255, 0},
|
||||
args = {"Success", "You gave " .. NDCore.players[target].firstName .. " " .. NDCore.players[target].lastName .. " $" .. amount .. "."}
|
||||
args = {"Success", "You gave " .. NDCore.Players[target].firstName .. " " .. NDCore.Players[target].lastName .. " $" .. amount .. "."}
|
||||
})
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
-- Give money from a players wallet to a nearby player.
|
||||
function NDCore.functions:giveCashToNearbyPlayer(player, amount)
|
||||
local targetId = NDCore.functions:getNearbyPedToPlayer(player)
|
||||
function NDCore.Functions.GiveCashToNearbyPlayer(player, amount)
|
||||
local targetId = NDCore.Functions.GetNearbyPedToPlayer(player)
|
||||
if targetId then
|
||||
NDCore.functions:giveCash(amount, player, targetId)
|
||||
NDCore.Functions.GiveCash(amount, player, targetId)
|
||||
return true
|
||||
end
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
@@ -167,59 +167,59 @@ function NDCore.functions:giveCashToNearbyPlayer(player, amount)
|
||||
end
|
||||
|
||||
-- withdraws money from a players bank account to their wallet/cash.
|
||||
function NDCore.functions:withdrawMoney(amount, player)
|
||||
function NDCore.Functions.WithdrawMoney(amount, player)
|
||||
local amount = tonumber(amount)
|
||||
local player = tonumber(player)
|
||||
if amount <= 0 then return false end
|
||||
if NDCore.players[player].bank < amount then return false end
|
||||
MySQL.query.await("UPDATE characters SET bank = bank - ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||
MySQL.query.await("UPDATE characters SET cash = cash + ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||
NDCore.functions:updateMoney(player)
|
||||
if NDCore.Players[player].bank < amount then return false end
|
||||
MySQL.query.await("UPDATE characters SET bank = bank - ? WHERE character_id = ?", {amount, NDCore.Players[player].id})
|
||||
MySQL.query.await("UPDATE characters SET cash = cash + ? WHERE character_id = ?", {amount, NDCore.Players[player].id})
|
||||
NDCore.Functions.UpdateMoney(player)
|
||||
return true
|
||||
end
|
||||
|
||||
-- deposits money from a players wallet/cash to their bank account.
|
||||
function NDCore.functions:depositMoney(amount, player)
|
||||
function NDCore.Functions.DepositMoney(amount, player)
|
||||
local amount = tonumber(amount)
|
||||
local player = tonumber(player)
|
||||
if amount <= 0 then return false end
|
||||
if NDCore.players[player].cash < amount then return false end
|
||||
MySQL.query.await("UPDATE characters SET cash = cash - ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||
MySQL.query.await("UPDATE characters SET bank = bank + ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||
NDCore.functions:updateMoney(player)
|
||||
if NDCore.Players[player].cash < amount then return false end
|
||||
MySQL.query.await("UPDATE characters SET cash = cash - ? WHERE character_id = ?", {amount, NDCore.Players[player].id})
|
||||
MySQL.query.await("UPDATE characters SET bank = bank + ? WHERE character_id = ?", {amount, NDCore.Players[player].id})
|
||||
NDCore.Functions.UpdateMoney(player)
|
||||
return true
|
||||
end
|
||||
|
||||
-- Deducts money from the player, "bank" or "cash" needs to be specified.
|
||||
function NDCore.functions:deductMoney(amount, player, from)
|
||||
function NDCore.Functions.DeductMoney(amount, player, from)
|
||||
local amount = tonumber(amount)
|
||||
local player = tonumber(player)
|
||||
if from == "bank" then
|
||||
MySQL.query.await("UPDATE characters SET bank = bank - ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||
MySQL.query.await("UPDATE characters SET bank = bank - ? WHERE character_id = ?", {amount, NDCore.Players[player].id})
|
||||
elseif from == "cash" then
|
||||
MySQL.query.await("UPDATE characters SET cash = cash - ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||
MySQL.query.await("UPDATE characters SET cash = cash - ? WHERE character_id = ?", {amount, NDCore.Players[player].id})
|
||||
end
|
||||
NDCore.functions:updateMoney(player)
|
||||
NDCore.Functions.UpdateMoney(player)
|
||||
end
|
||||
|
||||
-- Adds money from the player, "bank" or "cash" needs to be specified.
|
||||
function NDCore.functions:addMoney(amount, player, to)
|
||||
function NDCore.Functions.AddMoney(amount, player, to)
|
||||
local amount = tonumber(amount)
|
||||
local player = tonumber(player)
|
||||
if to == "bank" then
|
||||
MySQL.query.await("UPDATE characters SET bank = bank + ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||
MySQL.query.await("UPDATE characters SET bank = bank + ? WHERE character_id = ?", {amount, NDCore.Players[player].id})
|
||||
elseif to == "cash" then
|
||||
MySQL.query.await("UPDATE characters SET cash = cash + ? WHERE character_id = ?", {amount, NDCore.players[player].id})
|
||||
MySQL.query.await("UPDATE characters SET cash = cash + ? WHERE character_id = ?", {amount, NDCore.Players[player].id})
|
||||
end
|
||||
NDCore.functions:updateMoney(player)
|
||||
NDCore.Functions.UpdateMoney(player)
|
||||
end
|
||||
|
||||
-- Adds the players character to the NDCore.players table, this table consists of every players selected character.
|
||||
function NDCore.functions:setActiveCharacter(player, characterId)
|
||||
-- Adds the players character to the NDCore.Players table, this table consists of every players selected character.
|
||||
function NDCore.Functions.SetActiveCharacter(player, characterId)
|
||||
local result = MySQL.query.await("SELECT * FROM characters WHERE character_id = ?", {characterId})
|
||||
if result then
|
||||
local i = result[1]
|
||||
NDCore.players[player] = {
|
||||
NDCore.Players[player] = {
|
||||
id = characterId,
|
||||
firstName = i.first_name,
|
||||
lastName = i.last_name,
|
||||
@@ -231,13 +231,13 @@ function NDCore.functions:setActiveCharacter(player, characterId)
|
||||
bank = i.bank
|
||||
}
|
||||
end
|
||||
TriggerClientEvent("ND:setCharacter", player, NDCore.players[player])
|
||||
TriggerClientEvent("ND:setCharacter", player, NDCore.Players[player])
|
||||
end
|
||||
|
||||
-- This returns all the characters the player has.
|
||||
function NDCore.functions:getPlayerCharacters(player)
|
||||
function NDCore.Functions.GetPlayerCharacters(player)
|
||||
local characters = {}
|
||||
local result = MySQL.query.await("SELECT * FROM characters WHERE license = ?", {NDCore.functions:GetPlayerIdentifierFromType("license", player)})
|
||||
local result = MySQL.query.await("SELECT * FROM characters WHERE license = ?", {NDCore.Functions.GetPlayerIdentifierFromType("license", player)})
|
||||
for i = 1, #result do
|
||||
local temp = result[i]
|
||||
characters[temp.character_id] = {id = temp.character_id, firstName = temp.first_name, lastName = temp.last_name, dob = temp.dob, gender = temp.gender, twt = temp.twt, job = temp.job, cash = temp.cash, bank = temp.bank}
|
||||
@@ -246,8 +246,8 @@ function NDCore.functions:getPlayerCharacters(player)
|
||||
end
|
||||
|
||||
-- Creates a new character for the player and returns all their characters to the client.
|
||||
function NDCore.functions:createCharacter(player, firstName, lastName, dob, gender, twt, job, cash, bank)
|
||||
local license = NDCore.functions:GetPlayerIdentifierFromType("license", player)
|
||||
function NDCore.Functions.CreateCharacter(player, firstName, lastName, dob, gender, twt, job, cash, bank)
|
||||
local license = NDCore.Functions.GetPlayerIdentifierFromType("license", player)
|
||||
if not cash or not bank or tonumber(cash) > config.startingCash or tonumber(bank) > config.startingBank then
|
||||
cash = config.startingCash
|
||||
bank = config.startingBank
|
||||
@@ -255,21 +255,21 @@ function NDCore.functions:createCharacter(player, firstName, lastName, dob, gend
|
||||
local result = MySQL.query.await("SELECT character_id FROM characters WHERE license = ?", {license})
|
||||
if result and config.characterLimit > #result then
|
||||
MySQL.query.await("INSERT INTO characters (license, first_name, last_name, dob, gender, twt, job, cash, bank) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", {license, firstName, lastName, dob, gender, twt, job, cash, bank})
|
||||
TriggerClientEvent("ND:returnCharacters", player, NDCore.functions:getPlayerCharacters(player))
|
||||
TriggerClientEvent("ND:returnCharacters", player, NDCore.Functions.GetPlayerCharacters(player))
|
||||
end
|
||||
end
|
||||
|
||||
-- Update/edit a character by character id.
|
||||
function NDCore.functions:updateCharacterData(characterId, firstName, lastName, dob, gender, twt, job)
|
||||
function NDCore.Functions.UpdateCharacterData(characterId, firstName, lastName, dob, gender, twt, job)
|
||||
MySQL.query("UPDATE characters SET first_name = ?, last_name = ?, dob = ?, gender = ?, twt = ?, job = ? WHERE character_id = ?", {firstName, lastName, dob, gender, twt, job, characterId})
|
||||
end
|
||||
|
||||
-- Delete a character by character id.
|
||||
function NDCore.functions:deleteCharacter(characterId)
|
||||
function NDCore.Functions.DeleteCharacter(characterId)
|
||||
MySQL.query("DELETE FROM characters WHERE character_id = ?", {characterId})
|
||||
end
|
||||
|
||||
function NDCore.functions:versionChecker(expectedResourceName, resourceName, downloadLink, rawGithubLink)
|
||||
function NDCore.Functions.VersionChecker(expectedResourceName, resourceName, downloadLink, rawGithubLink)
|
||||
if expectedResourceName ~= resourceName then
|
||||
print("^1[^4" .. expectedResourceName .. "^1] WARNING^0")
|
||||
print("Change the resource name to ^4" .. expectedResourceName .. " ^0or else it won't work properly!")
|
||||
@@ -306,4 +306,4 @@ function NDCore.functions:versionChecker(expectedResourceName, resourceName, dow
|
||||
end
|
||||
end)
|
||||
end
|
||||
NDCore.functions:versionChecker("ND_Core", GetCurrentResourceName(), "https://github.com/Andyyy7666/ND_Framework", "https://raw.githubusercontent.com/Andyyy7666/ND_Framework/main/ND_Core/fxmanifest.lua")
|
||||
NDCore.Functions.VersionChecker("ND_Core", GetCurrentResourceName(), "https://github.com/Andyyy7666/ND_Framework", "https://raw.githubusercontent.com/Andyyy7666/ND_Framework/main/ND_Core/fxmanifest.lua")
|
||||
@@ -1,9 +1,9 @@
|
||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||
|
||||
NDCore = {}
|
||||
NDCore.players = {}
|
||||
NDCore.functions = {}
|
||||
NDCore.config = config
|
||||
NDCore.Players = {}
|
||||
NDCore.Functions = {}
|
||||
NDCore.Config = config
|
||||
|
||||
function GetCoreObject()
|
||||
return NDCore
|
||||
|
||||
Reference in New Issue
Block a user