-
Notifications
You must be signed in to change notification settings - Fork 0
/
clientrevised.lua
115 lines (103 loc) · 5.54 KB
/
clientrevised.lua
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
114
115
--[[Door locking clientside code, referenced from MissBehavin's non-ESX door lock script, edited (implemented player animations, removed ESX, removed non-used code) and presented for LARP demonstration, by TitanSix--]]--
--[[Code includes 3d text of door being locked/unlocked when used, also includes animation for locking the door, for MRPD cell doors]]--
--[[Code also referenced from FiveM forums]]--
function DrawText3d(x,y,z, text)
local onScreen,_x,_y=World3dToScreen2d(x,y,z)
local px,py,pz=table.unpack(GetGameplayCamCoords())
if onScreen then
SetTextScale(0.5, 0.5)
SetTextFont(0)
SetTextProportional(1)
SetTextColour(255, 0, 0, 255)
SetTextDropshadow(0, 0, 0, 0, 55)
SetTextEdge(2, 0, 0, 0, 150)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
SetTextCentre(1)
AddTextComponentString(text)
DrawText(_x,_y)
ClearDrawOrigin()
end
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local ped = GetPlayerPed(-1)
for i = 1, #doors do
local playerCoords = GetEntityCoords( GetPlayerPed(-1) )
local closeDoor = GetClosestObjectOfType(doors[i]["x"], doors[i]["y"], doors[i]["z"], 1.0, GetHashKey(doors[i]["objName"]), false, false, false)
local objectCoordsDraw = GetEntityCoords( closeDoor )
local playerDistance = GetDistanceBetweenCoords(playerCoords.x, playerCoords.y, playerCoords.z, doors[i]["x"], doors[i]["y"], doors[i]["z"], true)
if(playerDistance < 1.25) then
if doors[i]["locked"] == true then
DrawText3d(doors[i]["txtX"], doors[i]["txtY"], doors[i]["txtZ"], "[E] ~r~Locked")
else
DrawText3d(doors[i]["txtX"], doors[i]["txtY"], doors[i]["txtZ"], "[E] ~g~Unlocked")
end
if IsControlJustPressed(1,51) then
--[[Code chunk below is for animations. I believe it could be put here, or individually inside if the doors are locked = true/= false. Clarification?]]--
if (GetEntityModel(ped) == GetHashKey("mp_m_freemode_01")) then
RequestAnimDict('anim@amb@clubhouse@tutorial@bkr_tut_ig3@machinic_loop_mechandplayer')
while not HasAnimDictLoaded('anim@amb@clubhouse@tutorial@bkr_tut_ig3@machinic_loop_mechandplayer') do
Citizen.Wait(0)
end
TaskPlayAnim(ped,'anim@amb@clubhouse@tutorial@bkr_tut_ig3@machinic_loop_mechandplayer', 'machinic_loop_mechandplayer'', 1.0, 1.0, -1, 8, -1, true, true, true)
elseif (GetEntityModel(ped) == GetHashKey("mp_f_freemode_01")) then
RequestAnimDict('anim@amb@clubhouse@tutorial@bkr_tut_ig3@machinic_loop_mechandplayer')
while not HasAnimDictLoaded('anim@amb@clubhouse@tutorial@bkr_tut_ig3@machinic_loop_mechandplayer') do
Citizen.Wait(0)
end
TaskPlayAnim(ped,'anim@amb@clubhouse@tutorial@bkr_tut_ig3@machinic_loop_mechandplayer', 'machinic_loop_mechandplayer'', 1.0, 1.0, -1, 8, -1, true, true, true)
else
RequestAnimDict('anim@amb@clubhouse@tutorial@bkr_tut_ig3@machinic_loop_mechandplayer')
while not HasAnimDictLoaded('anim@amb@clubhouse@tutorial@bkr_tut_ig3@machinic_loop_mechandplayer') do
Citizen.Wait(0)
end
TaskPlayAnim(ped,'anim@amb@clubhouse@tutorial@bkr_tut_ig3@machinic_loop_mechandplayer', 'machinic_loop_mechandplayer'', 1.0, 1.0, -1, 8, -1, true, true, true)
end
end
end
--[[Code below is for lock state on the doors. Github seems to be playing up, and not properly coloring it.]]--
if doors[i]["locked"] == true then
FreezeEntityPosition(closeDoor, false)
if(i==1 or i==2 or i==3 or i==4) then
doors[1]["locked"] = false
doors[2]["locked"] = false
doors[3]["locked"] = false
doors[4]["locked"] = false
else
doors[i]["locked"] = false
end
else
FreezeEntityPosition(closeDoor, true)
if(i==1 or i==2 or i==3 or i==4) then
doors[1]["locked"] = true
doors[2]["locked"] = true
doors[3]["locked"] = true
doors[4]["locked"] = true
else
doors[i]["locked"] = true
end
end
TriggerServerEvent('door:update', i, doors[i]["locked"])
end
else
FreezeEntityPosition(closeDoor, doors[i]["locked"])
end
end
end
end)
doors = {
-- mission row cell doors
[1] = { ["objName"] = "v_ilev_ph_cellgate", ["x"]= 463.815, ["y"]= -992.686,["z"]= 24.9149,["locked"]= true,["txtX"]=463.815,["txtY"]=-992.686,["txtZ"]=25.064},
[2] = { ["objName"] = "v_ilev_ph_cellgate", ["x"]= 462.381, ["y"]= -993.651,["z"]= 24.9149,["locked"]= true,["txtX"]=461.806,["txtY"]=-993.308,["txtZ"]=25.064},
[3] = { ["objName"] = "v_ilev_ph_cellgate", ["x"]= 462.331, ["y"]= -998.152,["z"]= 24.9149,["locked"]= true,["txtX"]=461.806,["txtY"]=-998.800,["txtZ"]=25.064},
[4] = { ["objName"] = "v_ilev_ph_cellgate", ["x"]= 462.704, ["y"]= -1001.92,["z"]= 24.9149,["locked"]= true,["txtX"]=461.806,["txtY"]=-1002.450,["txtZ"]=25.064},
}
RegisterNetEvent('door:state')
AddEventHandler('door:state', function(id, lockdoor)
if type(doors[id]) ~= nil then
doors[id]["locked"] = lockdoor
end
end)