-- [[Register Plugin Data]] local pluginData = { name = "Official NPC Revive Plugin", description = "This plugin allows you to call an NPC with a command to revive you.", author = "Simsonfanatiker", version = "1.0.0 [29.03.2023]" } -- Information: I have currently decided not to query whether medics are online or not. But this may come soon ------------------------------------------------------------------------------- --[[ Config Options ]] local command = "npcrevive" local modelname = "s_m_m_doctor_01" local time = 15000 -- in ms (15000ms --> 15s ) [s * 1000 = ms ] local text = "Du wurdest behandelt" local text2 = "Du bist nicht bewusstlos" ------------------------------------------------------------------------------- -- [[Register Client Plguin]] RegisterClientPlugin(pluginData, function(print) print("plugin_revive_client.lua loaded") end) -- [[Set Basic Values]] local isUnconscious = false -- [[Some Animation Things]] function loadAnimDict(dict) while (not HasAnimDictLoaded(dict)) do RequestAnimDict(dict) Citizen.Wait(0) end end -- [[Spawn Medic NPC]] function SpawnNPC(playerPed, playerCoords, Medic) loadAnimDict("mini@cpr@char_a@cpr_str") while not HasAnimDictLoaded("mini@cpr@char_a@cpr_str") do Citizen.Wait(0) end local spawnHeading = GetEntityHeading(playerPed) MedicPed = CreatePed(4, Medic, playerCoords.x, playerCoords.y, playerCoords.z, spawnHeading, true, false) TaskPlayAnim(MedicPed, "mini@cpr@char_a@cpr_str","cpr_pumpchest",1.0, 1.0, -1, 9, 1.0, 0, 0, 0) end -- [[Revive Player Function]] function revivePlayer(source) local playerPed = PlayerPedId() local playerCoords = GetEntityCoords(playerPed) local MedicPeded = {model = modelname, colour = 111} local reviveTime = time local Medic = GetHashKey(MedicPeded.model) RequestModel(Medic) while not HasModelLoaded(Medic) do RequestModel(Medic) Citizen.Wait(0) end SpawnNPC(playerPed, playerCoords, Medic) ClearPedTasksImmediately(playerPed) Citizen.Wait(reviveTime) TriggerEvent('visn_are:resetHealthBuffer', source) ClearPedTasksImmediately(MedicPed) DeletePed(MedicPed) Wait(5000) ShowNotification(text) end --[[RegisterCommand]] RegisterCommand(command, function(source, rawCommand) isUnconscious = exports['visn_are']:GetHealthBuffer().unconscious print(isUnconscious) if isUnconscious then revivePlayer(source) else ShowNotification(text2) end end) -- [[Show Notification Function]] function ShowNotification(text) SetNotificationTextEntry('STRING') AddTextComponentString(text) DrawNotification(false, true) end