tw.player
Side: Client | Alias: tw.pl
Auto-updated player information, refreshed every 100ms. Provides quick access to the local player's ped, coordinates, and identity.
Properties
| Property | Type | Description |
|---|---|---|
tw.player.ped | integer | Current player ped handle |
tw.player.coords | vector3 | Current player world coordinates |
tw.player.player_id | integer | Local player ID |
tw.player.server_id | integer | Server-side player ID (source) |
tw.player.is_male | boolean | Whether the player model is male |
Callable
tw.player() can be called directly as a function. It returns tw.player.ped.
lua
local ped = tw.player()
-- equivalent to tw.player.pedFunctions
tw.player.force_update()
Forces an immediate refresh of all player properties. Fires the twinded_libs:player:update event after updating.
lua
tw.player.force_update()
-- tw.player.coords is now guaranteed up-to-datetw.player.move(callback, interval?)
Registers a callback that fires when the player moves. The callback is called immediately on first registration with the current position. Multiple callbacks can be registered.
| Parameter | Type | Default | Description |
|---|---|---|---|
callback | function | — | Called with updated player data on movement |
interval | integer? | — | Custom poll interval in ms |
lua
tw.player.move(function()
print("Player moved to", tw.player.coords)
end)tw.player.did_move_since(id) -> boolean
Checks whether the player has moved since the last time this function was called with the given id. Each id tracks its own position independently.
| Parameter | Type | Description |
|---|---|---|
id | string | Unique identifier for this movement check |
Returns: boolean — true if the player moved since the last call with this id.
lua
if tw.player.did_move_since("my_feature") then
print("Player moved since last check")
endExamples
Access player info
lua
tw.ready(function()
print("Server ID:", tw.player.server_id)
print("Position:", tw.player.coords)
print("Is male:", tw.player.is_male)
end)React to player movement
lua
tw.player.move(function()
-- Update nearby markers, refresh UI, etc.
local pos = tw.player.coords
-- ...
end)Use as function shorthand
lua
local ped = tw.player()
SetEntityHeading(ped, 180.0)Events
| Event | Description |
|---|---|
twinded_libs:player:update | Fired after force_update() completes |
Notes
- Properties are updated automatically every 100ms in a background thread.
tw.player()is a shorthand fortw.player.pedand can be used anywhere a ped handle is expected.did_move_sinceis useful for throttling expensive operations that only need to run when the player changes position.

