1
0
Fork 0
forked from Simnation/Main

Update server.lua

This commit is contained in:
Nordi98 2025-06-29 05:16:21 +02:00
parent caf94ba42f
commit d53a1d5587

View file

@ -310,38 +310,43 @@ AddEventHandler("okokBanking:CreateSocietyAccount", function(society, society_na
end
end)
-- Server-side IBAN Update (okokBanking)
RegisterServerEvent("okokBanking:SetIBAN")
AddEventHandler("okokBanking:SetIBAN", function(iban)
local src = source
local xPlayer = QBCore.Functions.GetPlayer(src)
if not xPlayer then return end -- Validate player
if not xPlayer then
print("[ERROR] Player not found")
return
end
-- Check if IBAN is valid
-- Validate IBAN input
if not iban or type(iban) ~= "string" then
print("[okokBanking] ERROR: Invalid IBAN provided")
return
end
-- Update IBAN in charinfo (QBCore standard)
if not xPlayer.PlayerData.charinfo then
print("[okokBanking] ERROR: Player charinfo missing")
print("[ERROR] Invalid IBAN format")
return
end
-- Update in charinfo (QB standard)
xPlayer.PlayerData.charinfo = xPlayer.PlayerData.charinfo or {}
xPlayer.PlayerData.charinfo.iban = iban
xPlayer.Functions.SetPlayerData('charinfo', xPlayer.PlayerData.charinfo)
-- Proper QBCore database update method
-- Sync with database (Works with oxmysql/gmysql)
MySQL.Async.execute('UPDATE players SET charinfo = ? WHERE citizenid = ?', {
json.encode(xPlayer.PlayerData.charinfo),
xPlayer.PlayerData.citizenid
})
print("[okokBanking] Updated IBAN for", xPlayer.PlayerData.name, "New IBAN:", iban)
}, function(rowsChanged)
if rowsChanged > 0 then
print("[SUCCESS] Updated IBAN for", xPlayer.PlayerData.name, "to", iban)
else
print("[ERROR] Failed to update database")
end
end)
end)
QBCore.Functions.CreateCallback("okokBanking:HasCreditCard", function(source, cb)
local xPlayer = QBCore.Functions.GetPlayer(source)
if xPlayer ~= nil then