# New QBCore Adapt

{% hint style="danger" %}
Incomplete or incorrect installation will result in a multicharacter error and will not save your new characters.
{% endhint %}

{% hint style="warning" %}
qb-multicharacter should be disabled or deprecated.
{% endhint %}

{% hint style="info" %}
Visit this folder for the changes we will make.

*<mark style="background-color:green;">**qb-core/server/player.lua**</mark>*
{% endhint %}

* Find the specified function\ <mark style="background-color:orange;">function QBCore.Player.Login(source, citizenid, newData)</mark>
* Function should be found. <mark style="background-color:orange;">else</mark> part of <mark style="background-color:orange;">if citizenid then</mark> query should be opened
* the function <mark style="background-color:orange;">QBCore.Player.CheckPlayerData(source, newData)</mark> should be made as follows.

```lua
local required = QBCore.Player.CheckPlayerData(source, newData)
TriggerEvent('wais:sendNewCharacterData', required.source, required.cid, required.citizenid)
```

{% hint style="info" %}
After pasting the code above, it should look like below.
{% endhint %}

<pre class="language-lua"><code class="lang-lua">function QBCore.Player.Login(source, citizenid, newData)
    if source and source ~= '' then
        if citizenid then
            local license = QBCore.Functions.GetIdentifier(source, 'license')
            local PlayerData = MySQL.prepare.await('SELECT * FROM players where citizenid = ?', { citizenid })
            if PlayerData and license == PlayerData.license then
                -- THESE PLACES ARE ACTUALLY FULL OF CODES
            else
                -- THESE PLACES ARE ACTUALLY FULL OF CODES
            end
        else
            local required = QBCore.Player.CheckPlayerData(source, newData)
<strong>            TriggerEvent('wais:sendNewCharacterData', required.source, required.cid, required.citizenid)
</strong>        end
        return true
    else
        -- THESE PLACES ARE ACTUALLY FULL OF CODES
        return false
    end
end
</code></pre>

* After this section is made as above, the following path should be followed.
* <mark style="background-color:orange;">function QBCore.Player.CreatePlayer(PlayerData, Offline)</mark> The specified function must be found and go to the last line of this function.
* Then the following codes should be pasted

```lua
return Offline and self or {
        source = PlayerData.source,
        cid = PlayerData.cid,
        citizenid = PlayerData.citizenid
}
```

{% hint style="info" %}
After pasting the code above, it should look like below.

Only the return code content in the last line is important. Pay no attention to other lines of code.
{% endhint %}

```lua
function QBCore.Player.CreatePlayer(PlayerData, Offline)
    local self = {}
    self.Functions = {}
    self.PlayerData = PlayerData
    self.Offline = Offline
    
    -- THESE PLACES ARE ACTUALLY FULL OF CODES
    -- THESE PLACES ARE ACTUALLY FULL OF CODES
    -- THESE PLACES ARE ACTUALLY FULL OF CODES
    
    if self.Offline then
        return self
    else
        QBCore.Players[self.PlayerData.source] = self
        QBCore.Player.Save(self.PlayerData.source)
        TriggerEvent('QBCore:Server:PlayerLoaded', self)
        self.Functions.UpdatePlayerData()
    end
    
    return Offline and self or {
        source = PlayerData.source,
        cid = PlayerData.cid,
        citizenid = PlayerData.citizenid
    }
end
```
