forked from Simnation/Main
Update server.lua
This commit is contained in:
parent
d62e403346
commit
d208f85007
1 changed files with 26 additions and 24 deletions
|
@ -310,42 +310,44 @@ 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 xPlayer = QBCore.Functions.GetPlayer(src)
|
local Player = QBCore.Functions.GetPlayer(src)
|
||||||
|
|
||||||
if not xPlayer then
|
if not Player then
|
||||||
print("[ERROR] Player not found")
|
print("[okokBanking] Player not found")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Validate IBAN input
|
-- Debug-Ausgabe
|
||||||
if not iban or type(iban) ~= "string" then
|
print("[okokBanking] Setting IBAN for player: " .. Player.PlayerData.citizenid .. " to: " .. iban)
|
||||||
print("[ERROR] Invalid IBAN format")
|
|
||||||
return
|
-- Update the IBAN in the character info
|
||||||
end
|
local charinfo = Player.PlayerData.charinfo
|
||||||
|
charinfo.account = iban -- QBCore verwendet normalerweise 'account' für die IBAN
|
||||||
-- Update in charinfo (QB standard)
|
|
||||||
xPlayer.PlayerData.charinfo = xPlayer.PlayerData.charinfo or {}
|
-- Save to player data
|
||||||
xPlayer.PlayerData.charinfo.iban = iban
|
Player.Functions.SetPlayerData('charinfo', charinfo)
|
||||||
xPlayer.Functions.SetPlayerData('charinfo', xPlayer.PlayerData.charinfo)
|
|
||||||
|
-- Direkte MySQL-Aktualisierung
|
||||||
-- Sync with database (Works with oxmysql/gmysql)
|
MySQL.Async.execute('UPDATE players SET charinfo = @charinfo WHERE citizenid = @citizenid', {
|
||||||
MySQL.Async.execute('UPDATE players SET charinfo = ? WHERE citizenid = ?', {
|
['@charinfo'] = json.encode(charinfo),
|
||||||
json.encode(xPlayer.PlayerData.charinfo),
|
['@citizenid'] = Player.PlayerData.citizenid
|
||||||
xPlayer.PlayerData.citizenid
|
|
||||||
}, function(rowsChanged)
|
}, function(rowsChanged)
|
||||||
if rowsChanged > 0 then
|
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
|
else
|
||||||
print("[ERROR] Failed to update database")
|
print("[okokBanking] Failed to update IBAN in database")
|
||||||
end
|
end
|
||||||
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue