forked from Simnation/Main
Update server.lua
This commit is contained in:
parent
d53a1d5587
commit
a436fe0287
1 changed files with 16 additions and 29 deletions
|
@ -310,43 +310,30 @@ 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 return end
|
||||||
print("[ERROR] Player not found")
|
|
||||||
return
|
-- Update the IBAN in the character info
|
||||||
end
|
local charinfo = Player.PlayerData.charinfo
|
||||||
|
charinfo.iban = iban
|
||||||
-- Validate IBAN input
|
|
||||||
if not iban or type(iban) ~= "string" then
|
-- Save to player data
|
||||||
print("[ERROR] Invalid IBAN format")
|
Player.Functions.SetPlayerData('charinfo', charinfo)
|
||||||
return
|
|
||||||
end
|
-- Update database
|
||||||
|
|
||||||
-- 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 = ?', {
|
MySQL.Async.execute('UPDATE players SET charinfo = ? WHERE citizenid = ?', {
|
||||||
json.encode(xPlayer.PlayerData.charinfo),
|
json.encode(charinfo),
|
||||||
xPlayer.PlayerData.citizenid
|
Player.PlayerData.citizenid
|
||||||
}, 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)
|
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