forked from Simnation/Main
test
This commit is contained in:
parent
2dfaf23b8e
commit
311fa02747
2 changed files with 0 additions and 214 deletions
|
@ -1,159 +0,0 @@
|
|||
local pluginData = {
|
||||
name = "test_plugin",
|
||||
description = "NPC Heal",
|
||||
author = "test",
|
||||
version = "1.2"
|
||||
}
|
||||
|
||||
RegisterClientPlugin(pluginData, function(print)
|
||||
print("plugin_npcheal_client.lua loaded")
|
||||
end)
|
||||
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
local NPCPosition = {x = 349.18676, y = -577.2429, z = 28.822866, rot = 250.00}
|
||||
|
||||
local isNearPed = false
|
||||
local isAtPed = false
|
||||
local isPedLoaded = false
|
||||
local pedModel = GetHashKey("s_m_m_doctor_01")
|
||||
local npc
|
||||
local reviveTime = 15000
|
||||
local doctor = 0
|
||||
local price = 5000
|
||||
local isBusy = false
|
||||
local isBeingTreated = false
|
||||
|
||||
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
local playerPed = PlayerPedId()
|
||||
local playerCoords = GetEntityCoords(playerPed)
|
||||
local distance = Vdist(playerCoords, NPCPosition.x, NPCPosition.y, NPCPosition.z)
|
||||
|
||||
isNearPed = distance < 20.0
|
||||
isAtPed = distance < 2.0
|
||||
|
||||
if isNearPed and not isPedLoaded then
|
||||
RequestModel(pedModel)
|
||||
while not HasModelLoaded(pedModel) do
|
||||
Wait(10)
|
||||
end
|
||||
|
||||
npc = CreatePed(4, pedModel, NPCPosition.x, NPCPosition.y, NPCPosition.z - 1.0, NPCPosition.rot, false, false)
|
||||
FreezeEntityPosition(npc, true)
|
||||
SetEntityHeading(npc, NPCPosition.rot)
|
||||
SetEntityInvincible(npc, true)
|
||||
SetBlockingOfNonTemporaryEvents(npc, true)
|
||||
|
||||
isPedLoaded = true
|
||||
elseif not isNearPed and isPedLoaded then
|
||||
DeleteEntity(npc)
|
||||
isPedLoaded = false
|
||||
end
|
||||
|
||||
Citizen.Wait(500)
|
||||
end
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
if isNearPed and isAtPed then
|
||||
showInfobar('Drücke ~g~E~s~, um für ' .. price ..' $ eine Behandlung zu erhalten')
|
||||
if IsControlJustReleased(0, 38) then
|
||||
if not isBusy then
|
||||
isBusy = true
|
||||
isBeingTreated = true
|
||||
TriggerEvent("disableMovementControls", true)
|
||||
|
||||
local playerHealth = GetEntityHealth(PlayerPedId())
|
||||
if playerHealth < 200 then
|
||||
QBCore.Functions.TriggerCallback('visn_are:docOnline', function(medicOn, hasEnoughMoney)
|
||||
if medicOn <= doctor and hasEnoughMoney then
|
||||
QBCore.Functions.Progressbar("Notarzt", "Der Notarzt behandelt dich", reviveTime, false, true, {
|
||||
disableMovement = true,
|
||||
disableCarMovement = true,
|
||||
disableMouse = true,
|
||||
disableCombat = true,
|
||||
}, {}, {}, {}, function() -- Progress Callback
|
||||
TriggerServerEvent('visn_are:charge')
|
||||
TriggerEvent("visn_are:resetHealthBuffer")
|
||||
SetEntityHealth(PlayerPedId(), 200)
|
||||
ShowNotification('Du bezahlst ' .. price ..' $ für die Behandlung')
|
||||
ShowNotification("Du bist gesund")
|
||||
isBusy = false
|
||||
isBeingTreated = false
|
||||
TriggerEvent("disableMovementControls", false)
|
||||
end, function() -- Cancel Callback
|
||||
ShowNotification("Behandlung abgebrochen")
|
||||
isBusy = false
|
||||
isBeingTreated = false
|
||||
TriggerEvent("disableMovementControls", false)
|
||||
end)
|
||||
elseif medicOn > doctor then
|
||||
ShowNotification("Zuviele Medics im Dienst, rufe einen!")
|
||||
isBusy = false
|
||||
isBeingTreated = false
|
||||
TriggerEvent("disableMovementControls", false)
|
||||
elseif not hasEnoughMoney then
|
||||
ShowNotification("Du hast nicht genug Geld für die Behandlung")
|
||||
isBusy = false
|
||||
isBeingTreated = false
|
||||
TriggerEvent("disableMovementControls", false)
|
||||
end
|
||||
end)
|
||||
else
|
||||
ShowNotification("Du bist bereits gesund")
|
||||
isBusy = false
|
||||
isBeingTreated = false
|
||||
TriggerEvent("disableMovementControls", false)
|
||||
end
|
||||
else
|
||||
ShowNotification("Du wirst schon behandelt")
|
||||
end
|
||||
end
|
||||
end
|
||||
Citizen.Wait(1)
|
||||
end
|
||||
end)
|
||||
|
||||
function ShowNotification(text)
|
||||
SetNotificationTextEntry('STRING')
|
||||
AddTextComponentString(text)
|
||||
DrawNotification(false, true)
|
||||
end
|
||||
|
||||
function showInfobar(msg)
|
||||
SetTextComponentFormat('STRING')
|
||||
AddTextComponentString(msg)
|
||||
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
|
||||
end
|
||||
|
||||
RegisterNetEvent("disableMovementControls")
|
||||
AddEventHandler("disableMovementControls", function(disable)
|
||||
local playerPed = PlayerPedId()
|
||||
if disable then
|
||||
SetPedCurrentWeaponVisible(playerPed, false, true, true, true)
|
||||
SetPlayerControl(playerPed, false, 0)
|
||||
else
|
||||
SetPedCurrentWeaponVisible(playerPed, true, true, true, true)
|
||||
SetPlayerControl(playerPed, true, 0)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue