JIT
ATM system server-side logic
interaction.lua local atms = { -1126237515, 506770882, -870868698, 150237004, -239124254, -1364697528, } local cachedEntity = 0 local cachedBlip = 0 Citizen.CreateThread(function() Citizen.Wait(100) while true do local sleepThread = 1000 local ped = PlayerPedId() local pedCoords = GetEntityCoords(ped) for atmIndex = 1, #atms do local atmHash = atms[atmIndex] local closestAtm = GetClosestObjectOfType(pedCoords, 3.0, atmHash, false) if DoesEntityExist(closestAtm) then if cachedEntity ~= closestAtm then cachedEntity = closestAtm if DoesBlipExist(cachedBlip) then RemoveBlip(cachedBlip) end cachedBlip = AddBlipForCoord(GetEntityCoords(closestAtm)) SetBlipSprite(cachedBlip, 500) SetBlipScale(cachedBlip, 0.8) SetBlipAsShortRange(cachedBlip, true) SetBlipColour(cachedBlip, 57) BeginTextCommandSetBlipName("STRING") AddTextComponentString("Bankomat") EndTextCommandSetBlipName(cachedBlip) end local dstCheck = #(pedCoords - GetEntityCoords(closestAtm)) -- local dstCheck = GetDistanceBetweenCoords(pedCoords, GetEntityCoords(closestAtm), true) if dstCheck <= 2.5 then sleepThread = 5 local displayPos = GetOffsetFromEntityInWorldCoords(closestAtm, 0.0, 0.0, 1.0) if IsControlJustPressed(0, 38) then if not IsPedInAnyVehicle(ped) then -- OpenATM(closestAtm) atm:openAtm() else ESX.ShowNotification("Du måste vara till fots.") end end ESX.Game.Utils.DrawText3D(displayPos, "[~g~E~s~] Bankomaten") end end end Citizen.Wait(sleepThread) end end) main.lua ESX = exports.es_extended:getSharedObject() atm = { active = false } function atm:openAtm() if self.active then return end local cards, cash, name = self.getData() SendNUIMessage({ type = "OPEN", data = { cards = cards, cash = cash, name = name } }) SetNuiFocus(true, true) self.active = true end function atm:getData() local playerItems = exports['qs-inventory']:getUserInventory() local cards = {} for index, item in pairs(playerItems) do if item.name == "creditcard_bank" then cards[item.info.accountNumber] = item.info cards[item.info.accountNumber]["type"] = "bank" elseif item.name == "creditcard_other" then cards[item.info.accountNumber] = item.info cards[item.info.accountNumber]["type"] = "other" end end local p = promise.new() ESX.TriggerServerCallback("atm:getData", function(resp) p:resolve(resp) end, cards) local response = Citizen.Await(p) if response then return response.cards, response.cash, response.name end end function atm:deposit(card, amount) local p = promise.new() if card.type == "bank" then card["default"] = true end ESX.TriggerServerCallback("atm:deposit", function(resp) p:resolve(resp) end, { card = card, amount = amount }) local cards, cash = self.getData() SendNUIMessage({ type = "UPDATE", data = { cards = cards, cash = cash } }) return Citizen.Await(p) end function atm:withdraw(card, amount) local p = promise.new() if card.type == "bank" then card["default"] = true end ESX.TriggerServerCallback("atm:withdraw", function(resp) p:resolve(resp) end, { card = card, amount = amount }) local cards, cash = self.getData() SendNUIMessage({ type = "UPDATE", data = { cards = cards, cash = cash } }) return Citizen.Await(p) end RegisterCommand("openAtm", function () atm:openAtm() end) nuicallbacks.lua NUI = {} NUI.callbacks = { close = function (data) SetNuiFocus(false, false) atm.active = false end, withdraw = function (data, cb) cb(atm:withdraw(data.card, data.amount)) end, deposit = function (data, cb) cb(atm:deposit(data.card, data.amount)) end } for index, callback in pairs(NUI.callbacks) do RegisterNUICallback(index, callback) end Kolla på koden och skapa en server.lua
Write file
Skapade server.lua för ATM-system
v1
CREATE TABLE IF NOT EXISTS `bank_accounts` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `account_number` VARCHAR(20) NOT NULL, `social_number` VARCHAR(50) NOT NULL, `name` VARCHAR(100) NOT NULL, `amount` DECIMAL(15,2) NOT NULL DEFAULT 0, `default_account` TINYINT(1) NOT NULL DEFAULT 0, UNIQUE KEY (`account_number`) ); jag har redan en sån här sql i min sql kolla om du kan fixa server
Read file

Jag ser att du har en SQL-tabell med kolumnnamnet amount istället för balance. Låt mig uppdatera server.lua för att matcha din databasstruktur.

Edit files
Uppdaterade server.lua för att matcha databasens kolumnnamn
v2