# okok\_multichar

#### Step 0 (optional - only ESX)

Navigate to `es_extended/config.lua` and set `Config.Multichar = true` instead of `Config.Multichar = GetResourceState("esx_multicharacter") ~= "missing"`

#### Step 1 - Replace file `cl_utils.lua`

```lua
ESX = exports.es_extended:getSharedObject()

RegisterNetEvent(Config.EventPrefix..":notification")
AddEventHandler(Config.EventPrefix..":notification", function(title, text, type, time)
	if Config.UseOkokNotify then
		exports['okokNotify']:Alert(title, text, time, type)
	else
		ESX.ShowNotification(text)
	end
end)

RegisterNetEvent(Config.EventPrefix..":onCharacterSpawn")
AddEventHandler(Config.EventPrefix..":onCharacterSpawn", function()

	-- You can add here your code

end)

RegisterNetEvent(Config.EventPrefix..":characterFirstSpawn")
AddEventHandler(Config.EventPrefix..":characterFirstSpawn", function()

	TriggerServerEvent(Config.EventPrefix..":setWorld", 0) -- You can remove it here and add it on your clothing menu after creating the character

	if Config.ClothingSystem == 'fivem-appearance' then
		exports['fivem-appearance']:startPlayerCustomization(function (appearance)
			if (appearance) then
			  TriggerServerEvent('saveCharacterCustomization', JSON.encode(appearance))
			end
		  end)
	elseif Config.ClothingSystem == 'illenium-appearance' then
		TriggerEvent('esx_skin:openSaveableMenu')
	elseif Config.ClothingSystem == 'rcore_clothing' then
		TriggerEvent('esx_skin:openSaveableMenu')
	end

end)

RegisterNetEvent(Config.EventPrefix..":loadCharacterClothing")
AddEventHandler(Config.EventPrefix..":loadCharacterClothing", function(skin, ped)

 	if Config.ClothingSystem == 'illenium-appearance' then
		exports.rcore_clothing:setPedSkin(ped, skin)
	elseif Config.ClothingSystem == 'fivem-appearance' then
		exports['fivem-appearance']:setPedAppearance(ped, skin)
    elseif Config.ClothingSystem == 'rcore_clothing' then
        exports.rcore_clothing:setPedSkin(ped, skin)
	end

end)

RegisterNetEvent(Config.EventPrefix..":openSpawnSelection")
AddEventHandler(Config.EventPrefix..":openSpawnSelection", function(newChar, charinfo)

	TriggerServerEvent(Config.EventPrefix..":setWorld", 0) -- You can remove it here and add it on your clothing menu after creating the character

	if Config.UseOkokSpawnSelector then
		TriggerEvent('okokSpawnSelector:spawnMenu', newChar, charinfo)
	else
		-- You can add your own spawn selector here
	end

end)
```

#### Step 2 - Replace file `sv_utils.lua`

```lua
ESX = exports.es_extended:getSharedObject()
Webhook = ''

function MySQLexecute(query, values, func)
	return MySQL.Sync.fetchAll(query, values, func)
end

function MySQLinsert(query, values, func)
	return MySQL.Async.insert(query, values, func)
end

function initialItemsInfo(Player)
    -- Set the initial items to the player
end

function deleteCharacter(citizenid)
	-- You can add here events that you want to trigger when a character is deleted
end

lib.callback.register(Config.EventPrefix..":GetSkin", function(source, citizenid)
	if Config.ClothingSystem == 'rcore_clothing' then
        local skin = exports.rcore_clothing:getSkinByIdentifier(citizenid)
        if not skin then
            return false
        end

        return skin.ped_model, skin.skin
    end

	local identifier = GetIdentifier(source)
    local result = MySQLexecute('SELECT * FROM users WHERE identifier LIKE @citizenid', {['@citizenid'] = citizenid})
	if result[1] ~= nil then
		local model = json.decode(result[1].model)
		if model then return model.model, result[1].skin else return 'mp_m_freemode_01', result[1].skin end
	else
		return false
	end
end)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.rcore.cz/paid-resources/rcore_clothing/impl/okok_multichar.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
