mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 17:28:53 +00:00
Dynamic slots (#36)
* Removed slots configuration * feature: dynamic slots * fixes + improvements * edited core functionality * added commands for slots management * added commands english locale Co-authored-by: d3rp-jsx <15928886+derp-jsx@users.noreply.github.com>
This commit is contained in:
+46
-2
@@ -12,9 +12,15 @@ elseif ESX.GetConfig().Multichar == true then
|
||||
local SetupCharacters = function(playerId)
|
||||
while Fetch == -1 do Citizen.Wait(500) end
|
||||
local identifier = Config.Prefix..'%:'..ESX.GetIdentifier(playerId)
|
||||
local slots = MySQL.Sync.fetchScalar("SELECT `slots` FROM `multicharacter_slots` WHERE identifier = ?", {
|
||||
ESX.GetIdentifier(playerId)
|
||||
})
|
||||
if not slots then
|
||||
slots = Config.Slots
|
||||
end
|
||||
MySQL.Async.fetchAll(Fetch, {
|
||||
identifier,
|
||||
Config.Slots
|
||||
slots
|
||||
}, function(result)
|
||||
local characters = {}
|
||||
for i=1, #result, 1 do
|
||||
@@ -38,7 +44,7 @@ elseif ESX.GetConfig().Multichar == true then
|
||||
}
|
||||
if result[i].sex == 'm' then characters[id].sex = _('male') else characters[id].sex = _('female') end
|
||||
end
|
||||
TriggerClientEvent('esx_multicharacter:SetupUI', playerId, characters)
|
||||
TriggerClientEvent('esx_multicharacter:SetupUI', playerId, characters, slots)
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -123,6 +129,44 @@ elseif ESX.GetConfig().Multichar == true then
|
||||
TriggerEvent('esx:playerLogout', src)
|
||||
end)
|
||||
|
||||
ESX.RegisterCommand('setslots', 'admin', function(xPlayer, args, showError)
|
||||
local slots = MySQL.Sync.fetchScalar('SELECT `slots` FROM `multicharacter_slots` WHERE identifier = ?', {
|
||||
args.identifier
|
||||
})
|
||||
|
||||
if slots == nil then
|
||||
MySQL.Async.execute('INSERT INTO `multicharacter_slots` (`identifier`, `slots`) VALUES (?, ?)', {
|
||||
args.identifier,
|
||||
args.slots
|
||||
})
|
||||
xPlayer.triggerEvent('esx:showNotification', _U('slotsadd', args.slots, args.identifier))
|
||||
else
|
||||
MySQL.Async.execute('UPDATE `multicharacter_slots` SET `slots` = ? WHERE `identifier` = ?', {
|
||||
args.slots,
|
||||
args.identifier
|
||||
})
|
||||
xPlayer.triggerEvent('esx:showNotification', _U('slotsedit', args.slots, args.identifier))
|
||||
end
|
||||
end, true, {help = _U('command_setslots'), validate = true, arguments = {
|
||||
{name = 'identifier', help = _U('command_identifier'), type = 'string'},
|
||||
{name = 'slots', help = _U('command_slots'), type = 'number'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('remslots', 'admin', function(xPlayer, args, showError)
|
||||
local slots = MySQL.Sync.fetchScalar('SELECT `slots` FROM `multicharacter_slots` WHERE identifier = ?', {
|
||||
args.identifier
|
||||
})
|
||||
|
||||
if slots ~= nil then
|
||||
MySQL.Async.execute('DELETE FROM `multicharacter_slots` WHERE `identifier` = ?', {
|
||||
args.identifier
|
||||
})
|
||||
xPlayer.triggerEvent('esx:showNotification', _U('slotsrem', args.identifier))
|
||||
end
|
||||
end, true, {help = _U('command_remslots'), validate = true, arguments = {
|
||||
{name = 'identifier', help = _U('command_identifier'), type = 'string'}
|
||||
}})
|
||||
|
||||
RegisterCommand('forcelog', function(source, args, rawCommand)
|
||||
TriggerEvent('esx:playerLogout', source)
|
||||
end, true)
|
||||
|
||||
Reference in New Issue
Block a user