mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-18 22:36:03 +01:00
fix: update character info if online
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
local function charDelete(self)
|
local function charDelete(self)
|
||||||
local result = MySQL.query.await("DELETE FROM nd_characters WHERE charid = ?", {self.id})
|
local result = MySQL.query.await("DELETE FROM nd_characters WHERE charid = ?", {self.id})
|
||||||
|
if result and self.source then
|
||||||
|
ActivePlayers[self.source] = nil
|
||||||
|
end
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -9,6 +12,7 @@ local function charDeductMoney(self, account, amount, reason)
|
|||||||
self[account] -= amount
|
self[account] -= amount
|
||||||
if self.source then
|
if self.source then
|
||||||
TriggerEvent("ND:moneyChange", self.source, account, amount, "remove", reason)
|
TriggerEvent("ND:moneyChange", self.source, account, amount, "remove", reason)
|
||||||
|
ActivePlayers[self.source] = self
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -19,6 +23,7 @@ local function charAddMoney(self, account, amount, reason)
|
|||||||
self[account] += amount
|
self[account] += amount
|
||||||
if self.source then
|
if self.source then
|
||||||
TriggerEvent("ND:moneyChange", self.source, account, amount, "add", reason)
|
TriggerEvent("ND:moneyChange", self.source, account, amount, "add", reason)
|
||||||
|
ActivePlayers[self.source] = self
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -37,6 +42,11 @@ end
|
|||||||
|
|
||||||
local function charSetMetadata(self, key, value)
|
local function charSetMetadata(self, key, value)
|
||||||
self.metadata[key] = value
|
self.metadata[key] = value
|
||||||
|
if self.source then
|
||||||
|
ActivePlayers[self.source] = self
|
||||||
|
return ActivePlayers[self.source].metadata
|
||||||
|
end
|
||||||
|
return self.metadata
|
||||||
end
|
end
|
||||||
|
|
||||||
local function charUnload(self)
|
local function charUnload(self)
|
||||||
@@ -44,6 +54,7 @@ local function charUnload(self)
|
|||||||
local ped = GetPlayerPed(self.source)
|
local ped = GetPlayerPed(self.source)
|
||||||
self:setMetadata("location", GetEntityCoords(ped))
|
self:setMetadata("location", GetEntityCoords(ped))
|
||||||
self:save()
|
self:save()
|
||||||
|
if not self.source then return end
|
||||||
ActivePlayers[self.source] = nil
|
ActivePlayers[self.source] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -85,6 +96,10 @@ local function charCreateLicense(self, licenseType, expire)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
self.metadata.licenses = {license}
|
self.metadata.licenses = {license}
|
||||||
|
|
||||||
|
if not self.source then return end
|
||||||
|
ActivePlayers[self.source] = self
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function initPlayerTable(playerTable)
|
local function initPlayerTable(playerTable)
|
||||||
|
|||||||
Reference in New Issue
Block a user