Main/resources/[Developer]/[Mark]/plugin_npcheal/plugin_npcheal_server.lua
2025-06-07 08:51:21 +02:00

46 lines
No EOL
1.1 KiB
Lua

local pluginData = {
name = "test_plugin",
description = "test plugin",
author = "test",
version = "1.1"
}
RegisterServerPlugin(pluginData, function(print)
print("NPC Heal Server lua Loaded")
end)
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
local price = 2000 --Preis zum Healen muss gleich sein wie Preis in plugin_npcheal_client.lua Zeile 30
ESX.RegisterServerCallback('visn_are:docOnline' , function(source, cb)
local Ply = ESX.GetPlayerFromId(source)
local doctor = 0
local canpay = false
if Ply.getMoney() >= price then
canpay = true
else
if Ply.getAccount('bank').money >= price then
canpay = true
end
end
local doctor = GetMedicsOnDutyCount()
cb(doctor, canpay)
end)
RegisterServerEvent('visn_are:charge')
AddEventHandler('visn_are:charge', function()
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.getMoney()>= price then
xPlayer.removeMoney(price)
else
xPlayer.removeAccountMoney('bank', price)
end
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_ambulance', function(sharedAccount)
sharedAccount.addMoney(price)
end)
end)