client runtime · Lua API
Open77.players
Runs inside the game process. Reads and presentation are local; anything that changes shared state has to go through the server.
On this page51 sections
- all
- allHealthStates
- allLifeStates
- allowAim
- allowCrouch
- allowDodge
- allowInteraction
- allowJump
- allowRunning
- allowShoot
- allowWeapons
- closest
- entity
- freezePosition
- freezeRotation
- fromEntity
- getControlMask
- getDriveByState
- getHealthState
- getHoloCallEyes
- getLifeState
- getLocalDeathContext
- getModel
- getVehicleSeat
- isAiming
- isCrouching
- isDead
- isDiving
- isDriveByEnabled
- isDriver
- isFalling
- isGrounded
- isInDriveBy
- isInVehicle
- isJumping
- isLocalPuppetVisible
- isModelReady
- isModelValid
- isPassenger
- isReloading
- isShooting
- isSliding
- isSprinting
- isSwimming
- isVaulting
- local
- localId
- nearby
- resetControls
- setLocalDriveByEnabled
- setLocalPuppetVisible
all
Open77.players.all([options])Lists every player this client currently knows about, ascending by player id.
No permission. STREAMING-SCOPED, not the server roster: it holds the players this client has been told about and can draw, so a player the server counts as connected can legitimately be absent. Anything that must be true of the whole session asks the server. The local player is included, matching FiveM's GetActivePlayers. A player who is connected but has no body is still listed; pass { streamed = true } to keep only the ones with a body, which is the NetworkIsPlayerActive filter.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
options | table { streamed } | optional | — |
Returns
- array of player ids
Example
-- How many players does this client currently see with a body?
local visible = Open77.players.all({ streamed = true })
Open77.hud.notify(("%d players around you"):format(#visible - 1)) -- minus yourselfPlayers around you (client) · Registered in ResourceHost.cpp as LuaPlayersAll (line 25159).
allHealthStates
Open77.players.allHealthStates()Lists all replicated player health snapshots known to the client.
Requires players.life.read; returns an empty array when unavailable.
Returns
- array of health snapshots
Example
-- Show a low-health warning icon over every wounded player nearby
for _, health in ipairs(Open77.players.allHealthStates()) do
if health.health < health.maxHealth * 0.25 then
markWounded(health.playerId)
end
endPlayers around you (client) · Registered in ResourceHost.cpp as LuaPlayerHealthAll (line 25152).
allLifeStates
Open77.players.allLifeStates()Lists all replicated canonical player life states known to the client.
Requires players.life.read; returns an empty array when unavailable.
Returns
- array of life snapshots
Example
-- Count how many players around are down
local down = 0
for _, life in ipairs(Open77.players.allLifeStates()) do
if life.phase ~= "alive" then down = down + 1 end
endPlayers around you (client) · Registered in ResourceHost.cpp as LuaPlayerLifeAll (line 25150).
allowAim
Open77.players.allowAim(enabled)Allow or block a local-player action.
Requires players.controls and a strict boolean. Freeze true acquires a block; Allow false acquires a block. The inverse releases only this resource VM's block, never another owner or vanilla restriction. Automatically released on resource stop, death and session teardown. Does not freeze vehicles, moving platforms or server teleports. See player-utilities.md for each native restriction and limitations.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
enabled | boolean | required | — |
Returns
- true, or false, reason
Example
-- No aiming inside the safe zone; released again when the player leaves it
AddEventHandler("safezone:entered", function() Open77.players.allowAim(false) end)
AddEventHandler("safezone:left", function() Open77.players.allowAim(true) end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerControl (line 12381).
allowCrouch
Open77.players.allowCrouch(enabled)Allow or block a local-player action.
Requires players.controls and a strict boolean. Freeze true acquires a block; Allow false acquires a block. The inverse releases only this resource VM's block, never another owner or vanilla restriction. Automatically released on resource stop, death and session teardown. Does not freeze vehicles, moving platforms or server teleports. See player-utilities.md for each native restriction and limitations.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
enabled | boolean | required | — |
Returns
- true, or false, reason
Example
-- A cutscene where the player must stay standing
Open77.players.allowCrouch(false)
SetTimeout(10000, function() Open77.players.allowCrouch(true) end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerControl (line 12383).
allowDodge
Open77.players.allowDodge(enabled)Allow or block a local-player action.
Requires players.controls and a strict boolean. Freeze true acquires a block; Allow false acquires a block. The inverse releases only this resource VM's block, never another owner or vanilla restriction. Automatically released on resource stop, death and session teardown. Does not freeze vehicles, moving platforms or server teleports. See player-utilities.md for each native restriction and limitations.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
enabled | boolean | required | — |
Returns
- true, or false, reason
Example
-- The "no dodge" round of the fighting tournament
Open77.players.allowDodge(false)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerControl (line 12384).
allowInteraction
Open77.players.allowInteraction(enabled)Allow or block a local-player action.
Requires players.controls and a strict boolean. Freeze true acquires a block; Allow false acquires a block. The inverse releases only this resource VM's block, never another owner or vanilla restriction. Automatically released on resource stop, death and session teardown. Does not freeze vehicles, moving platforms or server teleports. See player-utilities.md for each native restriction and limitations.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
enabled | boolean | required | — |
Returns
- true, or false, reason
Example
-- Freeze the world's prompts while a dialogue is on screen
Open77.players.allowInteraction(false)
AddEventHandler("dialogue:closed", function() Open77.players.allowInteraction(true) end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerControl (line 12385).
allowJump
Open77.players.allowJump(enabled)Allow or block a local-player action.
Requires players.controls and a strict boolean. Freeze true acquires a block; Allow false acquires a block. The inverse releases only this resource VM's block, never another owner or vanilla restriction. Automatically released on resource stop, death and session teardown. Does not freeze vehicles, moving platforms or server teleports. See player-utilities.md for each native restriction and limitations.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
enabled | boolean | required | — |
Returns
- true, or false, reason
Example
-- No bunny-hopping across the racing track
AddEventHandler("race:started", function() Open77.players.allowJump(false) end)
AddEventHandler("race:finished", function() Open77.players.allowJump(true) end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerControl (line 12381).
allowRunning
Open77.players.allowRunning(enabled)Allow or block a local-player action.
Requires players.controls and a strict boolean. Freeze true acquires a block; Allow false acquires a block. The inverse releases only this resource VM's block, never another owner or vanilla restriction. Automatically released on resource stop, death and session teardown. Does not freeze vehicles, moving platforms or server teleports. See player-utilities.md for each native restriction and limitations.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
enabled | boolean | required | — |
Returns
- true, or false, reason
Example
-- A tired player can only walk for 20 seconds
Open77.players.allowRunning(false)
SetTimeout(20000, function() Open77.players.allowRunning(true) end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerControl (line 12382).
allowShoot
Open77.players.allowShoot(enabled)Allow or block a local-player action.
Requires players.controls and a strict boolean. Freeze true acquires a block; Allow false acquires a block. The inverse releases only this resource VM's block, never another owner or vanilla restriction. Automatically released on resource stop, death and session teardown. Does not freeze vehicles, moving platforms or server teleports. See player-utilities.md for each native restriction and limitations.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
enabled | boolean | required | — |
Returns
- true, or false, reason
Example
-- Weapons stay out but cannot fire in the lobby
Open77.players.allowShoot(false)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerControl (line 12382).
allowWeapons
Open77.players.allowWeapons(enabled)Allow or block a local-player action.
Requires players.controls and a strict boolean. Freeze true acquires a block; Allow false acquires a block. The inverse releases only this resource VM's block, never another owner or vanilla restriction. Automatically released on resource stop, death and session teardown. Does not freeze vehicles, moving platforms or server teleports. See player-utilities.md for each native restriction and limitations.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
enabled | boolean | required | — |
Returns
- true, or false, reason
Example
-- The hospital is a no-weapon zone
AddEventHandler("hospital:entered", function() Open77.players.allowWeapons(false) end)
AddEventHandler("hospital:left", function() Open77.players.allowWeapons(true) end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerControl (line 12385).
closest
Open77.players.closest([options])The nearest player with a body.
No permission. Open77.players.nearby reduced to its first entry, with the same options plus an optional radius (unbounded without one). Returns nil, "no_player_in_range" when nobody qualifies, which is deliberately distinct from nearby's empty table.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
options | table { radius, origin, includeSelf } | optional | — |
Returns
- { playerId, entity, distance, position, name, isLocal }
- or nil, reason
Example
-- Press E to trade with the nearest player within 3 m
RegisterKeyMapping("trade", "Trade", "E", function()
local other = Open77.players.closest({ radius = 3.0 })
if not other then return Open77.hud.notify("Nobody close enough") end
TriggerServerEvent("trade:request", other.playerId)
end)Players around you (client) · Registered in ResourceHost.cpp as LuaPlayersClosest (line 25165).
entity
Open77.players.entity(playerId)The entity id of one player's body.
No permission. Feed the result to any Open77 entity API, Open77.character.state(entity) first among them. The local player's body is the reserved entity id 0 that every entity API reads as "me", which is a value, not a failure. Reasons: player_not_streamed (known, no body right now), unknown_player, invalid_player. Cache the player id, never the entity id: a proxy body is destroyed and recreated on death, re-dress and world transition.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer|string | required | — |
Returns
- entity id
- or nil, reason
Example
-- Read another player's body state through their entity id
local entity = Open77.players.entity(playerId)
if entity then
local state = Open77.character.state(entity)
print(state.position.x, state.position.y, state.position.z)
endPlayers around you (client) · Registered in ResourceHost.cpp as LuaPlayersEntity (line 25162).
freezePosition
Open77.players.freezePosition(enabled)Request or release a native local-player freeze.
Requires players.controls and a strict boolean. Freeze true acquires a block; Allow false acquires a block. The inverse releases only this resource VM's block, never another owner or vanilla restriction. Automatically released on resource stop, death and session teardown. Does not freeze vehicles, moving platforms or server teleports. See player-utilities.md for each native restriction and limitations.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
enabled | boolean | required | — |
Returns
- true, or false, reason
Example
-- Hold the player still while the shop menu is open
Open77.players.freezePosition(true)
AddEventHandler("shop:closed", function() Open77.players.freezePosition(false) end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerControl (line 12380).
freezeRotation
Open77.players.freezeRotation(enabled)Request or release a native local-player freeze.
Requires players.controls and a strict boolean. Freeze true acquires a block; Allow false acquires a block. The inverse releases only this resource VM's block, never another owner or vanilla restriction. Automatically released on resource stop, death and session teardown. Does not freeze vehicles, moving platforms or server teleports. See player-utilities.md for each native restriction and limitations.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
enabled | boolean | required | — |
Returns
- true, or false, reason
Example
-- Lock the camera direction for a fixed-angle photo
Open77.players.freezeRotation(true)
SetTimeout(5000, function() Open77.players.freezeRotation(false) end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerControl (line 12380).
fromEntity
Open77.players.fromEntity(entityId)Which player wears a given body.
No permission. The inverse of Open77.players.entity, for turning a raycast or a proximity hit back into a player id. Accepts the entity as an integer or as the decimal string form. Entity 0 resolves to the local player. Returns nil, "unknown_entity" for an id that is not a live player body right now, which is what a cached id becomes after its body is retired.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
entityId | integer|string | required | — |
Returns
- player id
- or nil, reason
Example
-- The raycast hit a body: which player is it?
local hit = Open77.world.raycast(from, to, { entities = true })
if hit and hit.entity then
local playerId = Open77.players.fromEntity(hit.entity.engineEntity)
if playerId then Open77.hud.notify("You are looking at player " .. playerId) end
endPlayers around you (client) · Registered in ResourceHost.cpp as LuaPlayersFromEntity (line 25163).
getControlMask
Open77.players.getControlMask()Read the union of Open77 player-control block bits.
Requires players.controls. Does not remove other resources' blocks or expose vanilla restriction state. See player-utilities.md.
Returns
- integer mask, or nil, reason
Example
-- Debug: which controls has this resource blocked?
print(("control mask: 0x%X"):format(Open77.players.getControlMask() or 0))Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerControlsState (line 12392).
getDriveByState
Open77.players.getDriveByState([playerId])Reads local or remote vehicle drive-by state.
Client; requires players.read. Omit playerId or pass integer 0 for the local player. Returns enabled, available, active, phase, sequence, duration and elapsed; non-none phases also include canonical vehicle and seat. Phases are none, entering, active, exiting. active includes both transitions. duration/elapsed are seconds. Remote data must be fresh with an attached presented occupant body; unavailable data has phase none. Remote enabled reflects server policy, not another client's local resource restrictions. Returns nil, reason for unavailable players or invalid arguments. Use matching Unstable 2.31.21-unstable+op77.118 client and server (protocol 1.43), including the animation assets. Passenger support was introduced in .117; car and motorcycle drivers require .118. See Vehicle drive-by. Adds mode (passenger, car_driver, bike_driver) and driverYaw/driverPitch/driverRoll in degrees relative to the seated pose. Drivers use front_left and phase active with zero duration/elapsed. Only interpret mode while active; inactive data defaults to passenger with zero angles.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | 0 |
Returns
- state table or nil
- reason on failure
Example
CreateThread(function()
local state, reason = Open77.players.getDriveByState()
if state and state.available then print(state.phase, state.vehicle, state.seat)
elseif not state then print(reason) end
end)Passenger drive-by guide · Registered in ResourceHost.cpp as LuaReadDriveBy (line 12379).
getHealthState
Open77.players.getHealthState([playerId])Reads one replicated player health snapshot.
Requires players.life.read. Omit playerId for the local player.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- table { playerId, revision, health, maxHealth, armor, godMode, lastAttacker, lastDamage, lastAttackKind, lastBodyPart, lastHitDirection }, or nil
Example
-- A simple health bar for the local player
SetTick(function()
local hp = Open77.players.getHealthState()
if hp then healthBar.set(hp.health / hp.maxHealth, hp.armor) end
end)Players around you (client) · Registered in ResourceHost.cpp as LuaPlayerHealthState (line 25151).
getHoloCallEyes
Open77.players.getHoloCallEyes([playerId])Read the server-replicated blue eye-glow intent in the current routing bucket.
Requires players.holocall.read. Omit playerId for the local network player. Returns nil, state_unavailable before the initial server snapshot. False means absent from this client's active bucket snapshot; it is not a cross-bucket global query or proof that native pixels are rendered. There is intentionally no client setter. See holocall-eyes.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean enabled, or nil, reason
Example
-- Draw the "on a call" icon over players whose eyes glow
local glowing = Open77.players.getHoloCallEyes(playerId)
if glowing then showCallIcon(playerId) endBlue holocall eyes guide · Registered in ResourceHost.cpp as LuaPlayerHoloCallEyes (line 25146).
getLifeState
Open77.players.getLifeState([playerId])Reads the canonical replicated life state of one player.
Requires players.life.read. Omit playerId for the local session player.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- life snapshot, or nil
Example
-- Show the death screen only when the server says we are dead
local life = Open77.players.getLifeState()
if life and life.phase ~= "alive" then showDeathScreen() endPlayers around you (client) · Registered in ResourceHost.cpp as LuaPlayerLifeState (line 25147).
getLocalDeathContext
Open77.players.getLocalDeathContext()Reads the local player's replicated death context.
Requires players.life.read. The snapshot includes phase, cause, killer, weapon, position, yaw, impulse, revision and grace duration.
Returns
- life snapshot, or nil
Example
-- Tell the player who killed them
RegisterNetEvent("hud:died", function()
local death = Open77.players.getLocalDeathContext()
if death and death.killer then
Open77.hud.notify("Killed by player " .. tostring(death.killer))
end
end)Players around you (client) · Registered in ResourceHost.cpp as LuaLocalDeathContext (line 25148).
getModel
Open77.players.getModel([playerId])Read this client's NPC presentation state for a player.
Requires players.model.read. Omit playerId or pass nil for the local player; an explicit ID must be a positive integer. Returns nil without an error for the original character, or a table with player, record, appearance, revision, entity, ready, status and optional failure. The entity handle is local and disposable, never a network player ID. Status is preparing, active, parked, not_streamed or failed. Cosmetic NPC presentation only: the real player retains identity, controls, health, equipment and saved appearance. Character.* records resolve against each client's installed game data, not a virtual allowlist. See player-models.md for ownership, events, cleanup and the known special-rig/vehicle limitations.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- table? state
- string? reason
Example
local model, reason = Open77.players.getModel()
if model then print(model.record, model.ready, model.status) endPlayer morphs and model lifecycle guide · Registered in ResourceHost.cpp as LuaPlayerModel (line 25140).
getVehicleSeat
Open77.players.getVehicleSeat([playerId])Reads a replicated player's canonical vehicle-seat assignment.
Alias of Open77.vehicles.getPlayerSeat, exposed under the player namespace. Requires vehicles.read; omitting playerId selects the local player.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer|string | optional | — |
Returns
- table { playerId, vehicleId, seat (the canonical name only: seat_front_left, seat_front_right, seat_back_left or seat_back_right -- never driver or passenger, which are accepted aliases, not reported ones), flags (integer bitfield), entering, exiting, forcedEntry, exitLocked, forcedExit (booleans); the client copy adds animatedEntry and occupants }, or nil when the player is not assigned to a vehicle
Example
-- Is another player in a vehicle right now?
local seat = Open77.players.getVehicleSeat(playerId)
if seat then print("player", playerId, "is in vehicle", seat.vehicleId, "seat", seat.seat) endPlayers around you (client) · Registered in ResourceHost.cpp as LuaVehicleGetPlayerSeat (line 25153).
isAiming
Open77.players.isAiming([playerId])Graph-produced aiming state, including toggle aim.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- A stealth mission: warn when the player raises their weapon near the guards
SetTick(function()
if Open77.players.isAiming() and nearGuards then
Open77.hud.notify("Lower your weapon", { replace = true })
end
end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12366).
isCrouching
Open77.players.isCrouching([playerId])Crouched locomotion state.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- Sneaking bonus: quieter footsteps while crouched
if Open77.players.isCrouching() then noiseLevel = 0.3 endPlayer checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12368).
isDead
Open77.players.isDead([playerId])Whether a player is canonically dead or awaiting revive/respawn.
Requires players.life.read. Omit playerId for the local player. Unknown or unavailable states return false.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean
Example
-- Hide the HUD while the local player is dead
SetTick(function()
Open77.hud.setVisible("all", not Open77.players.isDead())
end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerIsDead (line 25149).
isDiving
Open77.players.isDiving([playerId])Native underwater swimming state.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- Warn about the oxygen the moment the player goes under
SetTick(function()
if Open77.players.isDiving() then Open77.hud.notify("Watch your oxygen", { replace = true }) end
end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12365).
isDriveByEnabled
Open77.players.isDriveByEnabled([playerId])Reads the effective vehicle drive-by permission.
Client; requires players.read. Omit playerId or use 0 for the local player. Reads the enabled field of getDriveByState: local resource restrictions combine with server policy; remote reads report only server policy. True permits native vehicle combat but does not mean the player is currently in it. Returns nil, reason for an unavailable player or invalid arguments. Use matching Unstable 2.31.21-unstable+op77.118 client and server (protocol 1.43), including the animation assets. Passenger support was introduced in .117; car and motorcycle drivers require .118. See Vehicle drive-by.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | 0 |
Returns
- boolean enabled or nil
- reason on failure
Example
CreateThread(function()
local enabled, reason = Open77.players.isDriveByEnabled()
if enabled == nil then print(reason) else print("Drive-by allowed:", enabled) end
end)Passenger drive-by guide · Registered in ResourceHost.cpp as LuaReadDriveBy (line 12379).
isDriver
Open77.players.isDriver([playerId])Mounted in the driver seat.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- The radio key only works for the driver
RegisterKeyMapping("car_radio", "Car radio", "R", function()
if Open77.players.isDriver() then toggleRadio() end
end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12371).
isFalling
Open77.players.isFalling([playerId])Falling phase.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- Deploy the parachute automatically on a long fall
SetTick(function()
if Open77.players.isFalling() and not chuteOpen then openChute() end
end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12370).
isGrounded
Open77.players.isGrounded([playerId])Locomotion ground contact.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- The dash key only works from the ground
RegisterKeyMapping("dash", "Dash", "SHIFT", function()
if Open77.players.isGrounded() then dash() end
end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12367).
isInDriveBy
Open77.players.isInDriveBy([playerId])Reports whether a player is entering, using or leaving window combat.
Client; requires players.read. Omit playerId or use 0 for the local player. True for entering, active or exiting; false for none or stale action data. Use getDriveByState().phase == "active" when only the combat loop is relevant. Returns nil, reason for an unavailable player or invalid arguments. Use matching Unstable 2.31.21-unstable+op77.118 client and server (protocol 1.43), including the animation assets. Passenger support was introduced in .117; car and motorcycle drivers require .118. See Vehicle drive-by.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | 0 |
Returns
- boolean active or nil
- reason on failure
Example
CreateThread(function()
local active, reason = Open77.players.isInDriveBy()
if active == nil then print(reason) else print("Window action:", active) end
end)Passenger drive-by guide · Registered in ResourceHost.cpp as LuaReadDriveBy (line 12379).
isInVehicle
Open77.players.isInVehicle([playerId])Native vehicle mounting state.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- Show the speedometer only while in a vehicle
SetTick(function()
speedometer.visible = Open77.players.isInVehicle() == true
end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12371).
isJumping
Open77.players.isJumping([playerId])Jump or double-jump phase.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- Count jumps for a parkour score
local lastJumping = false
SetTick(function()
local jumping = Open77.players.isJumping()
if jumping and not lastJumping then jumps = jumps + 1 end
lastJumping = jumping == true
end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12370).
isLocalPuppetVisible
Open77.players.isLocalPuppetVisible()Reads the combined local-avatar visibility request.
Client-only; requires players.local.visibility and takes no arguments. False means at least one resource holds a hide. True means no resource requests hiding; it does not force third person or prove a body is rendered. Returns the current combined policy immediately, while rendering follows on the game tick. Returns nil, reason when unavailable or permission is denied; unexpected arguments return unexpected_arguments. See Local player visibility.
Returns
- boolean visible or nil
- reason on failure
Example
CreateThread(function()
local visible, reason = Open77.players.isLocalPuppetVisible()
if visible == nil then print(reason) else print("Local avatar visible:", visible) end
end)Local player visibility & Prop Hunt · Registered in ResourceHost.cpp as LuaIsLocalPuppetVisible (line 12394).
isModelReady
Open77.players.isModelReady([playerId])Check whether the model is ready on this client.
Requires players.model.read. Omitted/nil playerId selects the local player; explicit IDs must be positive integers. False means no active ready model, including the original character; nil, reason indicates failure. This is local projection readiness, not an acknowledgement from every observer. Cosmetic NPC presentation only: the real player retains identity, controls, health, equipment and saved appearance. Character.* records resolve against each client's installed game data, not a virtual allowlist. See player-models.md for ownership, events, cleanup and the known special-rig/vehicle limitations.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean? ready
- string? reason
Example
local ready, reason = Open77.players.isModelReady()
if ready then print('Local presentation ready') endPlayer morphs and model lifecycle guide · Registered in ResourceHost.cpp as LuaPlayerModel (line 25142).
isModelValid
Open77.players.isModelValid(record)Validate a Character record in the client's installed game data.
Requires players.model.read. Does not spawn or animate the model. True confirms an existing Character record, not compatibility of its rig, locomotion, seats or authored appearances. Invalid inputs and absent records return false, reason; permission failures return nil, reason. Cosmetic NPC presentation only: the real player retains identity, controls, health, equipment and saved appearance. Character.* records resolve against each client's installed game data, not a virtual allowlist. See player-models.md for ownership, events, cleanup and the known special-rig/vehicle limitations.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
record | string | required | — |
Returns
- boolean? valid
- string? reason
Example
local ok, reason = Open77.players.isModelValid('Character.Rogue')
if not ok then print(reason) endPlayer morphs and model lifecycle guide · Registered in ResourceHost.cpp as LuaPlayerModelValid (line 25144).
isPassenger
Open77.players.isPassenger([playerId])Mounted in a non-driver seat.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- A passenger may use the phone while the car moves; the driver may not
if Open77.players.isPassenger() then openPhone() endPlayer checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12372).
isReloading
Open77.players.isReloading([playerId])Reloading state.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- Hide the crosshair while reloading
SetTick(function()
Open77.hud.setVisible("crosshair", Open77.players.isReloading() ~= true)
end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12367).
isShooting
Open77.players.isShooting([playerId])Graph trigger state, not confirmation of a projectile or damage.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- Is the remote player in front of us firing?
if Open77.players.isShooting(otherPlayerId) then
print("player", otherPlayerId, "is firing")
endPlayer checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12366).
isSliding
Open77.players.isSliding([playerId])Sliding locomotion state.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- Sliding through the finish line counts double
if Open77.players.isSliding() then score = score + 2 endPlayer checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12368).
isSprinting
Open77.players.isSprinting([playerId])Sprint state rather than a velocity threshold.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- Stamina drink wears off faster while sprinting
SetTick(function()
if Open77.players.isSprinting() then buffTimer = buffTimer - 2 end
end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12369).
isSwimming
Open77.players.isSwimming([playerId])Native surface-swimming or diving state.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- Drop the held item when the player enters the water
SetTick(function()
if Open77.players.isSwimming() and holdingBox then dropBox() end
end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12365).
isVaulting
Open77.players.isVaulting([playerId])Vault traversal state.
Requires players.read. Omit playerId to query the local network player. Remote players must be streamed and presentation-ready; swimming/diving are local-only and return nil, state_not_replicated remotely. Unavailable is not false. Read-only, without advancing replication counters. See player-utilities.md.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
playerId | integer | optional | — |
Returns
- boolean, or nil, reason
Example
-- Play a grunt sound on a vault
local wasVaulting = false
SetTick(function()
local vaulting = Open77.players.isVaulting()
if vaulting and not wasVaulting then Play2DSound("audio/grunt.wav") end
wasVaulting = vaulting == true
end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerPredicate (line 12369).
local
Open77.players.local()The local player's id; keyword-named alias of localId.
No permission. Identical function value to Open77.players.localId. local is reserved in Lua, so this name only parses through the bracket form Open77.players["local"](); prefer localId.
Returns
- player id
- or nil, reason
Example
-- Reachable only through the bracket form; prefer localId
local me = Open77.players["local"]()Players around you (client) · Registered in ResourceHost.cpp as LuaPlayersLocal (line 25161).
localId
Open77.players.localId()The local player's id.
No permission. Returns nil, "no_session" while not connected. Registered under local as well, for the FiveM-parity spelling, but local is a Lua keyword: Open77.players.local() is a syntax error and the name is only reachable as Open77.players["local"](). Same function value.
Returns
- player id
- or nil, reason
Example
-- Skip yourself when listing nearby players
local me = Open77.players.localId()
for _, entry in ipairs(Open77.players.nearby(20)) do
if entry.playerId ~= me then print(entry.name, entry.distance) end
endPlayers around you (client) · Registered in ResourceHost.cpp as LuaPlayersLocal (line 25160).
nearby
Open77.players.nearby(radius, [options])Players with a body within radius, nearest first.
No permission. Centred on the local player unless origin is given; ties broken by player id so the order does not flicker. Each entry is { playerId, entity, distance, position, name, isLocal }, where position is a plain x/y/z table and therefore already a vector3. Players without a body are skipped, having no position; use all() to see that they exist. Empty table when nobody qualifies. Reasons: invalid_radius, invalid_origin, invalid_limit, no_session, no_local_position (connected with no body, so no centre - pass origin to ask anyway).
Parameters 2
| Name | Type | Use | Default |
|---|---|---|---|
radius | number | required | — |
options | table { origin, includeSelf, limit } | optional | — |
Returns
- array of { playerId, entity, distance, position, name, isLocal }
- or nil, reason
Example
-- Everyone within 20 m, nearest first
for _, entry in ipairs(Open77.players.nearby(20)) do
print(("%s is %.1f m away"):format(entry.name, entry.distance))
endPlayers around you (client) · Registered in ResourceHost.cpp as LuaPlayersNearby (line 25164).
resetControls
Open77.players.resetControls()Release every player-control block owned by the calling resource VM.
Requires players.controls. Does not remove other resources' blocks or expose vanilla restriction state. See player-utilities.md.
Returns
- true, or false, reason
Example
-- The mini-game ends: release every block this resource holds
AddEventHandler("minigame:ended", function()
Open77.players.resetControls()
end)Player checks & controls guide · Registered in ResourceHost.cpp as LuaPlayerControlsReset (line 12391).
setLocalDriveByEnabled
Open77.players.setLocalDriveByEnabled(enabled)Allows or denies native vehicle drive-by for the local player.
Client-only; requires players.driveby. Call with exactly one boolean from a running resource callback/thread. False holds this resource's restriction; true releases only that restriction. Another resource or server denial still wins. Stopping or reloading the resource releases its hold; disconnect resets local holds. Disabling an active passenger requests native exit; it does not equip a weapon or force a pose. Errors include expected_boolean, resource_not_running and owner_limit. Use matching Unstable 2.31.21-unstable+op77.118 client and server (protocol 1.43), including the animation assets. Passenger support was introduced in .117; car and motorcycle drivers require .118. See Vehicle drive-by.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
enabled | boolean | required | — |
Returns
- boolean accepted
- reason on failure
Example
RegisterNetEvent("safezone:changed", function(inside)
local ok, reason = Open77.players.setLocalDriveByEnabled(not inside)
if not ok then print(reason) end
end)Passenger drive-by guide · Registered in ResourceHost.cpp as LuaSetLocalDriveByEnabled (line 12375).
setLocalPuppetVisible
Open77.players.setLocalPuppetVisible(visible)Hides or restores the player's local avatar, including third person.
Client-only; requires players.local.visibility. Accepts exactly one boolean from a running resource callback/thread. False holds the native body, held weapon and third-person double hidden while retaining the camera and movement. True releases only this resource's hold; any other hide still wins. Rendering follows on the game tick. Resource stop/reload releases its hold; death, player replacement and disconnect clear lifecycle requests. Does not affect collision, separate props, gameplay effects or what other players see. Use server players.setVisible independently for observer visibility. Errors include expected_boolean, resource_not_running, player_not_ready and visibility_owner_quota. Requires a compatible client; check function availability on older builds. See Local player visibility.
Parameters 1
| Name | Type | Use | Default |
|---|---|---|---|
visible | boolean | required | — |
Returns
- boolean accepted
- reason on failure
Example
RegisterNetEvent("prophunt:localDisguise", function(disguised)
local setVisible = Open77.players.setLocalPuppetVisible
if not setVisible then return end
local ok, reason = setVisible(not disguised)
if not ok then print(reason) end
end)Local player visibility & Prop Hunt · Registered in ResourceHost.cpp as LuaSetLocalPuppetVisible (line 12393).
// For agents & LLMsthis page as Markdownllms.txtllms-full.txt
