You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update player deletion code in server/player.lua to accommodate tables that do not use the column name citizenid
Many scripts use other column names to store the citizenid but contain data that should be deleted upon character deletion. This leads to excess data build up in the database that is no longer needed and currently requires manual effort to clean out the database.
Ideal solution
Sample code below for your review:
New format for playertables:
Starting @ line 532:
local playertables = { -- Add tables as needed
---
--- 'table' is the SQL table name
--- 'key' is the column name which contains the 'citizenid'
---
--Tables where primary key = 'citizenid'
{ table = 'players', key = 'citizenid' },
{ table = 'apartments', key = 'citizenid' },
...
{ table = 'player_contacts', key = 'identifier' },
{ table = 'bank_cards', key = 'identifier' },
{ table = 'bank_history', key = 'identifier' },
...
{ table = 'bank_process', key = 'owner' },
{ table = 'mail_accounts', key = 'owner' },
{ table = 'lation_chopshop', key = 'player_identifier' },
Edits to the SQL calls for DeleteCharacter (and similar change for ForceDeleteCharacter):
starting @ line 547:
function QBCore.Player.DeleteCharacter(source, citizenid)
local license = QBCore.Functions.GetIdentifier(source, 'license')
local result = MySQL.scalar.await('SELECT license FROM players where citizenid = ?', { citizenid })
if license == result then
-- old call
-- local query = 'DELETE FROM %s WHERE citizenid = ?'
local query = 'DELETE FROM %s WHERE %s = ?' -- updated query
local tableCount = #playertables
local queries = table.create(tableCount, 0)
for i = 1, tableCount do
local v = playertables[i]
-- old call
-- queries[i] = { query = query:format(v.table), values = { citizenid } }
queries[i] = { query = query:format(v.table, v.key), values = { citizenid } } -- updated query
end
Alternative solutions
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
The problem
Update player deletion code in
server/player.lua
to accommodate tables that do not use the column namecitizenid
Many scripts use other column names to store the
citizenid
but contain data that should be deleted upon character deletion. This leads to excess data build up in the database that is no longer needed and currently requires manual effort to clean out the database.Ideal solution
Sample code below for your review:
New format for
playertables
:Starting @ line 532:
Edits to the SQL calls for
DeleteCharacter
(and similar change forForceDeleteCharacter
):starting @ line 547:
Alternative solutions
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: