mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 13:56:02 +01:00
2.0.0
This commit is contained in:
@@ -10,23 +10,26 @@ if resource ~= expectedName then
|
||||
end
|
||||
|
||||
-- check if resource version is up to date
|
||||
PerformHttpRequest("https://raw.githubusercontent.com/Andyyy7666/ND_Framework/main/ND_Core/fxmanifest.lua", function(error, res, head)
|
||||
i, j = string.find(tostring(res), "version")
|
||||
res = string.sub(tostring(res), i, j + 6)
|
||||
res = string.gsub(res, "version ", "")
|
||||
res = string.gsub(res, '"', "")
|
||||
resp = tonumber(res)
|
||||
verFile = GetResourceMetadata(expectedName, "version", 0)
|
||||
|
||||
if verFile then
|
||||
if tonumber(verFile) < resp then
|
||||
PerformHttpRequest("https://raw.githubusercontent.com/Andyyy7666/ND_Framework/main/ND_Core/fxmanifest.lua", function(errorCode, resultData, resultHeaders)
|
||||
i, j = string.find(tostring(resultData), "version")
|
||||
resultData = string.sub(tostring(resultData), i, j + 12)
|
||||
resultData = string.gsub(resultData, "version \"", "")
|
||||
i, j = string.find(resultData, "\"")
|
||||
resultData = string.sub(resultData, 1, i - 1)
|
||||
local githubVersion = string.gsub(resultData, "%.", "")
|
||||
local fileVersion = string.gsub(GetResourceMetadata(expectedName, "version", 0), "%.", "")
|
||||
githubVersion = tonumber(githubVersion)
|
||||
fileVersion = tonumber(fileVersion)
|
||||
|
||||
if githubVersion and fileVersion then
|
||||
if githubVersion > fileVersion then
|
||||
print("^1[^4" .. expectedName .. "^1] WARNING^0")
|
||||
print("^4" .. expectedName .. " ^0is outdated. Please update it from ^5https://github.com/Andyyy7666/ND_Framework ^0| Current Version: ^1" .. verFile .. " ^0| New Version: ^2" .. resp .. " ^0|")
|
||||
elseif tonumber(verFile) > tonumber(resp) then
|
||||
print("^4" .. expectedName .. " ^0is outdated. Please update it from ^5https://github.com/Andyyy7666/ND_Framework ^0| Current Version: ^1" .. fileVersion .. " ^0| New Version: ^2" .. githubVersion .. " ^0|")
|
||||
elseif githubVersion < fileVersion then
|
||||
print("^1[^4" .. expectedName .. "^1] WARNING^0")
|
||||
print("^4" .. expectedName .. "s ^0version number is higher than we expected. | Current Version: ^3" .. verFile .. " ^0| Expected Version: ^2" .. resp .. " ^0|")
|
||||
print("^4" .. expectedName .. " ^0version number is higher than expected | Current Version: ^3" .. fileVersion .. " ^0| Expected Version: ^2" .. githubVersion .. " ^0|")
|
||||
else
|
||||
print("^4" .. expectedName .. " ^0is up to date | Current Version: ^2" .. verFile .. " ^0|")
|
||||
print("^4" .. expectedName .. " ^0is up to date | Current Version: ^2" .. fileVersion .. " ^0|")
|
||||
end
|
||||
else
|
||||
print("^1[^4" .. expectedName .. "^1] WARNING^0")
|
||||
@@ -34,27 +37,43 @@ PerformHttpRequest("https://raw.githubusercontent.com/Andyyy7666/ND_Framework/ma
|
||||
end
|
||||
end)
|
||||
|
||||
-- onlinePlayers table.
|
||||
onlinePlayers = {}
|
||||
|
||||
-- Get player identifier function (This will not change the identifier all the time)
|
||||
function GetPlayerIdentifierFromType(type, source) -- Credits: xander1998, Post: https://forum.cfx.re/t/solved-is-there-a-better-way-to-get-lic-steam-and-ip-than-getplayeridentifiers/236243/2?u=andyyy7666
|
||||
local identifiers = {}
|
||||
local identifierCount = GetNumPlayerIdentifiers(source)
|
||||
|
||||
for a = 0, identifierCount do
|
||||
table.insert(identifiers, GetPlayerIdentifier(source, a))
|
||||
end
|
||||
|
||||
for b = 1, #identifiers do
|
||||
if string.find(identifiers[b], type, 1) then
|
||||
return identifiers[b]
|
||||
end
|
||||
end
|
||||
return nil
|
||||
-- Used to retrive the players discord server nickname, discord name and tag, and the roles.
|
||||
function getUserDiscordInfo(discordUserId)
|
||||
local data
|
||||
PerformHttpRequest("https://discordapp.com/api/guilds/" .. server_config.guildId .. "/members/" .. discordUserId, function(errorCode, resultData, resultHeaders)
|
||||
if errorCode ~= 200 then
|
||||
return
|
||||
end
|
||||
local result = json.decode(resultData)
|
||||
local roles = {}
|
||||
for _, roleId in pairs(result.roles) do
|
||||
roles[roleId] = roleId
|
||||
end
|
||||
data = {
|
||||
nickname = result.nick,
|
||||
discordTag = tostring(result.user.username) .. "#" .. tostring(result.user.discriminator),
|
||||
roles = roles
|
||||
}
|
||||
end, "GET", "", {["Content-Type"] = "application/json", ["Authorization"] = "Bot " .. server_config.discordServerToken})
|
||||
while not data do
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
return data
|
||||
end
|
||||
|
||||
function validateMoney(cash, bank)
|
||||
-- Get player any identifier, available types: steam, license, xbl, ip, discord, live.
|
||||
function GetPlayerIdentifierFromType(type, source)
|
||||
local identifierCount = GetNumPlayerIdentifiers(source)
|
||||
for count = 0, identifierCount do
|
||||
local identifier = GetPlayerIdentifier(source, count)
|
||||
if identifier and string.find(identifier, type) then
|
||||
return identifier
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function validateMoney(cash, bank)
|
||||
if tonumber(cash) > config.maxStartingCash or tonumber(bank) > config.maxStartingBank then
|
||||
return false
|
||||
end
|
||||
@@ -62,12 +81,13 @@ function validateMoney(cash, bank)
|
||||
end
|
||||
|
||||
function validateDepartment(player, department)
|
||||
local rolePermission = false
|
||||
local departmentExists = config.departments[department]
|
||||
if departmentExists then
|
||||
for i = 1, #departmentExists do
|
||||
rolePermission = IsRolePresent(player, department, departmentExists[i], "start")
|
||||
if rolePermission then
|
||||
local discordUserId = string.gsub(GetPlayerIdentifierFromType("discord", player), "discord:", "")
|
||||
local roles = getUserDiscordInfo(discordUserId).roles
|
||||
|
||||
for _, roleId in pairs(departmentExists) do
|
||||
if roles[roleId] or roleId == 0 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -75,25 +95,22 @@ function validateDepartment(player, department)
|
||||
return false
|
||||
end
|
||||
|
||||
-- Using the IsRolePresent function from discord.lua to check if the player has the roles.
|
||||
RegisterNetEvent("checkPerms")
|
||||
AddEventHandler("checkPerms", function(role)
|
||||
AddEventHandler("checkPerms", function()
|
||||
local player = source
|
||||
local rolePermission = false
|
||||
for i = 1, #config.departments[role] do
|
||||
rolePermission = IsRolePresent(player, role, config.departments[role][i], "start")
|
||||
if rolePermission then
|
||||
break
|
||||
local discordUserId = string.gsub(GetPlayerIdentifierFromType("discord", player), "discord:", "")
|
||||
local allowedRoles = {}
|
||||
local roles = getUserDiscordInfo(discordUserId).roles
|
||||
|
||||
for dept, roleTable in pairs(config.departments) do
|
||||
for _, roleId in pairs(roleTable) do
|
||||
if roles[roleId] or roleId == 0 then
|
||||
table.insert(allowedRoles, dept)
|
||||
end
|
||||
end
|
||||
end
|
||||
TriggerClientEvent("permsChecked", player, role, rolePermission)
|
||||
end)
|
||||
|
||||
-- Disconnecting a player
|
||||
RegisterNetEvent("exitGame")
|
||||
AddEventHandler("exitGame", function()
|
||||
local player = source
|
||||
DropPlayer(player, "Disconnected using framework.")
|
||||
TriggerClientEvent("permsChecked", player, allowedRoles)
|
||||
end)
|
||||
|
||||
-- Inserting the players characters into characters table
|
||||
@@ -124,7 +141,7 @@ AddEventHandler("newCharacter", function(newCharacter)
|
||||
|
||||
local startingCash = newCharacter.startingCash
|
||||
local startingBank = newCharacter.startingBank
|
||||
print(startingCash)
|
||||
|
||||
if config.enableMoneySystem then
|
||||
-- Don't trust the client, validate maximum amounts.
|
||||
local moneyCheck = validateMoney(startingCash, startingBank)
|
||||
@@ -177,51 +194,8 @@ AddEventHandler("editCharacter", function(newCharacter)
|
||||
exports.oxmysql:query("UPDATE characters SET first_name = ?, last_name = ?, dob = ?, gender = ?, twt = ?, department = ? WHERE license = ? AND character_id = ?", {newCharacter.firstName, newCharacter.lastName, newCharacter.dateOfBirth, newCharacter.gender, newCharacter.twtName, newCharacter.department, GetPlayerIdentifierFromType("license", player), newCharacter.id})
|
||||
end)
|
||||
|
||||
if config.enableMoneySystem then
|
||||
-- This is used to find out how much money the player has and use it in the client to show it on the ui.
|
||||
RegisterNetEvent("getMoney")
|
||||
AddEventHandler("getMoney", function(characterid)
|
||||
local player = source
|
||||
local license = GetPlayerIdentifierFromType("license", player)
|
||||
exports.oxmysql:query("SELECT cash, bank FROM characters WHERE license = ? AND character_id = ?", {license, characterid}, function(result)
|
||||
if result then
|
||||
local cash = result[1].cash
|
||||
local bank = result[1].bank
|
||||
onlinePlayers[player].cash = cash
|
||||
onlinePlayers[player].bank = bank
|
||||
TriggerClientEvent("returnMoney", player, cash, bank)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
-- paying command.
|
||||
RegisterCommand(config.payCommand, function(source, args, raw)
|
||||
local player = source
|
||||
local target = tonumber(args[1])
|
||||
local amount = tonumber(args[2])
|
||||
transferBank(amount, player, target)
|
||||
end)
|
||||
|
||||
-- Give money command.
|
||||
RegisterCommand(config.giveCommand, function(source, args, raw)
|
||||
local player = source
|
||||
local amount = tonumber(args[1])
|
||||
giveCashToClosestTarget(amount, player)
|
||||
end)
|
||||
|
||||
-- Salary.
|
||||
local salaryInterval = config.salaryInterval * 60000
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(salaryInterval)
|
||||
for playerid, playerinfo in pairs(onlinePlayers) do
|
||||
local license = GetPlayerIdentifierFromType("license", playerid)
|
||||
exports.oxmysql:query("UPDATE characters SET bank = bank + ? WHERE license = ? AND character_id = ?", {config.salaryAmount, license, playerinfo.characterId})
|
||||
TriggerClientEvent("receiveSalary", playerid, config.salaryAmount)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
-- onlinePlayers table, this is used to store all the players current character info on the server.
|
||||
onlinePlayers = {}
|
||||
|
||||
-- add a player to the table.
|
||||
RegisterNetEvent("characterOnline")
|
||||
@@ -252,111 +226,174 @@ AddEventHandler("playerDropped", function(reason)
|
||||
onlinePlayers[player] = nil
|
||||
end)
|
||||
|
||||
-- Disconnecting a player
|
||||
RegisterNetEvent("exitGame")
|
||||
AddEventHandler("exitGame", function()
|
||||
local player = source
|
||||
DropPlayer(player, "Disconnected using framework.")
|
||||
end)
|
||||
|
||||
-- this is for the exports
|
||||
function getCharacterTable()
|
||||
return onlinePlayers
|
||||
end
|
||||
|
||||
function transferBank(amount, player, target)
|
||||
exports.oxmysql:query("SELECT bank FROM characters WHERE license = ? AND character_id = ?", {GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId}, function(result)
|
||||
function updateMoney(player)
|
||||
local player = tonumber(player)
|
||||
local license = GetPlayerIdentifierFromType("license", player)
|
||||
exports.oxmysql:query("SELECT cash, bank FROM characters WHERE license = ? AND character_id = ?", {license, onlinePlayers[player].characterId}, function(result)
|
||||
if result then
|
||||
if player == target then
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {255, 0, 0},
|
||||
args = {"Error", "You can't send money to yourself."}
|
||||
})
|
||||
elseif GetPlayerPing(target) == 0 then
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {255, 0, 0},
|
||||
args = {"Error", "That player does not exist."}
|
||||
})
|
||||
elseif result[1].bank < amount then
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {255, 0, 0},
|
||||
args = {"Error", "You don't have enough money."}
|
||||
})
|
||||
else
|
||||
exports.oxmysql:query("UPDATE characters SET bank = bank - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
TriggerClientEvent("updateMoney", player)
|
||||
exports.oxmysql:query("UPDATE characters SET bank = bank + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", target), onlinePlayers[target].characterId})
|
||||
TriggerClientEvent("updateMoney", target)
|
||||
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {0, 255, 0},
|
||||
args = {"Success", "You paid " .. onlinePlayers[target].firstName .. " " .. onlinePlayers[target].lastName .. " $" .. amount .. "."}
|
||||
})
|
||||
TriggerClientEvent("receiveBank", target, amount, onlinePlayers[player].firstName .. " " .. onlinePlayers[player].lastName, player)
|
||||
end
|
||||
local cash = result[1].cash
|
||||
local bank = result[1].bank
|
||||
onlinePlayers[player].cash = cash
|
||||
onlinePlayers[player].bank = bank
|
||||
TriggerClientEvent("updateMoney", player, cash, bank)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function transferBank(amount, player, target)
|
||||
local amount = tonumber(amount)
|
||||
local player = tonumber(player)
|
||||
local target = tonumber(target)
|
||||
if player == target then
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {255, 0, 0},
|
||||
args = {"Error", "You can't send money to yourself."}
|
||||
})
|
||||
return false
|
||||
elseif GetPlayerPing(target) == 0 then
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {255, 0, 0},
|
||||
args = {"Error", "That player does not exist."}
|
||||
})
|
||||
return false
|
||||
elseif onlinePlayers[player].bank < amount then
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {255, 0, 0},
|
||||
args = {"Error", "You don't have enough money."}
|
||||
})
|
||||
return false
|
||||
else
|
||||
exports.oxmysql:query("UPDATE characters SET bank = bank - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
updateMoney(player)
|
||||
exports.oxmysql:query("UPDATE characters SET bank = bank + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", target), onlinePlayers[target].characterId})
|
||||
updateMoney(target)
|
||||
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {0, 255, 0},
|
||||
args = {"Success", "You paid " .. onlinePlayers[target].firstName .. " " .. onlinePlayers[target].lastName .. " $" .. amount .. "."}
|
||||
})
|
||||
TriggerClientEvent("receiveBank", target, amount, onlinePlayers[player].firstName .. " " .. onlinePlayers[player].lastName, player)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function giveCashToClosestTarget(amount, player)
|
||||
exports.oxmysql:query("SELECT cash FROM characters WHERE license = ? AND character_id = ?", {GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId}, function(result)
|
||||
if result then
|
||||
local playerFound = false
|
||||
local playerCoords = GetEntityCoords(GetPlayerPed(player))
|
||||
if result[1].cash < amount then
|
||||
local amount = tonumber(amount)
|
||||
local player = tonumber(player)
|
||||
local playerFound = false
|
||||
local playerCoords = GetEntityCoords(GetPlayerPed(player))
|
||||
if onlinePlayers[player].cash < amount then
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {255, 0, 0},
|
||||
args = {"Error", "You don't have enough money."}
|
||||
})
|
||||
return false
|
||||
else
|
||||
for targetId, targetInfo in pairs(onlinePlayers) do
|
||||
local targetCoords = GetEntityCoords(GetPlayerPed(targetId))
|
||||
if (#(playerCoords - targetCoords) < 2.0) and (targetId ~= player) and not playerFound then
|
||||
exports.oxmysql:query("UPDATE characters SET cash = cash - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
updateMoney(player)
|
||||
exports.oxmysql:query("UPDATE characters SET cash = cash + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", targetId), tonumber(targetInfo.characterId)})
|
||||
updateMoney(targetId)
|
||||
playerFound = true
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {255, 0, 0},
|
||||
args = {"Error", "You don't have enough money."}
|
||||
color = {0, 255, 0},
|
||||
args = {"Success", "You gave " .. onlinePlayers[targetId].firstName .. " " .. onlinePlayers[targetId].lastName .. " $" .. amount .. "."}
|
||||
})
|
||||
else
|
||||
for k, v in pairs(onlinePlayers) do
|
||||
local targetCoords = GetEntityCoords(GetPlayerPed(k))
|
||||
if (#(playerCoords - targetCoords) < 2.0) and (k ~= player) and not playerFound then
|
||||
exports.oxmysql:query("UPDATE characters SET cash = cash - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
TriggerClientEvent("updateMoney", player)
|
||||
exports.oxmysql:query("UPDATE characters SET cash = cash + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", k), tonumber(v.characterId)})
|
||||
TriggerClientEvent("updateMoney", k)
|
||||
playerFound = true
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {0, 255, 0},
|
||||
args = {"Success", "You gave " .. onlinePlayers[k].firstName .. " " .. onlinePlayers[k].lastName .. " $" .. amount .. "."}
|
||||
})
|
||||
TriggerClientEvent("receiveCash", k, amount, onlinePlayers[player].firstName .. " " .. onlinePlayers[player].lastName, player)
|
||||
break
|
||||
end
|
||||
end
|
||||
if not playerFound then
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {255, 0, 0},
|
||||
args = {"Error", "No players nearby."}
|
||||
})
|
||||
end
|
||||
playerFound = false
|
||||
end
|
||||
TriggerClientEvent("receiveCash", targetId, amount, onlinePlayers[player].firstName .. " " .. onlinePlayers[player].lastName, player)
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
if not playerFound then
|
||||
TriggerClientEvent("chat:addMessage", player, {
|
||||
color = {255, 0, 0},
|
||||
args = {"Error", "No players nearby."}
|
||||
})
|
||||
return false
|
||||
end
|
||||
playerFound = false
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function withdrawMoney(amount, player)
|
||||
exports.oxmysql:query("UPDATE characters SET bank = bank - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
exports.oxmysql:query("UPDATE characters SET cash = cash + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
TriggerClientEvent("updateMoney", player)
|
||||
local amount = tonumber(amount)
|
||||
local player = tonumber(player)
|
||||
if onlinePlayers[player].bank >= amount then
|
||||
exports.oxmysql:query("UPDATE characters SET bank = bank - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
exports.oxmysql:query("UPDATE characters SET cash = cash + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
Citizen.Wait(500)
|
||||
updateMoney(player)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function depositMoney(amount, player)
|
||||
exports.oxmysql:query("UPDATE characters SET cash = cash - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
exports.oxmysql:query("UPDATE characters SET bank = bank + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
TriggerClientEvent("updateMoney", player)
|
||||
local amount = tonumber(amount)
|
||||
local player = tonumber(player)
|
||||
if onlinePlayers[player].cash >= amount then
|
||||
exports.oxmysql:query("UPDATE characters SET cash = cash - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
exports.oxmysql:query("UPDATE characters SET bank = bank + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
Citizen.Wait(500)
|
||||
updateMoney(player)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function deductMoney(amount, player, from)
|
||||
local amount = tonumber(amount)
|
||||
local player = tonumber(player)
|
||||
if from == "bank" then
|
||||
exports.oxmysql:query("UPDATE characters SET bank = bank - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
TriggerClientEvent("updateMoney", player)
|
||||
Citizen.Wait(500)
|
||||
updateMoney(player)
|
||||
elseif from == "cash" then
|
||||
exports.oxmysql:query("UPDATE characters SET cash = cash - ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
TriggerClientEvent("updateMoney", player)
|
||||
Citizen.Wait(500)
|
||||
updateMoney(player)
|
||||
end
|
||||
end
|
||||
|
||||
function addMoney(amount, player, to)
|
||||
local amount = tonumber(amount)
|
||||
local player = tonumber(player)
|
||||
if to == "bank" then
|
||||
exports.oxmysql:query("UPDATE characters SET bank = bank + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
TriggerClientEvent("updateMoney", player)
|
||||
Citizen.Wait(500)
|
||||
updateMoney(player)
|
||||
elseif to == "cash" then
|
||||
exports.oxmysql:query("UPDATE characters SET cash = cash + ? WHERE license = ? AND character_id = ?", {amount, GetPlayerIdentifierFromType("license", player), onlinePlayers[player].characterId})
|
||||
TriggerClientEvent("updateMoney", player)
|
||||
Citizen.Wait(500)
|
||||
updateMoney(player)
|
||||
end
|
||||
end
|
||||
|
||||
-- paying command.
|
||||
RegisterCommand(config.payCommand, function(source, args, raw)
|
||||
local player = source
|
||||
local target = tonumber(args[1])
|
||||
local amount = math.floor(tonumber(args[2]))
|
||||
transferBank(amount, player, target)
|
||||
end)
|
||||
|
||||
-- Give money command.
|
||||
RegisterCommand(config.giveCommand, function(source, args, raw)
|
||||
local player = source
|
||||
local amount = math.floor(tonumber(args[1]))
|
||||
giveCashToClosestTarget(amount, player)
|
||||
end)
|
||||
Reference in New Issue
Block a user