Player Functions

playerfunctions.lua

This module contains helper functions for manipulating player states, interactions, and utility checks.

instantLookEnt(ent, ent2)

Instantly turns an entity to face a target (entity or coordinates) without animation.

Example:

instantLookEnt(nil, vector3(200.0, 300.0, 40.0))
instantLookEnt(ped1, ped2)

lookEnt(entity)

Makes the current player look toward the given entity.

Usually called after when opening a menu or something similar to make the player visually face the location

Example:

lookEnt(vector3(200.0, 300.0, 40.0))
lookEnt(pedEntity)

setThirst(src, thirst)

Sets the thirst level of a player.

Example:


setHunger(src, hunger)

Sets the hunger level of a player.

Example:


chargePlayer(cost, moneyType, newsrc)

Deducts money from a player of the specified type (cash, bank, etc).

Example:


fundPlayer(fund, moneyType, newsrc)

Adds money to a player's balance of a given type.

Example:


ConsumeSuccess(itemName, type, data)

Handles logic when an item is successfully consumed (e.g., food, drink, etc).

Supports hunger and thirst info directly from table eg. { hunger = 10, thirst = 20 }

Example:


hasJob(job, source, grade)

Checks if a player has a certain job and optionally checks for a specific grade.

Similar to jobCheck() but also retrieves as much player job info as possible

Example:


getPlayer(source)

Retrieves basic player information (name, cash, bank, job, etc.) based on the active core/inventory system.

Can be called server-side (passing a player source) or client-side (for current player).

Called often in my scripts as its makes use of frameworks "GetPlayerData" etc.

Example:


GetPlayersFromCoords(coords, radius)

Returns a list of players within a specified radius of a set of coordinates.

Example:


Last updated