I haven’t used this (why would I?), and I couldn’t say how it wouldn’t support my ESX so long as the appropriate edits for multicharacter compatibility are made. Anyway, I’m here to tell you to fix your resource.
DeleteCharacter
Client
Feel free to send any citizenid to the server
$.post('https://mx-multicharacter/DeleteCharacter', JSON.stringify({
citizenid: MX.CurrentCharacter
}));
RegisterNUICallback('DeleteCharacter', function (data) MX:TSE('mx-multicharacter:DeleteCharacter', data.citizenid) end)
Server
No check for ownership of that citizenid, and not using a prepared statement for the citizenid
AddEventHandler('mx-multicharacter:DeleteCharacter', function(cid) MX:DeleteCharacter(source, cid) end)
function MX:DeleteCharacter(source, cid)
if cid and source then
for _, v in pairs(self.DeleteTables) do
MySQL.Sync.execute("DELETE FROM `"..v.table.."` WHERE `"..v.owner.."` = '"..cid.."'")
end
Wait(200)
DropPlayer(source, 'Your character has been deleted, please login again.')
else
DropPlayer(source, '.d?.')
end
end
Congratulations on deleting your character, and database
PlayCharacter
Client
$.post('https://mx-multicharacter/PlayCharacter', JSON.stringify({
data: MX.CurrentCharacter
}));
RegisterNUICallback('PlayCharacter', function (data)
MX:Cam(false)
SetNuiFocus(false, false)
TriggerServerEvent('mx-multicharacter:CreateCharacter', data.data)
TriggerEvent('mx-spawn:Open', data.data)
MX:DelEntity()
DisplayRadar(1)
end)
Server
tt is the client-submitted cid for existing characters
AddEventHandler('mx-multicharacter:CreateCharacter', function (tt)
local src = source
if not tt then
local cid = MX:CreateCitizenId()
MX:TCE('mx-multicharacter:SetCitizenId', src, cid)
MX.players[src] = cid
else
MX.players[src] = tt
MX:TCE('mx-multicharacter:SetCitizenId', src, tt)
end
end)
SetCitizenId
Client
AddEventHandler('mx-multicharacter:SetCitizenId', function (cid) MX.CitizenId = cid end)
...
TriggerServerEvent('esx:onPlayerJoined', MX.CitizenId, MX.NewCharacterData)
Server
Receive whatever citizenid from the client and now select the appropriate character; owner be damned
RegisterNetEvent('esx:onPlayerJoined')
AddEventHandler('esx:onPlayerJoined', function(cid, data)
if not ESX.Players[source] then
onPlayerJoined(source, cid, data)
end
end)
function onPlayerJoined(playerId, citizenid, data)
local identifier = ESX.GetIdentifier(playerId)
if identifier and citizenid then
if ESX.GetPlayerFromIdentifier(identifier) then
DropPlayer(playerId, ('there was an error loading your character!\nError code: identifier-active-ingame\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same Rockstar account.\n\nYour Rockstar identifier: %s'):format(identifier))
else
MySQL.Async.fetchScalar('SELECT 1 FROM users WHERE citizenid = @citizenid', {
['@citizenid'] = citizenid
}, function(result)
if result then
loadESXPlayer(identifier, citizenid, playerId, false)
else createESXPlayer(identifier, citizenid, playerId, data) end
end)
end
else
DropPlayer(playerId, 'there was an error loading your character!\nError code: identifier-missing-ingame\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.')
end
end