> For the complete documentation index, see [llms.txt](https://shx-store.gitbook.io/shxstore/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://shx-store.gitbook.io/shxstore/~/changes/sWltUEee2euonRDw7ATu/scripts/shx-sid-static-id/installation.md).

# Installation

## qb-core

You have to go here and find this. qb-core/server/player.lua find `QBCore.Player.Save(source)` and change :

{% code title="qb-core/server/player.lua" %}

```lua
function QBCore.Player.Save(source)
	local src = source
	local ped = GetPlayerPed(src)
    local pcoords = GetEntityCoords(ped)
    local PlayerData = QBCore.Players[src].PlayerData
	if PlayerData ~= nil then
		local result = exports.oxmysql:executeSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = PlayerData.citizenid})
		if result[1] == nil then
			exports.oxmysql:execute('INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata) VALUES (:citizenid, :cid, :license, :name, :money, :charinfo, :job, :gang, :position, :metadata, :discordID) ON DUPLICATE KEY UPDATE cid = :cid, name = :name, money = :money, charinfo = :charinfo, job = :job, gang = :gang, position = :position, metadata = :metadata', {
				citizenid = PlayerData.citizenid,
				cid = tonumber(PlayerData.cid),
				license = PlayerData.license,
				name = PlayerData.name,
				money = json.encode(PlayerData.money),
				charinfo = json.encode(PlayerData.charinfo),
				job = json.encode(PlayerData.job),
				gang = json.encode(PlayerData.gang),
				position = json.encode(pcoords),
				metadata = json.encode(PlayerData.metadata),
			})
		else
			exports.oxmysql:execute('UPDATE players SET license = @license, name = @name, money = @money, charinfo = @charinfo, job = @job, gang = @gang, position = @position, metadata = @metadata WHERE citizenid = @citizenid', {
				['@citizenid'] = PlayerData.citizenid,
				['@license'] = PlayerData.license,
				['@name'] = PlayerData.name,
				['@money'] = json.encode(PlayerData.money),
				['@charinfo'] = json.encode(PlayerData.charinfo),
				['@job'] = json.encode(PlayerData.job),
				['@gang'] = json.encode(PlayerData.gang),
				['@position'] = json.encode(pcoords),
				['@metadata'] = json.encode(PlayerData.metadata),
			})
		end
		-- QBCore.Player.SaveInventory(src)
        	exports['qb-inventory']:SaveInventory(src)
		QBCore.ShowSuccess(GetCurrentResourceName(), 'NEW PLAYER '..PlayerData.name ..' SAVED!')
	else
		QBCore.ShowError(GetCurrentResourceName(), 'ERROR QBCORE.PLAYER.SAVE - PLAYERDATA IS EMPTY!')
	end
end

```

{% endcode %}

**After change:** You have to go here and find this. qb-core/server/player.lua find `QBCore.Player.SaveOffline(source)`

{% code title="qb-core/server/player.lua" %}

```lua
function QBCore.Player.SaveOffline(source)
	if PlayerData then
        local ped = GetPlayerPed(source)
        local pcoords = GetEntityCoords(ped)
		local result = exports.oxmysql:executeSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = PlayerData.citizenid})
		if result[1] == nil then
			exports.oxmysql:execute('INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata, discordID) VALUES (:citizenid, :cid, :license, :name, :money, :charinfo, :job, :gang, :position, :metadata) ON DUPLICATE KEY UPDATE cid = :cid, name = :name, money = :money, charinfo = :charinfo, job = :job, gang = :gang, position = :position, metadata = :metadata', {
				citizenid = PlayerData.citizenid,
				cid = tonumber(PlayerData.cid),
				license = PlayerData.license,
				name = PlayerData.name,
				money = json.encode(PlayerData.money),
				charinfo = json.encode(PlayerData.charinfo),
				job = json.encode(PlayerData.job),
				gang = json.encode(PlayerData.gang),
				position = json.encode(pcoords),
				metadata = json.encode(PlayerData.metadata),
			})
		else
			exports.oxmysql:execute('UPDATE players SET license = @license, name = @name, money = @money, charinfo = @charinfo, job = @job, gang = @gang, position = @position, metadata = @metadata WHERE citizenid = @citizenid', {
				['@citizenid'] = PlayerData.citizenid,
				['@license'] = PlayerData.license,
				['@name'] = PlayerData.name,
				['@money'] = json.encode(PlayerData.money),
				['@charinfo'] = json.encode(PlayerData.charinfo),
				['@job'] = json.encode(PlayerData.job),
				['@gang'] = json.encode(PlayerData.gang),
				['@position'] = json.encode(PlayerData.position),
				['@metadata'] = json.encode(PlayerData.metadata),
			})
		end
		-- QBCore.Player.SaveInventory(src)
        	exports['qb-inventory']:SaveInventory(PlayerData, true)
		QBCore.ShowSuccess(GetCurrentResourceName(), 'NEW PLAYER '..PlayerData.name ..' SAVED!')
	else
		QBCore.ShowError(GetCurrentResourceName(), 'ERROR QBCORE.PLAYER.SAVE - PLAYERDATA IS EMPTY!')
	end
end
```

{% endcode %}

## **qbx-core**

You have to go here and find this. qbx-core/server/storage.lua find `UpsertPlayerEntity(request)`and change :

{% code title="qbx-core/server/storage.lua" %}

```lua
function UpsertPlayerEntity(request)
    local src = source
    local result = exports.oxmysql:executeSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = request.playerEntity.citizenid})
    if result[1] == nil then
        MySQL.query.await('INSERT INTO players (citizenid, license, name, money, charinfo, job, gang, position, metadata) VALUES (:citizenid, :license, :name, :money, :charinfo, :job, :gang, :position, :metadata) ON DUPLICATE KEY UPDATE name = :name, money = :money, charinfo = :charinfo, job = :job, gang = :gang, position = :position, metadata = :metadata', {
            citizenid = request.playerEntity.citizenid,
            license = request.playerEntity.license,
            name = request.playerEntity.name,
            money = json.encode(request.playerEntity.money),
            charinfo = json.encode(request.playerEntity.charinfo),
            job = json.encode(request.playerEntity.job),
            gang = json.encode(request.playerEntity.gang),
            position = json.encode(request.position),
            metadata = json.encode(request.playerEntity.metadata)
        })
    else
        exports.oxmysql:execute('UPDATE players SET license = @license, name = @name, money = @money, charinfo = @charinfo, job = @job, gang = @gang, position = @position, metadata = @metadata WHERE citizenid = @citizenid', {
            ['@citizenid'] = request.playerEntity.citizenid,
            ['@license'] = request.playerEntity.license,
            ['@name'] = request.playerEntity.name,
            ['@money'] = json.encode(request.playerEntity.money),
            ['@charinfo'] = json.encode(request.playerEntity.charinfo),
            ['@job'] = json.encode(request.playerEntity.job),
            ['@gang'] = json.encode(request.playerEntity.gang),
            ['@position'] = json.encode(request.position),
            ['@metadata'] = json.encode(request.playerEntity.metadata),
        })
    end
end
```

{% endcode %}
