forked from Simnation/Main
123 lines
3.1 KiB
Lua
123 lines
3.1 KiB
Lua
|
|
local pluginData = {
|
|
name = "test_plugin",
|
|
description = "NPC Heal",
|
|
author = "test",
|
|
version = "1.2"
|
|
}
|
|
|
|
RegisterClientPlugin(pluginData, function(print)
|
|
print("plugin_npcheal_client.lua loaded")
|
|
end)
|
|
ESX = nil
|
|
Citizen.CreateThread(function()
|
|
while ESX == nil do
|
|
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
|
Citizen.Wait(0)
|
|
end
|
|
end)
|
|
|
|
local NPCPosition = {x = 307.19, y = -584.26, z= 43.28 , rot = 88.88 }
|
|
|
|
local isNearPed = false
|
|
local isAtPed = false
|
|
local isPedLoaded = false
|
|
local pedModel = GetHashKey("s_m_m_doctor_01")
|
|
local npc
|
|
local reviveTime = 15000 --in MS Wie lange braucht der NPC zum Wiederbeleben (für Progressbar)
|
|
local doctor = 0 --Wieviele Medics Dürfen maximal online sein um NPC Doctor zu benutzen
|
|
|
|
local price = 2000 --muss gleich sein wie in plugin_npcheal_server.lua Zeile 14
|
|
Citizen.CreateThread(function()
|
|
while true do
|
|
|
|
local playerPed = PlayerPedId()
|
|
local playerCoords = GetEntityCoords(playerPed)
|
|
local distance = Vdist(playerCoords,NPCPosition.x,NPCPosition.y,NPCPosition.z)
|
|
isNearPed = false
|
|
isAtPed = false
|
|
|
|
if distance < 20.0 then
|
|
isNearPed = true
|
|
if 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
|
|
|
|
end
|
|
end
|
|
|
|
if distance < 2.0 then
|
|
isAtPed = true
|
|
end
|
|
Citizen.Wait(500)
|
|
end
|
|
end)
|
|
|
|
|
|
Citizen.CreateThread(function()
|
|
while true do
|
|
if 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
|
|
ESX.TriggerServerCallback('visn_are:docOnline', function(medicOn, hasEnoughMoney)
|
|
if medicOn <= doctor and hasEnoughMoney then
|
|
exports['progressBars']:startUI(reviveTime, "Der Notarzt behandelt dich") --Lösche oder ändere auf deine Progressbar
|
|
Wait(reviveTime) --Für Progressbar, falls kein Progressbar erwünscht lösche auch diese zeile
|
|
TriggerServerEvent('visn_are:charge')
|
|
TriggerEvent("visn_are:resetHealthBuffer")
|
|
SetEntityHealth(GetPlayerPed(-1), 200)
|
|
ShowNotification('Du Bezahlst ' .. price ..' $ für die behandlung')
|
|
isBusy = false
|
|
elseif medicOn > doctor then
|
|
ShowNotification("Zuviele Medics im Dienst, rufe einen!")
|
|
isBusy = false
|
|
elseif not hasEnoughMoney then
|
|
ShowNotification("Du hast nicht genug Geld für die Behandlung")
|
|
isBusy = false
|
|
end
|
|
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)
|
|
|
|
CurrentActionMsg = msg
|
|
SetTextComponentFormat('STRING')
|
|
AddTextComponentString(CurrentActionMsg)
|
|
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|