1
0
Fork 0
forked from Simnation/Main

Update server.lua

This commit is contained in:
Nordi98 2025-06-29 05:37:01 +02:00
parent 7167055241
commit d62e403346

View file

@ -310,30 +310,42 @@ AddEventHandler("okokBanking:CreateSocietyAccount", function(society, society_na
end end
end) end)
-- Server-side IBAN Update (okokBanking)
RegisterServerEvent("okokBanking:SetIBAN") RegisterServerEvent("okokBanking:SetIBAN")
AddEventHandler("okokBanking:SetIBAN", function(iban) AddEventHandler("okokBanking:SetIBAN", function(iban)
local src = source local src = source
local Player = QBCore.Functions.GetPlayer(src) local xPlayer = QBCore.Functions.GetPlayer(src)
if not Player then return end if not xPlayer then
print("[ERROR] Player not found")
return
end
-- Update the IBAN in the character info -- Validate IBAN input
local charinfo = Player.PlayerData.charinfo if not iban or type(iban) ~= "string" then
charinfo.iban = iban print("[ERROR] Invalid IBAN format")
return
end
-- Save to player data -- Update in charinfo (QB standard)
Player.Functions.SetPlayerData('charinfo', charinfo) xPlayer.PlayerData.charinfo = xPlayer.PlayerData.charinfo or {}
xPlayer.PlayerData.charinfo.iban = iban
xPlayer.Functions.SetPlayerData('charinfo', xPlayer.PlayerData.charinfo)
-- Update database -- Sync with database (Works with oxmysql/gmysql)
MySQL.Async.execute('UPDATE players SET charinfo = ? WHERE citizenid = ?', { MySQL.Async.execute('UPDATE players SET charinfo = ? WHERE citizenid = ?', {
json.encode(charinfo), json.encode(xPlayer.PlayerData.charinfo),
Player.PlayerData.citizenid xPlayer.PlayerData.citizenid
}) }, function(rowsChanged)
if rowsChanged > 0 then
-- Aktualisiere die IBAN im Client (DIESE ZEILE HINZUFÜGEN) print("[SUCCESS] Updated IBAN for", xPlayer.PlayerData.name, "to", iban)
TriggerClientEvent('okokBanking:updateIban', src, iban) else
print("[ERROR] Failed to update database")
end
end)
end) end)
QBCore.Functions.CreateCallback("okokBanking:HasCreditCard", function(source, cb) QBCore.Functions.CreateCallback("okokBanking:HasCreditCard", function(source, cb)
local xPlayer = QBCore.Functions.GetPlayer(source) local xPlayer = QBCore.Functions.GetPlayer(source)
if xPlayer ~= nil then if xPlayer ~= nil then