Skip to content

Commit 9ce52fe

Browse files
author
Nats-ji
committed
Fixed Hotkey in cet 1.9.2
1 parent f0d5be1 commit 9ce52fe

File tree

1 file changed

+71
-75
lines changed

1 file changed

+71
-75
lines changed

init.lua

Lines changed: 71 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -23,91 +23,87 @@ registerForEvent("onInit", function()
2323
print("************************************************")
2424
end)
2525

26-
registerForEvent("onUpdate", function()
27-
if (not ImGui.IsKeyDown(0x10) and ImGui.IsKeyPressed(HotKey, false)) then
28-
drawPopup = false
29-
player = Game.GetPlayer()
30-
objLook = Game.GetTargetingSystem():GetLookAtObject(player,false,false)
31-
objType = objLook:ToString()
32-
33-
-- Real door --
34-
if (objType == "Door") then
35-
objName = objType
36-
detailInfo = "Open Sesame..."
37-
breachInfo = "The door has been opened."
38-
objLook:OpenDoor()
39-
getTime = os:clock()
40-
drawPopup = true
41-
42-
-- Fake door --
43-
elseif (objType == "FakeDoor") then
44-
objName = objType
45-
detailInfo = "This is a fake door..."
46-
breachInfo = "Failed to breach the door."
47-
getTime = os:clock()
48-
drawPopup = true
26+
registerHotkey("open_sesame_open", "Open/Unlock Hotkey", function()
27+
drawPopup = false
28+
player = Game.GetPlayer()
29+
objLook = Game.GetTargetingSystem():GetLookAtObject(player,false,false)
30+
objType = objLook:ToString()
4931

50-
-- Vehicle door --
51-
elseif (objLook:IsVehicle()) then
52-
vehDestoryed = objLook:IsDestroyed()
53-
if (not vehDestoryed) then
54-
vehName = objLook:GetDisplayName()
55-
vehPS = objLook:GetVehiclePS()
56-
vehComp = objLook:GetVehicleComponent()
57-
vehOcc = not is_empty(vehPS:GetNpcOccupiedSlots())
58-
vehMass = objLook:GetTotalMass()
59-
objName = vehName
60-
detailInfo = vehName.." weighs "..vehMass.."KG"
61-
breachInfo = "Vehicle doors has been unlocked."
62-
if (vehOcc) then -- Vehicle is occupied by npc
63-
vehComp:DestroyVehicle() -- Eject NPCs
64-
vehComp:RepairVehicle()
65-
vehComp:DestroyMappin() -- RepairVehicle() somehow adds mappin
66-
end
67-
vehPS:UnlockAllVehDoors() -- Open Vehicle Doors
68-
vehComp:HonkAndFlash()
69-
getTime = os:clock()
70-
drawPopup = true
71-
end
72-
end
73-
elseif (ImGui.IsKeyDown(0x10) and ImGui.IsKeyPressed(HotKey, false)) then
74-
drawPopup = false
75-
player = Game.GetPlayer()
76-
objLook = Game.GetTargetingSystem():GetLookAtObject(player,false,false)
77-
objType = objLook:ToString()
32+
-- Real door --
33+
if (objType == "Door") then
34+
objName = objType
35+
detailInfo = "Open Sesame..."
36+
breachInfo = "The door has been opened."
37+
objLook:OpenDoor()
38+
getTime = os:clock()
39+
drawPopup = true
7840

79-
-- Kill NPC --
80-
if (objType == "NPCPuppet") then
81-
if (not objLook:IsDead()) then
82-
npcName = objLook:GetDisplayName()
83-
objName = npcName
84-
detailInfo = npcName.." is a NPC."
85-
breachInfo = npcName.." has been killed."
86-
objLook:Kill(player, false, false) -- Kill NPC by player
87-
getTime = os:clock()
88-
drawPopup = true
89-
end
41+
-- Fake door --
42+
elseif (objType == "FakeDoor") then
43+
objName = objType
44+
detailInfo = "This is a fake door..."
45+
breachInfo = "Failed to breach the door."
46+
getTime = os:clock()
47+
drawPopup = true
9048

91-
-- Explode Vehicle --
92-
elseif (objLook:IsVehicle()) then
49+
-- Vehicle door --
50+
elseif (objLook:IsVehicle()) then
51+
vehDestoryed = objLook:IsDestroyed()
52+
if (not vehDestoryed) then
9353
vehName = objLook:GetDisplayName()
54+
vehPS = objLook:GetVehiclePS()
9455
vehComp = objLook:GetVehicleComponent()
56+
vehOcc = not is_empty(vehPS:GetNpcOccupiedSlots())
9557
vehMass = objLook:GetTotalMass()
96-
vehDestoryed = objLook:IsDestroyed()
97-
vehComp:ExplodeVehicle(player)
98-
vehComp:DestroyVehicle()
9958
objName = vehName
10059
detailInfo = vehName.." weighs "..vehMass.."KG"
101-
breachInfo = "Vehicle has been blown up."
102-
if (not vehDestoryed) then
103-
getTime = os:clock()
104-
drawPopup = true
60+
breachInfo = "Vehicle doors has been unlocked."
61+
if (vehOcc) then -- Vehicle is occupied by npc
62+
vehComp:DestroyVehicle() -- Eject NPCs
63+
vehComp:RepairVehicle()
64+
vehComp:DestroyMappin() -- RepairVehicle() somehow adds mappin
10565
end
66+
vehPS:UnlockAllVehDoors() -- Open Vehicle Doors
67+
vehComp:HonkAndFlash()
68+
getTime = os:clock()
69+
drawPopup = true
70+
end
71+
end
72+
end)
73+
74+
registerHotkey("open_sesame_kill", "Kill/Explode Hotkey", function()
75+
drawPopup = false
76+
player = Game.GetPlayer()
77+
objLook = Game.GetTargetingSystem():GetLookAtObject(player,false,false)
78+
objType = objLook:ToString()
79+
80+
-- Kill NPC --
81+
if (objType == "NPCPuppet") then
82+
if (not objLook:IsDead()) then
83+
npcName = objLook:GetDisplayName()
84+
objName = npcName
85+
detailInfo = npcName.." is a NPC."
86+
breachInfo = npcName.." has been killed."
87+
objLook:Kill(player, false, false) -- Kill NPC by player
88+
getTime = os:clock()
89+
drawPopup = true
90+
end
91+
92+
-- Explode Vehicle --
93+
elseif (objLook:IsVehicle()) then
94+
vehName = objLook:GetDisplayName()
95+
vehComp = objLook:GetVehicleComponent()
96+
vehMass = objLook:GetTotalMass()
97+
vehDestoryed = objLook:IsDestroyed()
98+
vehComp:ExplodeVehicle(player)
99+
vehComp:DestroyVehicle()
100+
objName = vehName
101+
detailInfo = vehName.." weighs "..vehMass.."KG"
102+
breachInfo = "Vehicle has been blown up."
103+
if (not vehDestoryed) then
104+
getTime = os:clock()
105+
drawPopup = true
106106
end
107-
-- Dump object
108-
-- elseif (ImGui.IsKeyDown(0x10) and ImGui.IsKeyPressed(0x52, false)) then
109-
-- objLook = Game.GetTargetingSystem():GetLookAtObject(player,false,false)
110-
-- print(Dump(objLook))
111107
end
112108
end)
113109

0 commit comments

Comments
 (0)