-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.lua
More file actions
113 lines (96 loc) · 3.94 KB
/
client.lua
File metadata and controls
113 lines (96 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
local createdped = 0
local wagon = 0
local VORPcore = {}
local amount
local close
TriggerEvent("getCore", function(core)
VORPcore = core
end)
RegisterCommand(Config.doctors.command,function(source)
TriggerServerEvent("legacy_medic:getjob")
end)
RegisterNetEvent('legacy_medic:findjob')
AddEventHandler('legacy_medic:findjob', function(docs)
if IsEntityDead(PlayerPedId()) then
VORPcore.NotifyRightTip(Config.Language.calldoctor,4000)
SpawnNPC()
else
VORPcore.NotifyRightTip(Config.Language.notdead,4000)
end
end)
function SpawnNPC()
local model = GetHashKey(Config.doctors.ped)
RequestModel(model)
if not HasModelLoaded(model) then
RequestModel(model)
end
while not HasModelLoaded(model) or HasModelLoaded(model) == 0 or model == 1 do
Citizen.Wait(1)
end
for k, v in pairs(Config.doctors) do
local coords = GetEntityCoords(PlayerPedId())
local randomAngle = math.rad(math.random(0, 360))
local x = coords.x + math.sin(randomAngle) * math.random(1, 100) * 0.5
local y = coords.y + math.cos(randomAngle) * math.random(1, 100) * 0.5 -- End Number multiplied by is radius to player
local z = coords.z
local b, rdcoords, rdcoords2 = GetClosestVehicleNode(coords.x, coords.y, coords.z, 1, 10.0, 10.0)
if (rdcoords.x == 0.0 and rdcoords.y == 0.0 and rdcoords.z == 0.0) then
local valid, outPosition = GetSafeCoordForPed(x, y, z, false, 8)
if valid then
x = outPosition.x
y = outPosition.y
z = outPosition.z
end
else
local inwater = Citizen.InvokeNative(0x43C851690662113D, createdped, 100)
if inwater then
DeleteEntity(createdped)
VORPcore.NotifyRightTip(Config.Language.inwater,4000)
end
local valid, outPosition = GetSafeCoordForPed(x, y, z, false, 16)
if valid then
x = outPosition.x
y = outPosition.y
z = outPosition.z
end
local foundground, groundZ, normal = GetGroundZAndNormalFor_3dCoord(x, y, z)
if foundground then
z = groundZ
else
VORPcore.NotifyRightTip(Config.Language.missground,4000)
DeleteEntity(createdped)
end
end
if createdped == 0 then
createdped = CreatePed(model, x+2.0, y, z ,true, true, true, true)
Wait(500)
else
DeleteEntity(createdped)
VORPcore.NotifyRightTip(Config.Language.doctordied,4000)
createdped = 0
end
Citizen.InvokeNative(0x283978A15512B2FE, createdped, true)
local ped = PlayerPedId()
FreezeEntityPosition(createdped, false)
Citizen.InvokeNative(0x923583741DC87BCE, createdped, "default")
TaskGoToEntity(createdped, ped, -1, 2.0, 5.0, 1073741824, 1)
Wait(0)
while createdped do
local pcoords = GetEntityCoords(PlayerPedId())
local tcoords = GetEntityCoords(createdped)
local distance = Vdist2(pcoords.x,pcoords.y,pcoords.z,tcoords.x,tcoords.y,tcoords.z)
Wait(0)
if distance < 5 then
if createdped then
Wait(5000)
DeleteEntity(createdped)
TriggerServerEvent('legacy_medic:reviveplayer', source)
end
end
end
end
end
RegisterNetEvent("legacy_medic:revive")
AddEventHandler("legacy_medic:revive", function()
TriggerEvent('vorp:resurrectPlayer', source)
end)