mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 13:56:02 +01:00
Compare commits
21 Commits
v2.1.3
...
feat/qb-co
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70a1487420 | ||
|
|
626f0ad06f | ||
|
|
d5c3acbd81 | ||
|
|
98cba87bec | ||
|
|
001fc22ef6 | ||
|
|
87420e99e9 | ||
|
|
c5597161d9 | ||
|
|
898b9aefe9 | ||
|
|
5545650dd5 | ||
|
|
f4f01a5b1c | ||
|
|
3252118f93 | ||
|
|
9d4708a1f8 | ||
|
|
d0d04ae282 | ||
|
|
c005c1b28b | ||
|
|
590044b5d6 | ||
|
|
3146172c0c | ||
|
|
2ce47ef8d1 | ||
|
|
6258651d8b | ||
|
|
eecbc8f690 | ||
|
|
1d25b54e0f | ||
|
|
e18389a52a |
@@ -29,15 +29,14 @@ AddEventHandler("gameEventTriggered", function(name, args)
|
|||||||
local victim = args[1]
|
local victim = args[1]
|
||||||
if not IsPedAPlayer(victim) or NetworkGetPlayerIndexFromPed(victim) ~= cache.playerId then return end
|
if not IsPedAPlayer(victim) or NetworkGetPlayerIndexFromPed(victim) ~= cache.playerId then return end
|
||||||
|
|
||||||
if not IsPedDeadOrDying(victim, true) then
|
local hit, bone = GetPedLastDamageBone(victim)
|
||||||
local hit, bone = GetPedLastDamageBone(victim)
|
if hit and usingAmbulance then
|
||||||
if hit and usingAmbulance then
|
local damageWeapon = ambulance:getLastDamagingWeapon(victim)
|
||||||
local damageWeapon = ambulance:getLastDamagingWeapon(victim)
|
ambulance:updateBodyDamage(bone, damageWeapon)
|
||||||
return damageWeapon and ambulance:updateBodyDamage(bone, damageWeapon)
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not IsPedDeadOrDying(victim, true) or GetEntityHealth(victim) > 100 then return end
|
||||||
|
|
||||||
local killerEntity, deathCause = GetPedSourceOfDeath(cache.ped), GetPedCauseOfDeath(cache.ped)
|
local killerEntity, deathCause = GetPedSourceOfDeath(cache.ped), GetPedCauseOfDeath(cache.ped)
|
||||||
local killerClientId = NetworkGetPlayerIndexFromPed(killerEntity)
|
local killerClientId = NetworkGetPlayerIndexFromPed(killerEntity)
|
||||||
if killerEntity ~= cache.ped and killerClientId and NetworkIsPlayerActive(killerClientId) then
|
if killerEntity ~= cache.ped and killerClientId and NetworkIsPlayerActive(killerClientId) then
|
||||||
|
|||||||
@@ -22,5 +22,50 @@ RegisterNetEvent("ND:updateLastLocation", function(location)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent("ND:revivePlayer", function()
|
RegisterNetEvent("ND:revivePlayer", function()
|
||||||
NDCore.revivePlayer(true)
|
if source == "" then return end
|
||||||
|
local veh = GetVehiclePedIsIn(cache.ped)
|
||||||
|
local seat = cache.seat
|
||||||
|
local coords = GetEntityCoords(cache.ped)
|
||||||
|
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, GetEntityHeading(cache.ped), true, true, false)
|
||||||
|
|
||||||
|
local ped = PlayerPedId()
|
||||||
|
if cache.ped ~= ped then
|
||||||
|
DeleteEntity(cache.ped)
|
||||||
|
ClearAreaOfPeds(coords.x, coords.y, coords.z, 0.2, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
SetEntityInvincible(ped, false)
|
||||||
|
FreezeEntityPosition(ped, false)
|
||||||
|
SetEntityVisible(ped, true)
|
||||||
|
SetEveryoneIgnorePlayer(ped, false)
|
||||||
|
SetPedCanBeTargetted(ped, true)
|
||||||
|
SetEntityCanBeDamaged(ped, true)
|
||||||
|
SetBlockingOfNonTemporaryEvents(ped, false)
|
||||||
|
SetPedCanRagdollFromPlayerImpact(ped, true)
|
||||||
|
ClearPedTasksImmediately(ped)
|
||||||
|
|
||||||
|
if veh and veh ~= 0 then
|
||||||
|
SetPedIntoVehicle(ped, veh, seat)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
RegisterNetEvent("ND:characterUnloaded")
|
||||||
|
|
||||||
|
RegisterNetEvent("ND:clothingMenu", function()
|
||||||
|
if GetResourceState("fivem-appearance") ~= "started" then return end
|
||||||
|
|
||||||
|
local function customize(appearance)
|
||||||
|
if not appearance then return end
|
||||||
|
TriggerServerEvent("ND:updateClothing", appearance)
|
||||||
|
end
|
||||||
|
|
||||||
|
exports["fivem-appearance"]:startPlayerCustomization(customize, {
|
||||||
|
ped = false,
|
||||||
|
headBlend = true,
|
||||||
|
faceFeatures = true,
|
||||||
|
headOverlays = true,
|
||||||
|
components = true,
|
||||||
|
props = true,
|
||||||
|
tattoos = true
|
||||||
|
})
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -33,56 +33,8 @@ function NDCore.getConfig(info)
|
|||||||
return Config[info]
|
return Config[info]
|
||||||
end
|
end
|
||||||
|
|
||||||
function NDCore.revivePlayer(reset, keepDead)
|
|
||||||
local usingAmbulance = GetResourceState("ND_Ambulance") == "started"
|
|
||||||
if not keepDead then
|
|
||||||
LocalPlayer.state.dead = false
|
|
||||||
if usingAmbulance then
|
|
||||||
local state = Player(cache.serverId).state
|
|
||||||
state:set("isDead", false, true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local veh = GetVehiclePedIsIn(cache.ped)
|
|
||||||
local seat = cache.seat
|
|
||||||
local coords = GetEntityCoords(cache.ped)
|
|
||||||
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, GetEntityHeading(cache.ped), true, true, false)
|
|
||||||
|
|
||||||
local ped = PlayerPedId()
|
|
||||||
if cache.ped ~= ped then
|
|
||||||
DeleteEntity(cache.ped)
|
|
||||||
ClearAreaOfPeds(coords.x, coords.y, coords.z, 0.2, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
SetEntityInvincible(ped, false)
|
|
||||||
FreezeEntityPosition(ped, false)
|
|
||||||
SetEntityVisible(ped, true)
|
|
||||||
SetEveryoneIgnorePlayer(ped, false)
|
|
||||||
SetPedCanBeTargetted(ped, true)
|
|
||||||
SetEntityCanBeDamaged(ped, true)
|
|
||||||
SetBlockingOfNonTemporaryEvents(ped, false)
|
|
||||||
SetPedCanRagdollFromPlayerImpact(ped, true)
|
|
||||||
ClearPedTasksImmediately(ped)
|
|
||||||
|
|
||||||
if veh and veh ~= 0 then
|
|
||||||
SetPedIntoVehicle(ped, veh, seat)
|
|
||||||
end
|
|
||||||
if reset and GetPedMovementClipset(ped) == `move_m@injured` then
|
|
||||||
ClearEntityLastDamageEntity(ped)
|
|
||||||
SetPedMoveRateOverride(ped, 1.0)
|
|
||||||
ResetPedMovementClipset(ped, 0)
|
|
||||||
end
|
|
||||||
if reset and usingAmbulance then
|
|
||||||
exports["ND_Ambulance"]:resetBodyDamage()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function NDCore.notify(...)
|
function NDCore.notify(...)
|
||||||
if GetResourceState("ModernHUD") == "started" then
|
lib.notify(...)
|
||||||
exports["ModernHUD"]:notify(...)
|
|
||||||
elseif GetResourceState("ox_lib") == "started" then
|
|
||||||
lib.notify(...)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, func in pairs(NDCore) do
|
for name, func in pairs(NDCore) do
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Config = {
|
|||||||
discordAsset = GetConvar("core:discordAsset", "andyyy"),
|
discordAsset = GetConvar("core:discordAsset", "andyyy"),
|
||||||
discordAssetSmall = GetConvar("core:discordAssetSmall", "andyyy"),
|
discordAssetSmall = GetConvar("core:discordAssetSmall", "andyyy"),
|
||||||
discordActionText = GetConvar("core:discordActionText", "DISCORD"),
|
discordActionText = GetConvar("core:discordActionText", "DISCORD"),
|
||||||
discordActionLink = GetConvar("discordActionLink", "https://discord.gg/Z9Mxu72zZ6"),
|
discordActionLink = GetConvar("core:discordActionLink", "https://discord.gg/Z9Mxu72zZ6"),
|
||||||
discordActionText2 = GetConvar("core:discordActionText2", "STORE"),
|
discordActionText2 = GetConvar("core:discordActionText2", "STORE"),
|
||||||
discordActionLink2 = GetConvar("core:discordActionLink2", "https://andyyy.tebex.io/category/fivem-scripts"),
|
discordActionLink2 = GetConvar("core:discordActionLink2", "https://andyyy.tebex.io/category/fivem-scripts"),
|
||||||
disableVehicleAirControl = GetConvarInt("core:disableVehicleAirControl", 1) == 1,
|
disableVehicleAirControl = GetConvarInt("core:disableVehicleAirControl", 1) == 1,
|
||||||
|
|||||||
@@ -218,10 +218,10 @@ end)
|
|||||||
RegisterCommand("getclothing", function(source, args, rawCommand)
|
RegisterCommand("getclothing", function(source, args, rawCommand)
|
||||||
local info = ""
|
local info = ""
|
||||||
for k, v in pairs(clothingComponents) do
|
for k, v in pairs(clothingComponents) do
|
||||||
info = ("%s\n%s = {\n drawable = %s,\n texture = %s\n},"):format(info, k, GetPedDrawableVariation(cache.ped, v), GetPedTextureVariation(cache.ped, v))
|
info = ("%s\n%s = { drawable = %s, texture = %s },"):format(info, k, GetPedDrawableVariation(cache.ped, v), GetPedTextureVariation(cache.ped, v))
|
||||||
end
|
end
|
||||||
for k, v in pairs(clothingProps) do
|
for k, v in pairs(clothingProps) do
|
||||||
info = ("%s\n%s = {\n drawable = %s,\n texture = %s\n},"):format(info, k, GetPedPropIndex(cache.ped, v), GetPedPropTextureIndex(cache.ped, v))
|
info = ("%s\n%s = { drawable = %s, texture = %s },"):format(info, k, GetPedPropIndex(cache.ped, v), GetPedPropTextureIndex(cache.ped, v))
|
||||||
end
|
end
|
||||||
lib.setClipboard(info)
|
lib.setClipboard(info)
|
||||||
end, false)
|
end, false)
|
||||||
|
|||||||
@@ -1 +1,73 @@
|
|||||||
if not lib.table.contains(Config.compatibility, "qb") then return end
|
if not lib.table.contains(Config.compatibility, "qb") then return end
|
||||||
|
|
||||||
|
local QBCore = {}
|
||||||
|
|
||||||
|
QBCore.Config = QBConfig
|
||||||
|
QBCore.Shared = QBShared
|
||||||
|
QBCore.ClientCallbacks = {}
|
||||||
|
QBCore.ServerCallbacks = {}
|
||||||
|
|
||||||
|
QBCore.Players = {}
|
||||||
|
QBCore.Functions = {}
|
||||||
|
QBCore.Player_Buckets = {}
|
||||||
|
QBCore.Entity_Buckets = {}
|
||||||
|
QBCore.UsableItems = {}
|
||||||
|
|
||||||
|
function QBCore.Functions.GetCoords(entity)
|
||||||
|
local coords = GetEntityCoords(entity)
|
||||||
|
local heading = GetEntityHeading(entity)
|
||||||
|
return vec4(coords.x, coords.y, coords.z, heading)
|
||||||
|
end
|
||||||
|
|
||||||
|
function QBCore.Functions.GetIdentifier(source, idtype)
|
||||||
|
if GetConvarInt("sv_fxdkMode", 0) == 1 then return "license:fxdk" end
|
||||||
|
return GetPlayerIdentifierByType(source, idtype or "license")
|
||||||
|
end
|
||||||
|
|
||||||
|
function QBCore.Functions.GetSource(identifier)
|
||||||
|
for src, _ in pairs(NDCore.players) do
|
||||||
|
local idens = GetPlayerIdentifiers(src)
|
||||||
|
for _, id in pairs(idens) do
|
||||||
|
if identifier == id then
|
||||||
|
return src
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local function createPlayer(player)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function QBCore.Functions.GetPlayer(source)
|
||||||
|
if type(source) == "number" then
|
||||||
|
return createPlayer(NDCore.players[source])
|
||||||
|
else
|
||||||
|
return createPlayer(NDCore.players[QBCore.Functions.GetSource(source)])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function QBCore.Functions.GetPlayerByCitizenId(citizenid)
|
||||||
|
for src in pairs(NDCore.players) do
|
||||||
|
if NDCore.players[src].id == citizenid then
|
||||||
|
return NDCore.players[src]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- function QBCore.Functions.GetOfflinePlayerByCitizenId(citizenid)
|
||||||
|
-- return QBCore.Player.GetOfflinePlayer(citizenid)
|
||||||
|
-- end
|
||||||
|
|
||||||
|
-- function QBCore.Functions.GetPlayerByLicense(license)
|
||||||
|
-- return QBCore.Player.GetPlayerByLicense(license)
|
||||||
|
-- end
|
||||||
|
|
||||||
|
function QBCore.Functions.GetPlayerByPhone(number)
|
||||||
|
for src in pairs(NDCore.players) do
|
||||||
|
if NDCore.players[src].phonenumber == number then
|
||||||
|
return createPlayer(NDCore.players[src])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ lib.addCommand("pay", {
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
lib.addCommand("unlock", {
|
lib.addCommand("unlock", {
|
||||||
help = "Admin force unlock vehicles",
|
help = "Admin Command, force unlock vehicle.",
|
||||||
restricted = "group.admin",
|
restricted = "group.admin",
|
||||||
}, function(source, args, raw)
|
}, function(source, args, raw)
|
||||||
local ped = GetPlayerPed(source)
|
local ped = GetPlayerPed(source)
|
||||||
@@ -309,13 +309,13 @@ lib.addCommand("revive", {
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
lib.addCommand("dv", {
|
lib.addCommand("dv", {
|
||||||
help = "Admin command, delete vehicles within the range.",
|
help = "Admin command, delete vehicles within the range or the closest.",
|
||||||
restricted = "group.admin",
|
restricted = "group.admin",
|
||||||
params = {
|
params = {
|
||||||
{
|
{
|
||||||
name = "range",
|
name = "range",
|
||||||
type = "number",
|
type = "number",
|
||||||
help = "The range to select vehicles for deleteion from",
|
help = "Range to delete vehicles in",
|
||||||
optional = true
|
optional = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ Config = {
|
|||||||
groups = json.decode(GetConvar("core:groups", "[]")),
|
groups = json.decode(GetConvar("core:groups", "[]")),
|
||||||
admins = json.decode(GetConvar("core:admins", "[]")),
|
admins = json.decode(GetConvar("core:admins", "[]")),
|
||||||
adminDiscordRoles = json.decode(GetConvar("core:adminDiscordRoles", "[]")),
|
adminDiscordRoles = json.decode(GetConvar("core:adminDiscordRoles", "[]")),
|
||||||
|
groupRoles = json.decode(GetConvar("core:groupRoles", "[]")),
|
||||||
multiCharacter = false,
|
multiCharacter = false,
|
||||||
compatibility = json.decode(GetConvar("core:compatibility", "[]"))
|
compatibility = json.decode(GetConvar("core:compatibility", "[]"))
|
||||||
}
|
}
|
||||||
@@ -154,3 +155,10 @@ RegisterNetEvent("ND:playerEliminated", function(info)
|
|||||||
deathInfo = info
|
deathInfo = info
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
RegisterNetEvent("ND::updateClothing", function(clothing)
|
||||||
|
local src = source
|
||||||
|
local player = NDCore.getPlayer(src)
|
||||||
|
if not player or not clothing or type(clothing) ~= "table" then return end
|
||||||
|
player.setMetadata("clothing", clothing)
|
||||||
|
end)
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ local function createCharacterTable(info)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
||||||
|
TriggerEvent("ND:updateCharacter", self)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param key string|table
|
---@param key string|table
|
||||||
@@ -128,6 +129,7 @@ local function createCharacterTable(info)
|
|||||||
self.metadata[key] = value
|
self.metadata[key] = value
|
||||||
end
|
end
|
||||||
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
||||||
|
TriggerEvent("ND:updateCharacter", self)
|
||||||
return self.metadata
|
return self.metadata
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -224,6 +226,7 @@ local function createCharacterTable(info)
|
|||||||
self.metadata.licenses = {license}
|
self.metadata.licenses = {license}
|
||||||
end
|
end
|
||||||
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
||||||
|
TriggerEvent("ND:updateCharacter", self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.getLicense(identifier)
|
function self.getLicense(identifier)
|
||||||
@@ -269,11 +272,7 @@ local function createCharacterTable(info)
|
|||||||
|
|
||||||
function self.notify(...)
|
function self.notify(...)
|
||||||
if not self.source then return end
|
if not self.source then return end
|
||||||
if GetResourceState("ModernHUD") == "started" then
|
TriggerClientEvent("ox_lib:notify", self.source, ...)
|
||||||
TriggerClientEvent("ModernHUD:notify", self.source, ...)
|
|
||||||
elseif GetResourceState("ox_lib") == "started" then
|
|
||||||
TriggerClientEvent("ox_lib:notify", self.source, ...)
|
|
||||||
end
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -310,6 +309,12 @@ local function createCharacterTable(info)
|
|||||||
self.addGroup("admin")
|
self.addGroup("admin")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for group, role in pairs(Config.groupRoles) do
|
||||||
|
if lib.table.contains(roles, role) then
|
||||||
|
self.addGroup(group)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, _ in pairs(self.groups) do
|
for name, _ in pairs(self.groups) do
|
||||||
@@ -324,10 +329,10 @@ local function createCharacterTable(info)
|
|||||||
---@param rank number
|
---@param rank number
|
||||||
---@param isJob boolean
|
---@param isJob boolean
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function self.addGroup(name, rank, isJob)
|
function self.addGroup(name, rank, info, isJob)
|
||||||
local groupRank = tonumber(rank) or 1
|
local groupRank = tonumber(rank) or 1
|
||||||
local groupInfo = Config.groups?[name]
|
local groupInfo = info or Config.groups?[name]
|
||||||
local bossRank = groupInfo and groupInfo.minimumBossRank
|
local bossRank = groupInfo?.minimumBossRank
|
||||||
|
|
||||||
-- if not groupInfo then return end
|
-- if not groupInfo then return end
|
||||||
if isJob then
|
if isJob then
|
||||||
@@ -338,8 +343,8 @@ local function createCharacterTable(info)
|
|||||||
|
|
||||||
self.groups[name] = {
|
self.groups[name] = {
|
||||||
name = name,
|
name = name,
|
||||||
label = groupInfo and groupInfo.label or name,
|
label = groupInfo?.label or name,
|
||||||
rankName = groupInfo and groupInfo.ranks[groupRank] or groupRank,
|
rankName = groupInfo?.ranks?[groupRank] or groupRank,
|
||||||
rank = groupRank,
|
rank = groupRank,
|
||||||
isJob = isJob,
|
isJob = isJob,
|
||||||
isBoss = bossRank and groupRank >= bossRank
|
isBoss = bossRank and groupRank >= bossRank
|
||||||
@@ -347,8 +352,11 @@ local function createCharacterTable(info)
|
|||||||
|
|
||||||
if not isJob then
|
if not isJob then
|
||||||
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
||||||
|
TriggerEvent("ND:updateCharacter", self)
|
||||||
end
|
end
|
||||||
|
|
||||||
lib.addPrincipal(self.source, ("group.%s"):format(name))
|
lib.addPrincipal(self.source, ("group.%s"):format(name))
|
||||||
|
|
||||||
return self.groups[name]
|
return self.groups[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -370,6 +378,7 @@ local function createCharacterTable(info)
|
|||||||
|
|
||||||
self.groups[name] = nil
|
self.groups[name] = nil
|
||||||
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
||||||
|
TriggerEvent("ND:updateCharacter", self)
|
||||||
lib.removePrincipal(self.source, ("group.%s"):format(name))
|
lib.removePrincipal(self.source, ("group.%s"):format(name))
|
||||||
return group
|
return group
|
||||||
end
|
end
|
||||||
@@ -379,12 +388,13 @@ local function createCharacterTable(info)
|
|||||||
---@return boolean
|
---@return boolean
|
||||||
function self.setJob(name, rank)
|
function self.setJob(name, rank)
|
||||||
self.removeGroup(self.job)
|
self.removeGroup(self.job)
|
||||||
local job = self.addGroup(name, rank, true)
|
local job = self.addGroup(name, rank, nil, true)
|
||||||
if job then
|
if job then
|
||||||
self.job = job.name
|
self.job = job.name
|
||||||
self.jobInfo = job
|
self.jobInfo = job
|
||||||
end
|
end
|
||||||
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
self.triggerEvent("ND:updateCharacter", removeCharacterFunctions(self))
|
||||||
|
TriggerEvent("ND:updateCharacter", self)
|
||||||
return job
|
return job
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -430,7 +440,7 @@ function NDCore.newCharacter(src, info)
|
|||||||
inventory = info.inventory or {}
|
inventory = info.inventory or {}
|
||||||
}
|
}
|
||||||
|
|
||||||
charInfo.id = MySQL.insert.await("INSERT INTO nd_characters (identifier, name, firstname, lastname, dob, gender, cash, bank, phonenumber, `groups`, metadata) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", {
|
charInfo.id = MySQL.insert.await("INSERT INTO nd_characters (identifier, name, firstname, lastname, dob, gender, cash, bank, phonenumber, `groups`, metadata, inventory) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", {
|
||||||
identifier,
|
identifier,
|
||||||
charInfo.name,
|
charInfo.name,
|
||||||
charInfo.firstname,
|
charInfo.firstname,
|
||||||
@@ -441,7 +451,8 @@ function NDCore.newCharacter(src, info)
|
|||||||
charInfo.bank,
|
charInfo.bank,
|
||||||
charInfo.phonenumber,
|
charInfo.phonenumber,
|
||||||
json.encode(charInfo.groups),
|
json.encode(charInfo.groups),
|
||||||
json.encode(charInfo.metadata)
|
json.encode(charInfo.metadata),
|
||||||
|
json.encode(charInfo.inventory)
|
||||||
})
|
})
|
||||||
|
|
||||||
return createCharacterTable(charInfo)
|
return createCharacterTable(charInfo)
|
||||||
|
|||||||
@@ -730,3 +730,30 @@ lib.callback.register("ND_Vehicles:getOwnedVehicles", function(src)
|
|||||||
if not player then return end
|
if not player then return end
|
||||||
return NDCore.getVehicles(player.id)
|
return NDCore.getVehicles(player.id)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
AddEventHandler("ND:characterLoaded", function(player)
|
||||||
|
local ownedExistingVehicles = {}
|
||||||
|
local ownedVehicles = NDCore.getVehicles(player.id)
|
||||||
|
local vehicles = GetAllVehicles()
|
||||||
|
local vehiclesToImpound = {}
|
||||||
|
|
||||||
|
for i=1, #vehicles do
|
||||||
|
local veh = vehicles[i]
|
||||||
|
local state = Entity(veh).state
|
||||||
|
if state.owner == player.id then
|
||||||
|
ownedExistingVehicles[#ownedExistingVehicles+1] = state.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=1, #ownedVehicles do
|
||||||
|
local veh = ownedVehicles[i]
|
||||||
|
if veh and not veh.stored and not veh.impounded and not lib.table.contains(ownedExistingVehicles, veh.id) then
|
||||||
|
vehiclesToImpound[#vehiclesToImpound+1] = veh.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #vehiclesToImpound == 0 then return end
|
||||||
|
|
||||||
|
local query = ("UPDATE nd_vehicles SET impounded = ? WHERE owner = ? AND id IN (%s)"):format(table.concat(vehiclesToImpound, ", "))
|
||||||
|
MySQL.rawExecute(query, {1, player.id})
|
||||||
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user