forked from Simnation/Main
167 lines
No EOL
6.5 KiB
Lua
167 lines
No EOL
6.5 KiB
Lua
teddy = nil
|
||
lastUsed = 0
|
||
isBusy = false
|
||
stretcher = nil
|
||
QBCore = exports['qb-core']:GetCoreObject()
|
||
|
||
CreateThread(function()
|
||
while true do
|
||
Wait(0)
|
||
local pos = Config.KlingelPosition
|
||
local ply = PlayerPedId()
|
||
local coords = GetEntityCoords(ply)
|
||
|
||
if #(coords - pos) < 2.0 and not isBusy then
|
||
--show3DText(pos, "[E] Hilfe anfordern")
|
||
DrawText3D(pos.x, pos.y, pos.z, "[E] Hilfe anfordern")
|
||
if IsControlJustPressed(0, 38) then
|
||
QBCore.Functions.TriggerCallback('drteddy:ceckJob', function(cb)
|
||
if not cb then
|
||
TriggerServerEvent("drteddy:requestDoctor")
|
||
else
|
||
Notify("Dr. Teddy", "Dr. Teddy ist grade nicht im Dienst, ruf den Notdienst", "inform")
|
||
end
|
||
end)
|
||
end
|
||
end
|
||
end
|
||
end)
|
||
|
||
RegisterNetEvent('drteddy:despawn', function()
|
||
if DoesEntityExist(teddy) then
|
||
DeletePed(teddy)
|
||
teddy = nil
|
||
isBusy = false
|
||
end
|
||
end)
|
||
|
||
RegisterCommand('delmedic', function()
|
||
local playerPed = PlayerPedId()
|
||
DetachEntity(playerPed, true, true)
|
||
SetEntityCollision(playerPed, true, true)
|
||
FreezeEntityPosition(playerPed, false)
|
||
ClearPedTasks(playerPed)
|
||
EnableAllControlActions(0)
|
||
DoScreenFadeIn(1000)
|
||
SetEntityHealth(playerPed, 100)
|
||
TriggerServerEvent('drteddy:delallmedics')
|
||
end, false)
|
||
|
||
RegisterNetEvent("drteddy:startDoctor")
|
||
AddEventHandler("drteddy:startDoctor", function()
|
||
if isBusy then return end
|
||
isBusy = true
|
||
|
||
Notify("Klingel betätigt", "Dr. Teddy ist auf dem Weg!", "info")
|
||
TriggerServerEvent('drteddy:log', "call")
|
||
teddy = spawnDoctor(Config.PathToBell[1], Config.PathToBell[1].w)
|
||
walkPath(teddy, Config.PathToBell, function()
|
||
lib.registerContext({
|
||
id = 'teddy_behandlung',
|
||
title = 'Dr. Teddy – Behandlung',
|
||
options = {
|
||
{
|
||
title = '✅ Ja, bitte behandeln',
|
||
description = 'Du wirst medizinisch versorgt.',
|
||
icon = 'heart-pulse',
|
||
onSelect = function()
|
||
QBCore.Functions.TriggerCallback('drteddy:checkMoney', function(cb)
|
||
if cb.status then
|
||
if type == 'cash' then
|
||
Notify("Dr. Teddy", "Du hast "..Config.TreatmentPrice.."$ gegeben.", "success")
|
||
TriggerServerEvent('drteddy:log', "cash")
|
||
elseif type == 'bank' then
|
||
Notify("Dr. Teddy", "Du hast "..Config.TreatmentPrice.."$ überwiesen.", "success")
|
||
TriggerServerEvent('drteddy:log', "bank")
|
||
end
|
||
Wait(500)
|
||
Notify("Dr. Teddy", "Bitte folgen Sie mir in den Behandlungsraum.", "inform")
|
||
walkPath(teddy, Config.PathToTreatment, function()
|
||
CheckPlayerArrivalAt(Config.PathToTreatment[#Config.PathToTreatment])
|
||
end)
|
||
else
|
||
if cb.type == 'noMoney' then
|
||
Notify("Dr. Teddy", "Du hast nicht genug Geld dabei oder auf deiner Bank!", "error")
|
||
TriggerServerEvent('drteddy:log', "noMoney")
|
||
elseif cb.type == 'noPlayer' then
|
||
Notify("Dr. Teddy", "Es gab ein Fehler, komme bitte später wieder...", "error")
|
||
TriggerServerEvent('drteddy:log', "noPlayer")
|
||
end
|
||
local newPath = reversePath(Config.PathToBell)
|
||
walkPath(teddy, newPath, function()
|
||
TriggerServerEvent('drteddy:delallmedics')
|
||
end)
|
||
end
|
||
end)
|
||
end
|
||
},
|
||
{
|
||
title = '❌ Nein, abbrechen',
|
||
description = 'Du lehnst die Behandlung ab.',
|
||
icon = 'heart-pulse',
|
||
onSelect = function()
|
||
Notify("Dr. Teddy", "Du hast die Behandlung abgelehnt.", "error")
|
||
local newPath = reversePath(Config.PathToBell)
|
||
walkPath(teddy, newPath, function()
|
||
TriggerServerEvent('drteddy:log', "storno")
|
||
TriggerServerEvent('drteddy:delallmedics')
|
||
end)
|
||
end
|
||
}
|
||
}
|
||
})
|
||
|
||
lib.showContext('teddy_behandlung')
|
||
end)
|
||
end)
|
||
|
||
function CheckPlayerArrivalAt(targetPos)
|
||
CreateThread(function()
|
||
local player = PlayerPedId()
|
||
while true do
|
||
Wait(500)
|
||
local dist = #(GetEntityCoords(player) - vector3(targetPos.x, targetPos.y, targetPos.z))
|
||
if dist < 2.0 then
|
||
DisableAllControlActions(0)
|
||
SetEntityCoords(player, 1121.6, -1553.79, 36.09, false, false, false, true)
|
||
SetEntityHeading(player, 178.72)
|
||
StartTreatmentSequence(player)
|
||
break
|
||
end
|
||
end
|
||
end)
|
||
end
|
||
|
||
function StartTreatmentSequence(playerPed)
|
||
-- NPC animation
|
||
local dict, anim = "amb@medic@standing@tendtodead@idle_a", "idle_a"
|
||
RequestAnimDict(dict)
|
||
while not HasAnimDictLoaded(dict) do Wait(100) end
|
||
TaskPlayAnim(teddy, dict, anim, 8.0, -8.0, 5000, 1, 0, false, false, false)
|
||
|
||
-- Bildschirm dunkel
|
||
DoScreenFadeOut(1000)
|
||
Wait(1500)
|
||
|
||
-- Spieler vollständig heilen
|
||
HealPlayerWithARE(playerPed)
|
||
TriggerServerEvent('drteddy:log', "heal")
|
||
|
||
-- Warte und bringe Bildschirm zurück
|
||
Wait(5000)
|
||
|
||
-- Spieler an Koordinate setzen
|
||
SetEntityCoords(playerPed, 1121.6, -1553.79, 36.09)
|
||
SetEntityHeading(playerPed, 178.72)
|
||
EnableAllControlActions(0)
|
||
DoScreenFadeIn(1000)
|
||
|
||
ClearPedTasks(teddy)
|
||
|
||
-- NPC zurückschicken
|
||
walkPath(teddy, reversePath(Config.PathToTreatment), function()
|
||
walkPath(teddy, reversePath(Config.PathToBell), function()
|
||
TriggerServerEvent('drteddy:delallmedics')
|
||
end)
|
||
end)
|
||
end |