Skip to content

Instantly share code, notes, and snippets.

@Lucas7yoshi
Created March 21, 2023 17:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Lucas7yoshi/c8bd225810e122d78c80528780a2e95c to your computer and use it in GitHub Desktop.
Save Lucas7yoshi/c8bd225810e122d78c80528780a2e95c to your computer and use it in GitHub Desktop.
RegisterCommand("tutpart1", function()
local scannerModel = GetHashKey("ch_prop_fingerprint_scanner_01d")
RequestModel(scannerModel)
RequestAnimDict("anim_heist@hs3f@ig1_hack_keypad@male@")
repeat Wait(0) until HasModelLoaded(scannerModel) and HasAnimDictLoaded("anim_heist@hs3f@ig1_hack_keypad@male@")
-- Spawn it a bit in the air just to avoid clipping with anything
local spawnPos = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 1.0, 1.0)
local scanner = CreateObject(scannerModel, spawnPos, true, false, false) -- Networked parameter MUST be true to be used in network scene!
SetEntityHeading(scanner, GetEntityHeading(PlayerPedId()))
local phoneModel = GetHashKey("ch_prop_ch_phone_ing_01a")
local usbModel = GetHashKey("ch_prop_ch_usb_drive01x")
RequestModel(phoneModel) RequestModel(usbModel)
repeat Wait(0) until HasModelLoaded(phoneModel) and HasModelLoaded(usbModel)
-- Just create these inside the player because they will be immediatelly attached to the scene.
local phone = CreateObject(phoneModel, GetEntityCoords(PlayerPedId()), true, false, false)
local usb = CreateObject(usbModel, GetEntityCoords(PlayerPedId()), true, false, false)
local scene = NetworkCreateSynchronisedScene(
GetEntityCoords(scanner), -- FiveM unwraps this to X, Y, Z
GetEntityRotation(scanner), -- ^
2, -- Rotation Order
true, -- Hold last frame
false, -- Do not loop
1.0, -- p9
0.0, -- Starting phase (0.0 meaning we play it from the beginning)
1.0 -- animSpeed
)
local dict = "anim_heist@hs3f@ig1_hack_keypad@male@" -- For readability
NetworkAddPedToSynchronisedScene(PlayerPedId(), scene, dict, "action_var_01", 8.0, 8.0, 0, 0, 1000.0, 0)
NetworkAddEntityToSynchronisedScene(usb, scene, dict, "action_var_01_ch_prop_ch_usb_drive01x", 8.0, 8.0, 0)
NetworkAddEntityToSynchronisedScene(phone, scene, dict, "action_var_01_prop_phone_ing", 8.0, 8.0, 0)
NetworkStartSynchronisedScene(scene)
Wait(0)
local localScene = NetworkGetLocalSceneFromNetworkId(scene)
repeat Wait(0) until GetSynchronizedScenePhase(localScene) > 0.99
-- Part 2
scene = NetworkCreateSynchronisedScene( -- Repeated code...
GetEntityCoords(scanner), -- FiveM unwraps this to X, Y, Z
GetEntityRotation(scanner), -- ^
2, -- Rotation Order
true, -- Hold last frame
false, -- Do not loop
1.0, -- p9
0.0, -- Starting phase (0.0 meaning we play it from the beginning)
1.0 -- animSpeed
)
NetworkAddPedToSynchronisedScene(PlayerPedId(), scene, dict, "hack_loop_var_01", 8.0, 8.0, 0, 0, 1000.0, 0)
NetworkAddEntityToSynchronisedScene(usb, scene, dict, "hack_loop_var_01_ch_prop_ch_usb_drive01x", 8.0, 8.0, 0)
NetworkAddEntityToSynchronisedScene(phone, scene, dict, "hack_loop_var_01_prop_phone_ing", 8.0, 8.0, 0)
NetworkStartSynchronisedScene(scene)
Wait(5000) -- Simulated "hacking" part
scene = NetworkCreateSynchronisedScene(
GetEntityCoords(scanner), GetEntityRotation(scanner),
2, false, false, 1.0, 0.0, 1.0
)
--success_react_exit_var_01
NetworkAddPedToSynchronisedScene(PlayerPedId(), scene, dict, "success_react_exit_var_01", 8.0, 8.0, 0, 0, 1000.0, 0)
NetworkAddEntityToSynchronisedScene(usb, scene, dict, "success_react_exit_var_01_ch_prop_ch_usb_drive01x", 8.0, 8.0, 0)
NetworkAddEntityToSynchronisedScene(phone, scene, dict, "success_react_exit_var_01_prop_phone_ing", 8.0, 8.0, 0)
NetworkStartSynchronisedScene(scene)
Wait(0)
localScene = NetworkGetLocalSceneFromNetworkId(scene)
repeat Wait(0) until not IsSynchronizedSceneRunning(localScene)
-- Clean up
DeleteObject(phone)
DeleteObject(usb)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment