mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
feat(chars): enable or disable a specific character of a player (#43)
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
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'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('enablechar', 'admin', function(xPlayer, args, showError)
|
||||
|
||||
local selectedCharacter = 'char'..args.charslot..':'..args.identifier;
|
||||
|
||||
MySQL.Async.execute('UPDATE `users` SET `disabled` = 0 WHERE identifier = ?', {
|
||||
selectedCharacter
|
||||
}, function(result)
|
||||
if result > 0 then
|
||||
xPlayer.triggerEvent('esx:showNotification', _U('charenabled', args.charslot, args.identifier))
|
||||
else
|
||||
xPlayer.triggerEvent('esx:showNotification', _U('charnotfound', args.charslot, args.identifier))
|
||||
end
|
||||
end)
|
||||
|
||||
end, true, {help = _U('command_enablechar'), validate = true, arguments = {
|
||||
{name = 'identifier', help = _U('command_identifier'), type = 'string'},
|
||||
{name = 'charslot', help = _U('command_charslot'), type = 'number'}
|
||||
}})
|
||||
|
||||
ESX.RegisterCommand('disablechar', 'admin', function(xPlayer, args, showError)
|
||||
|
||||
local selectedCharacter = 'char'..args.charslot..':'..args.identifier;
|
||||
|
||||
MySQL.Async.execute('UPDATE `users` SET `disabled` = 1 WHERE identifier = ?', {
|
||||
selectedCharacter
|
||||
}, function(result)
|
||||
if result > 0 then
|
||||
xPlayer.triggerEvent('esx:showNotification', _U('chardisabled', args.charslot, args.identifier))
|
||||
else
|
||||
xPlayer.triggerEvent('esx:showNotification', _U('charnotfound', args.charslot, args.identifier))
|
||||
end
|
||||
end)
|
||||
|
||||
end, true, {help = _U('command_disablechar'), validate = true, arguments = {
|
||||
{name = 'identifier', help = _U('command_identifier'), type = 'string'},
|
||||
{name = 'charslot', help = _U('command_charslot'), type = 'number'}
|
||||
}})
|
||||
|
||||
RegisterCommand('forcelog', function(source, args, rawCommand)
|
||||
TriggerEvent('esx:playerLogout', source)
|
||||
end, true)
|
||||
+3
-44
@@ -40,7 +40,8 @@ elseif ESX.GetConfig().Multichar == true then
|
||||
firstname = result[i].firstname,
|
||||
lastname = result[i].lastname,
|
||||
dateofbirth = result[i].dateofbirth,
|
||||
skin = json.decode(result[i].skin)
|
||||
skin = json.decode(result[i].skin),
|
||||
disabled = result[i].disabled,
|
||||
}
|
||||
if result[i].sex == 'm' then characters[id].sex = _('male') else characters[id].sex = _('female') end
|
||||
end
|
||||
@@ -83,7 +84,7 @@ elseif ESX.GetConfig().Multichar == true then
|
||||
print(('[^2INFO^7] Attempted to update ^5%s^7 columns to use VARCHAR(60)'):format(varsize))
|
||||
end
|
||||
if not next(ESX.Jobs) then ESX.Jobs = GetJobs() end
|
||||
Fetch = MySQL.Sync.store("SELECT `identifier`, `accounts`, `job`, `job_grade`, `firstname`, `lastname`, `dateofbirth`, `sex`, `skin` FROM `users` WHERE identifier LIKE ? LIMIT ?")
|
||||
Fetch = MySQL.Sync.store("SELECT `identifier`, `accounts`, `job`, `job_grade`, `firstname`, `lastname`, `dateofbirth`, `sex`, `skin`, `disabled` FROM `users` WHERE identifier LIKE ? LIMIT ?")
|
||||
end
|
||||
end)
|
||||
end)
|
||||
@@ -129,48 +130,6 @@ 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)
|
||||
|
||||
else
|
||||
SetTimeout(3000, function() print('[^3WARNING^7] Multicharacter is disabled - please check your ESX configuration') end)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user