Skip to content

Exports ​

The resource name has hyphens, so call the exports with brackets:

lua
local ccs = exports['np_crouch-crawl-shoot']
if ccs:IsProne() then … end

Exports from a resource that isn't running throw. Wrap calls in pcall or check GetResourceState('np_crouch-crawl-shoot') == 'started' if the resource is optional for you. The state bags work without that check.

Client ​

client

Export Returns Description
GetStance() 'stand' | 'crouch' | 'prone' Current stance
SetStance(state, instant?) true or false, reason Change the stance. instant = true skips the animation (the ped is already elsewhere: ragdoll, vehicle, cutscene). Animated changes to 'crouch' or 'prone' go through the same checks as the keys and return false, reason when refused ('busy', 'blocked', 'water', 'vehicle', 'slope', 'ui', …). It does not ask Config.CanUseStance
IsCrouched() boolean
IsProne() boolean Front or back
IsCrawling() boolean Prone and moving
GetProneType() 'front' | 'back' | nil nil when not prone
IsDeployed() boolean Prone with the weapon up
BlockStance(reason) boolean Add a block. See below
UnblockStance(reason) boolean Remove a block
IsBlocked(reason?) boolean With a reason: that block is set. Without: any block is set
SetWalkstyle(clipset) Tell the resource the player's walk style, so it comes back after crouching. See below
lua
local ccs = exports['np_crouch-crawl-shoot']

-- a cutscene: put the player on their feet without an animation
ccs:SetStance('stand', true)

-- a lockpick minigame that only works crouched
if ccs:GetStance() ~= 'crouch' then
  return exports.np_hud:Notify({ message = 'Crouch down first.', type = 'error' })
end

BlockStance ​

Blocks stop the player from crouching or going prone. If the player is crouched or prone when the first block is added, they stand up (animated). Standing up is never blocked.

lua
local ccs = exports['np_crouch-crawl-shoot']

-- while your minigame runs
ccs:BlockStance('my_minigame')
-- …
ccs:UnblockStance('my_minigame')
  • Reasons are strings. Several resources can hold different reasons at once. The stance is free when none is left.
  • Blocks are tied to the resource that added them and are removed when that resource stops.
  • The same works as a local event, TriggerEvent('np_ccs:block', reason, true|false). See Events.

For a permanent rule (zones, jobs), use Config.CanUseStance instead.

SetWalkstyle ​

When the player stands up from a crouch, the resource restores the walk style. It looks in this order:

  1. the clipset last reported with SetWalkstyle,
  2. np_menu's getWalkstyle(),
  3. otherwise it resets the movement clipset and fires np_menu:reapplyWalk.

A walk style menu or an emote resource other than np_menu should report changes:

lua
-- after applying a walk style
SetPedMovementClipset(PlayerPedId(), 'move_m@brave', 0.25)
exports['np_crouch-crawl-shoot']:SetWalkstyle('move_m@brave')

-- back to the default walk
exports['np_crouch-crawl-shoot']:SetWalkstyle(nil)   -- nil, false, '' or 'default'

crouch_crawl aliases ​

The exports of MadsLeander's crouch_crawl are also available on this resource, and under exports.crouch_crawl while crouch_crawl itself doesn't run:

Export Returns
IsPlayerProne() boolean
IsPlayerCrawling() boolean
IsPlayerCrouched() boolean
GetPlayerProneType() 'onfront' | 'onback' (also when not prone, like crouch_crawl)
StopPlayerProne(force?) Stand up from prone. force = true skips the animation

See Compatibility → crouch_crawl.

Server ​

server

Export Returns Description
GetPlayerStance(src) stance, proneType, deployed Read from the player's state bags. nil for an unknown player. stance defaults to 'stand', proneType is nil unless prone
lua
-- ESX: a hiding spot that only counts while prone
local stance = exports['np_crouch-crawl-shoot']:GetPlayerStance(source)
if stance == 'prone' then
  TriggerClientEvent('esx:showNotification', source, 'You are hidden.')
end

-- or read the bag directly, without the export
local stance = Player(source).state.stance