├── README.md ├── __resource.lua ├── LICENSE └── client.lua /README.md: -------------------------------------------------------------------------------- 1 | # crouch-n-prone 2 | Crouch'n Prone - FiveM Resource 3 | -------------------------------------------------------------------------------- /__resource.lua: -------------------------------------------------------------------------------- 1 | -- Crouch script written by WolfKnight 2 | -- Modified by Blumlaut 3 | resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' 4 | 5 | -- Add a client script 6 | client_script 'client.lua' -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Blumlaut 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /client.lua: -------------------------------------------------------------------------------- 1 | -- Script Created by Giant Cheese Wedge (AKA Blü) 2 | -- Script Modified and fixed by Hoopsure 3 | 4 | local crouched = false 5 | local proned = false 6 | crouchKey = 26 7 | proneKey = 36 8 | 9 | Citizen.CreateThread( function() 10 | while true do 11 | Citizen.Wait( 1 ) 12 | local ped = GetPlayerPed( -1 ) 13 | if ( DoesEntityExist( ped ) and not IsEntityDead( ped ) ) then 14 | ProneMovement() 15 | DisableControlAction( 0, proneKey, true ) 16 | DisableControlAction( 0, crouchKey, true ) 17 | if ( not IsPauseMenuActive() ) then 18 | if ( IsDisabledControlJustPressed( 0, crouchKey ) and not proned ) then 19 | RequestAnimSet( "move_ped_crouched" ) 20 | RequestAnimSet("MOVE_M@TOUGH_GUY@") 21 | 22 | while ( not HasAnimSetLoaded( "move_ped_crouched" ) ) do 23 | Citizen.Wait( 100 ) 24 | end 25 | while ( not HasAnimSetLoaded( "MOVE_M@TOUGH_GUY@" ) ) do 26 | Citizen.Wait( 100 ) 27 | end 28 | if ( crouched and not proned ) then 29 | ResetPedMovementClipset( ped ) 30 | ResetPedStrafeClipset(ped) 31 | SetPedMovementClipset( ped,"MOVE_M@TOUGH_GUY@", 0.5) 32 | crouched = false 33 | elseif ( not crouched and not proned ) then 34 | SetPedMovementClipset( ped, "move_ped_crouched", 0.55 ) 35 | SetPedStrafeClipset(ped, "move_ped_crouched_strafing") 36 | crouched = true 37 | end 38 | elseif ( IsDisabledControlJustPressed(0, proneKey) and not crouched and not IsPedInAnyVehicle(ped, true) and not IsPedFalling(ped) and not IsPedDiving(ped) and not IsPedInCover(ped, false) and not IsPedInParachuteFreeFall(ped) and (GetPedParachuteState(ped) == 0 or GetPedParachuteState(ped) == -1) ) then 39 | if proned then 40 | ClearPedTasks(ped) 41 | local me = GetEntityCoords(ped) 42 | SetEntityCoords(ped, me.x, me.y, me.z-0.5) 43 | proned = false 44 | elseif not proned then 45 | RequestAnimSet( "move_crawl" ) 46 | while ( not HasAnimSetLoaded( "move_crawl" ) ) do 47 | Citizen.Wait( 100 ) 48 | end 49 | ClearPedTasksImmediately(ped) 50 | proned = true 51 | if IsPedSprinting(ped) or IsPedRunning(ped) or GetEntitySpeed(ped) > 5 then 52 | TaskPlayAnim(ped, "move_jump", "dive_start_run", 8.0, 1.0, -1, 0, 0.0, 0, 0, 0) 53 | Citizen.Wait(1000) 54 | end 55 | SetProned() 56 | end 57 | end 58 | end 59 | else 60 | proned = false 61 | crouched = false 62 | end 63 | end 64 | end) 65 | 66 | function SetProned() 67 | ped = PlayerPedId() 68 | ClearPedTasksImmediately(ped) 69 | TaskPlayAnimAdvanced(ped, "move_crawl", "onfront_fwd", GetEntityCoords(ped), 0.0, 0.0, GetEntityHeading(ped), 1.0, 1.0, 1.0, 46, 1.0, 0, 0) 70 | end 71 | 72 | 73 | function ProneMovement() 74 | if proned then 75 | ped = PlayerPedId() 76 | DisableControlAction(0, 23) 77 | DisableControlAction(0, 21) 78 | if IsControlPressed(0, 32) or IsControlPressed(0, 33) then 79 | DisablePlayerFiring(ped, true) 80 | elseif IsControlJustReleased(0, 32) or IsControlJustReleased(0, 33) then 81 | DisablePlayerFiring(ped, false) 82 | end 83 | if IsControlJustPressed(0, 32) and not movefwd then 84 | movefwd = true 85 | TaskPlayAnimAdvanced(ped, "move_crawl", "onfront_fwd", GetEntityCoords(ped), 1.0, 0.0, GetEntityHeading(ped), 1.0, 1.0, 1.0, 47, 1.0, 0, 0) 86 | elseif IsControlJustReleased(0, 32) and movefwd then 87 | TaskPlayAnimAdvanced(ped, "move_crawl", "onfront_fwd", GetEntityCoords(ped), 1.0, 0.0, GetEntityHeading(ped), 1.0, 1.0, 1.0, 46, 1.0, 0, 0) 88 | movefwd = false 89 | end 90 | if IsControlJustPressed(0, 33) and not movebwd then 91 | movebwd = true 92 | TaskPlayAnimAdvanced(ped, "move_crawl", "onfront_bwd", GetEntityCoords(ped), 1.0, 0.0, GetEntityHeading(ped), 1.0, 1.0, 1.0, 47, 1.0, 0, 0) 93 | elseif IsControlJustReleased(0, 33) and movebwd then 94 | TaskPlayAnimAdvanced(ped, "move_crawl", "onfront_bwd", GetEntityCoords(ped), 1.0, 0.0, GetEntityHeading(ped), 1.0, 1.0, 1.0, 46, 1.0, 0, 0) 95 | movebwd = false 96 | end 97 | if IsControlPressed(0, 34) then 98 | SetEntityHeading(ped, GetEntityHeading(ped)+2.0 ) 99 | elseif IsControlPressed(0, 35) then 100 | SetEntityHeading(ped, GetEntityHeading(ped)-2.0 ) 101 | end 102 | end 103 | end 104 | --------------------------------------------------------------------------------