local pluginData = { name = "test_plugin", description = "test plugin", author = "test", version = "1.1" } RegisterServerPlugin(pluginData, function(print) print("NPC Heal Server lua Loaded") end) local QBCore = exports['qb-core']:GetCoreObject() local price = 5000 --Preis zum Healen muss gleich sein wie Preis in plugin_npcheal_client.lua Zeile 30 QBCore.Functions.CreateCallback('visn_are:docOnline', function(source, cb) local Ply = QBCore.Functions.GetPlayer(source) local doctor = 0 local canpay = false if Ply.PlayerData.money["cash"] >= price then canpay = true elseif Ply.PlayerData.money["bank"] >= price then canpay = true end local doctor = GetMedicsOnDutyCount() print("Server callback: doctor = " .. doctor .. ", canpay = " .. tostring(canpay)) cb(doctor, canpay) end) RegisterNetEvent('visn_are:charge') AddEventHandler('visn_are:charge', function() local src = source local xPlayer = QBCore.Functions.GetPlayer(src) if xPlayer.PlayerData.money["cash"] >= price then xPlayer.Functions.RemoveMoney('cash', price) else xPlayer.Functions.RemoveMoney('bank', price) end TriggerEvent('qb-bossmenu:server:addAccountMoney', 'ambulance', price) end) function GetMedicsOnDutyCount() -- Beispiel: Zähle die Anzahl der Medics im Dienst local count = 0 -- Durchlaufe alle Spieler und zähle die Medics for _, player in pairs(QBCore.Functions.GetPlayers()) do local xPlayer = QBCore.Functions.GetPlayer(player) if xPlayer.PlayerData.job.name == 'ambulance' and xPlayer.PlayerData.job.onduty then count = count + 1 end end return count end