Created
July 18, 2019 22:36
-
-
Save FrazzIe/756b644f3d7ab5bf3f8c917793f8ac71 to your computer and use it in GitHub Desktop.
Tablet animation - FiveM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local tablet = false | |
local tabletDict = "amb@code_human_in_bus_passenger_idles@female@tablet@base" | |
local tabletAnim = "base" | |
local tabletProp = `prop_cs_tablet` | |
local tabletBone = 60309 | |
local tabletOffset = vector3(0.03, 0.002, -0.0) | |
local tabletRot = vector3(10.0, 160.0, 0.0) | |
function ToggleTablet(toggle) | |
if toggle and not tablet then | |
tablet = true | |
Citizen.CreateThread(function() | |
RequestAnimDict(tabletDict) | |
while not HasAnimDictLoaded(tabletDict) do | |
Citizen.Wait(150) | |
end | |
RequestModel(tabletProp) | |
while not HasModelLoaded(tabletProp) do | |
Citizen.Wait(150) | |
end | |
local playerPed = PlayerPedId() | |
local tabletObj = CreateObject(tabletProp, 0.0, 0.0, 0.0, true, true, false) | |
local tabletBoneIndex = GetPedBoneIndex(playerPed, tabletBone) | |
SetCurrentPedWeapon(playerPed, `weapon_unarmed`, true) | |
AttachEntityToEntity(tabletObj, playerPed, tabletBoneIndex, tabletOffset.x, tabletOffset.y, tabletOffset.z, tabletRot.x, tabletRot.y, tabletRot.z, true, false, false, false, 2, true) | |
SetModelAsNoLongerNeeded(tabletProp) | |
while tablet do | |
Citizen.Wait(100) | |
playerPed = PlayerPedId() | |
if not IsEntityPlayingAnim(playerPed, tabletDict, tabletAnim, 3) then | |
TaskPlayAnim(playerPed, tabletDict, tabletAnim, 3.0, 3.0, -1, 49, 0, 0, 0, 0) | |
end | |
end | |
ClearPedSecondaryTask(playerPed) | |
Citizen.Wait(450) | |
DetachEntity(tabletObj, true, false) | |
DeleteEntity(tabletObj) | |
end) | |
elseif not toggle and tablet then | |
tablet = false | |
end | |
end | |
Citizen.CreateThread(function() | |
while true do | |
Citizen.Wait(0) | |
if IsControlJustPressed(1, 51) then | |
ToggleTablet(not tablet) | |
end | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment