mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-02 19:28:52 +00:00
Save accounts as encoded json text, migrate script found in development discord
This commit is contained in:
+12
-36
@@ -82,8 +82,18 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
return self.variables[k]
|
||||
end
|
||||
|
||||
self.getAccounts = function()
|
||||
return self.accounts
|
||||
self.getAccounts = function(minimal)
|
||||
if minimal then
|
||||
local minimalAccounts = {}
|
||||
|
||||
for k,v in ipairs(self.accounts) do
|
||||
minimalAccounts[v.name] = v.money
|
||||
end
|
||||
|
||||
return minimalAccounts
|
||||
else
|
||||
return self.accounts
|
||||
end
|
||||
end
|
||||
|
||||
self.getAccount = function(account)
|
||||
@@ -151,40 +161,6 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
self.name = newName
|
||||
end
|
||||
|
||||
self.getMissingAccounts = function(cb)
|
||||
local missingAccounts = {}
|
||||
|
||||
for account,label in pairs(Config.Accounts) do
|
||||
local found = false
|
||||
|
||||
for k2,v2 in ipairs(self.accounts) do
|
||||
if account == v2.name then
|
||||
found = true
|
||||
end
|
||||
end
|
||||
|
||||
if not found then
|
||||
missingAccounts[account] = Config.StartingAccountMoney[account] or 0
|
||||
end
|
||||
end
|
||||
|
||||
cb(missingAccounts)
|
||||
end
|
||||
|
||||
self.createMissingAccounts = function(missingAccounts, cb)
|
||||
for name,money in pairs(missingAccounts) do
|
||||
MySQL.Async.execute('INSERT INTO user_accounts (identifier, name, money) VALUES (@identifier, @name, @money)', {
|
||||
['@identifier'] = self.identifier,
|
||||
['@name'] = name,
|
||||
['@money'] = money
|
||||
}, function(rowsChanged)
|
||||
if cb then
|
||||
cb()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
self.setAccountMoney = function(accountName, money)
|
||||
if money >= 0 then
|
||||
local account = self.getAccount(accountName)
|
||||
|
||||
Reference in New Issue
Block a user