forked from Simnation/Main
Update server.lua
This commit is contained in:
parent
f1922f2eaa
commit
071df6cc88
1 changed files with 28 additions and 2 deletions
|
@ -312,9 +312,35 @@ end)
|
||||||
|
|
||||||
RegisterServerEvent("okokBanking:SetIBAN")
|
RegisterServerEvent("okokBanking:SetIBAN")
|
||||||
AddEventHandler("okokBanking:SetIBAN", function(iban)
|
AddEventHandler("okokBanking:SetIBAN", function(iban)
|
||||||
local xPlayer = QBCore.Functions.GetPlayer(source)
|
local src = source
|
||||||
|
local xPlayer = QBCore.Functions.GetPlayer(src)
|
||||||
|
|
||||||
xPlayer.Functions.ChangeIban(iban)
|
if not xPlayer then
|
||||||
|
print("[okokBanking] Error: Player not found")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not iban or type(iban) ~= "string" then
|
||||||
|
print("[okokBanking] Error: Invalid IBAN provided")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Method 1: Store in charinfo (recommended for QBCore, if IBAN is part of charinfo)
|
||||||
|
if xPlayer.PlayerData.charinfo then
|
||||||
|
xPlayer.PlayerData.charinfo.iban = iban
|
||||||
|
xPlayer.Functions.SetPlayerData('charinfo', xPlayer.PlayerData.charinfo)
|
||||||
|
|
||||||
|
-- Optional: Sync with database (standard QBCore method)
|
||||||
|
exports['qb-database']:update('UPDATE players SET charinfo = ? WHERE citizenid = ?', {
|
||||||
|
json.encode(xPlayer.PlayerData.charinfo),
|
||||||
|
xPlayer.PlayerData.citizenid
|
||||||
|
})
|
||||||
|
else
|
||||||
|
-- Method 2: Fallback to metadata if charinfo isn't available
|
||||||
|
xPlayer.Functions.SetMetaData("iban", iban)
|
||||||
|
end
|
||||||
|
|
||||||
|
print(("[okokBanking] Updated IBAN for %s (%s)"):format(xPlayer.PlayerData.name, iban))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
QBCore.Functions.CreateCallback("okokBanking:HasCreditCard", function(source, cb)
|
QBCore.Functions.CreateCallback("okokBanking:HasCreditCard", function(source, cb)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue