This repository has been archived by the owner on Feb 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
cl_carryEntity.lua
55 lines (51 loc) · 1.8 KB
/
cl_carryEntity.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
RegisterNetEvent('carryEntity')
AddEventHandler('carryEntity', function(Context,pEntity)
TriggerEvent("DoShortHudText","Press E to drop the Entity.")
-- we can add offsets here later to specific models, right now this is for bikes.
AttachEntityToEntity(pEntity, PlayerPedId(), 28422, 0.0, 0.3, 0.2, 0.0, 0.0, 90.0, 1, 1, 0, 1, 0, 1)
local CarryTime = 0
RequestAnimDict('anim@heists@box_carry@')
while not HasAnimDictLoaded("anim@heists@box_carry@") do
Citizen.Wait(0)
end
while pEntity ~= 0 and IsEntityAttachedToEntity(pEntity,PlayerPedId()) do
local ped = PlayerPedId()
Citizen.Wait(1)
CarryTime = CarryTime + 1
CarryEntityAnim()
if IsControlJustPressed(0,38) then
CleanEntityAttach(pEntity)
end
if AbuseCheck(ped) then
SetPedToRagdoll(ped, 500, 500, 3, 0, 0, 0)
CleanEntityAttach(pEntity)
end
if CarryTime > (1000*60) then
TriggerEvent("DoShortHudText","You got tired from carrying the Entity :(")
CleanEntityAttach(pEntity)
end
end
CleanEntityAttach(pEntity)
end)
function AbuseCheck(ped)
if
IsPedSprinting(ped) or
IsPedRunning(ped) or
IsPedClimbing(ped) or
IsPedJumping(ped) or
`WEAPON_UNARMED` ~= GetSelectedPedWeapon(PlayerPedId())
then
return true
end
return false
end
function CarryEntityAnim()
if not IsEntityPlayingAnim(PlayerPedId(), "anim@heists@box_carry@", "idle", 3) then
TaskPlayAnim(PlayerPedId(), "anim@heists@box_carry@", "idle", 8.0, -8, -1, 49, 0, 0, 0, 0)
end
end
function CleanEntityAttach(pEntity)
ClearPedTasks(PlayerPedId())
DetachEntity(pEntity)
SetVehicleOnGroundProperly(pEntity)
end