1
0
Fork 0
forked from Simnation/Main

Update server.lua

This commit is contained in:
Nordi98 2025-06-29 05:44:41 +02:00
parent d62e403346
commit d208f85007

View file

@ -310,42 +310,44 @@ 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
print("[ERROR] Player not found")
return
local Player = QBCore.Functions.GetPlayer(src)
if not Player then
print("[okokBanking] Player not found")
return
end
-- Validate IBAN input
if not iban or type(iban) ~= "string" then
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)
-- Sync with database (Works with oxmysql/gmysql)
MySQL.Async.execute('UPDATE players SET charinfo = ? WHERE citizenid = ?', {
json.encode(xPlayer.PlayerData.charinfo),
xPlayer.PlayerData.citizenid
-- Debug-Ausgabe
print("[okokBanking] Setting IBAN for player: " .. Player.PlayerData.citizenid .. " to: " .. iban)
-- Update the IBAN in the character info
local charinfo = Player.PlayerData.charinfo
charinfo.account = iban -- QBCore verwendet normalerweise 'account' für die IBAN
-- Save to player data
Player.Functions.SetPlayerData('charinfo', charinfo)
-- Direkte MySQL-Aktualisierung
MySQL.Async.execute('UPDATE players SET charinfo = @charinfo WHERE citizenid = @citizenid', {
['@charinfo'] = json.encode(charinfo),
['@citizenid'] = Player.PlayerData.citizenid
}, function(rowsChanged)
if rowsChanged > 0 then
print("[SUCCESS] Updated IBAN for", xPlayer.PlayerData.name, "to", iban)
print("[okokBanking] Successfully updated IBAN in database")
-- Aktualisiere die IBAN im Client
TriggerClientEvent('okokBanking:updateIban', src, iban)
else
print("[ERROR] Failed to update database")
print("[okokBanking] Failed to update IBAN in database")
end
end)
end)
QBCore.Functions.CreateCallback("okokBanking:HasCreditCard", function(source, cb)
local xPlayer = QBCore.Functions.GetPlayer(source)
if xPlayer ~= nil then