fix
This commit is contained in:
		
							parent
							
								
									071df6cc88
								
							
						
					
					
						commit
						caf94ba42f
					
				
					 2 changed files with 40 additions and 41 deletions
				
			
		|  | @ -315,34 +315,33 @@ AddEventHandler("okokBanking:SetIBAN", function(iban) | |||
|     local src = source | ||||
|     local xPlayer = QBCore.Functions.GetPlayer(src) | ||||
|  | ||||
|     if not xPlayer then  | ||||
|         print("[okokBanking] Error: Player not found") | ||||
|         return  | ||||
|     end | ||||
|     if not xPlayer then return end -- Validate player | ||||
|  | ||||
|     -- Check if IBAN is valid | ||||
|     if not iban or type(iban) ~= "string" then | ||||
|         print("[okokBanking] Error: Invalid IBAN provided") | ||||
|         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) | ||||
|     -- Update IBAN in charinfo (QBCore standard) | ||||
|     if not xPlayer.PlayerData.charinfo then | ||||
|         print("[okokBanking] ERROR: Player charinfo missing") | ||||
|         return | ||||
|     end | ||||
|  | ||||
|     print(("[okokBanking] Updated IBAN for %s (%s)"):format(xPlayer.PlayerData.name, iban)) | ||||
|     xPlayer.PlayerData.charinfo.iban = iban | ||||
|     xPlayer.Functions.SetPlayerData('charinfo', xPlayer.PlayerData.charinfo) | ||||
|  | ||||
|     -- Proper QBCore database update method | ||||
|     MySQL.Async.execute('UPDATE players SET charinfo = ? WHERE citizenid = ?', { | ||||
|         json.encode(xPlayer.PlayerData.charinfo), | ||||
|         xPlayer.PlayerData.citizenid | ||||
|     }) | ||||
|  | ||||
|     print("[okokBanking] Updated IBAN for", xPlayer.PlayerData.name, "New IBAN:", iban) | ||||
| end) | ||||
|  | ||||
|  | ||||
| QBCore.Functions.CreateCallback("okokBanking:HasCreditCard", function(source, cb) | ||||
| 	local xPlayer = QBCore.Functions.GetPlayer(source) | ||||
| 	if xPlayer ~= nil then | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nordi98
						Nordi98