Functions (Generic)
Client API Documentation
Overview
This documentation covers the Client API (cAPI) functions available in the FRP Framework. The API provides essential functionality for player interactions, world manipulation, UI elements, and game mechanics.
Table of Contents
Position & Movement
Camera & Targeting
Player State
Visual Effects
UI & Text Display
Vehicle Management
Notifications
Inventory
Progress Bars
Location Services
Audio
Dimensions
Teleportation
Position & Movement
cAPI.GetPosition()
cAPI.GetPosition()Gets the current player position coordinates.
Returns:
x(number): X coordinatey(number): Y coordinatez(number): Z coordinate
Example:
cAPI.GetSpeed
cAPI.GetSpeedGets the current player movement speed (magnitude of velocity vector).
Returns:
speed(number): Current speed in game units
Example:
cAPI.GetCoords
cAPI.GetCoordsGets coordinates and heading of any entity.
Parameters:
entity(number): Entity handle
Returns:
table: Contains x, y, z coordinates and heading (a)
Example:
Camera & Targeting
cAPI.GetCoordsFromCam
cAPI.GetCoordsFromCamCalculates world coordinates from camera position at specified distance.
Parameters:
distance(number): Distance from camera
Returns:
x(number): X coordinatey(number): Y coordinatez(number): Z coordinate
Example:
cAPI.Target
cAPI.TargetPerforms raycast targeting from camera to detect entities.
Parameters:
Distance(number): Maximum raycast distancePed(number): Ped entity to ignore in raycast
Returns:
Entity(number): Hit entity (0 if none)x(number): Hit point X coordinatey(number): Hit point Y coordinatez(number): Hit point Z coordinate
Example:
Player State
cAPI.ToggleInvinsible
cAPI.ToggleInvinsibleToggles player invincibility state.
Example:
cAPI.IsPlayingAnimation
cAPI.IsPlayingAnimationChecks if player is currently playing a specific animation.
Parameters:
dict(string): Animation dictionaryanim(string): Animation name
Returns:
boolean: True if animation is playing
Example:
cAPI.ClientConnected
cAPI.ClientConnectedHandles client connection state and loading screen.
Parameters:
bool(boolean): Connection status
Example:
Visual Effects
cAPI.ForceLightningFlashAtCoords
cAPI.ForceLightningFlashAtCoordsCreates a lightning flash effect at specified coordinates.
Parameters:
x(number): X coordinatey(number): Y coordinatez(number): Z coordinate
Returns:
boolean: Success status
Example:
cAPI.PlaySkyCameraAnimationAtCoords
cAPI.PlaySkyCameraAnimationAtCoordsPlays a cinematic sky camera animation sequence ending with teleportation.
Parameters:
coords(table): Array with [x, y, z] coordinates
Example:
UI & Text Display
cAPI.DrawText
cAPI.DrawTextDraws 2D text on screen with customizable properties.
Parameters:
x(number): Screen X position (0.0 to 1.0)y(number): Screen Y position (0.0 to 1.0)width(number): Text widthheight(number): Text heightscale(number): Text scale multiplierr(number): Red color component (0-255)g(number): Green color component (0-255)b(number): Blue color component (0-255)a(number): Alpha transparency (0-255)text(string): Text to display
Example:
cAPI.DrawText3D
cAPI.DrawText3DDraws 3D text in world space with background.
Parameters:
x(number): World X coordinatey(number): World Y coordinatez(number): World Z coordinatetext(string): Text to display
Example:
cAPI.DisplayHelpText
cAPI.DisplayHelpTextDisplays help text in the game's native help system.
Parameters:
helpText(string): Help message to display
Example:
Vehicle Management
cAPI.SpawnVehicle
cAPI.SpawnVehicleSpawns a vehicle with specified parameters.
Parameters:
model(string/number): Vehicle model name or hashcb(function, optional): Callback function receiving vehicle handlecoords(table, optional): Spawn coordinates {x, y, z, a}isnetworked(boolean, optional): Whether vehicle should be networked (default: true)
Example:
Notifications
cAPI.NotifySimple
cAPI.NotifySimpleShows a simple notification message.
Parameters:
text(string): Notification texttimeout(number): Display duration in milliseconds
Example:
cAPI.Notify
cAPI.NotifyShows a notification with type and quantity.
Parameters:
type(string): Notification typetext(string): Notification textquantity(number): Quantity to display
Example:
cAPI.NotifyToast
cAPI.NotifyToastShows a toast-style notification.
Parameters:
type(string): Toast type (defaults to "dev" if only text provided)text(string): Toast textquantity(number, optional): Quantity to display
Example:
Inventory
cAPI.HasItem
cAPI.HasItemChecks if player has specified item and amount.
Parameters:
item(string): Item identifieramount(number, optional): Required amount (default: 1)
Returns:
boolean: True if player has required amount
Example:
Progress Bars
cAPI.Progressbar
cAPI.ProgressbarCreates a progress bar with customizable options.
Parameters:
name(string): Progress bar identifierlabel(string): Display labelduration(number): Duration in millisecondsuseWhileDead(boolean): Allow while deadcanCancel(boolean): Can be cancelleddisableControls(table): Controls to disableanimation(table): Animation settingsprop(table): Primary prop settingspropTwo(table): Secondary prop settingsonFinish(function): Completion callbackonCancel(function): Cancellation callback
Example:
Location Services
cAPI.GetCurrentStateName
cAPI.GetCurrentStateNameGets the current state/region name.
Returns:
string: State name ("Ambarino", "Lemoyne", "West Elizabeth", "New Austin", "New Hanover", "Guarma")
Example:
cAPI.GetCurrentTownName
cAPI.GetCurrentTownNameGets the current town/settlement name.
Returns:
string: Town name or "Cidade Fantasma" if unknown
Example:
Audio
cAPI.PlayAmbientSpeech
cAPI.PlayAmbientSpeechPlays ambient speech for a ped.
Parameters:
ped(number): Ped entity handlespeech(string): Speech identifier
Example:
Dimensions
cAPI.enterDimension
cAPI.enterDimensionEnters a specific dimension, including any transport vehicle.
Parameters:
dimensionId(number): Target dimension ID
Example:
cAPI.leaveDimension
cAPI.leaveDimensionLeaves a specific dimension, including any transport vehicle.
Parameters:
dimensionId(number): Dimension ID to leave
Example:
Utility Functions
cAPI.GetUserIdFromServerId
cAPI.GetUserIdFromServerIdConverts server ID to user ID.
Parameters:
serverid(number): Server ID
Returns:
number: User ID (0 if not found)
cAPI.GetServerIdFromUserId
cAPI.GetServerIdFromUserIdConverts user ID to server ID.
Parameters:
userid(number): User ID
Returns:
number: Server ID (0 if not found)
cAPI.GetFromCoordsFromPlayer
cAPI.GetFromCoordsFromPlayerCalculates coordinates at a specific radius from a player/ped position.
Parameters:
position(vector3): Base positionped(number, optional): Ped entity (defaults to PlayerPedId())radius(number, optional): Distance radius (default: 0.8)
Returns:
vector3: Calculated coordinates with ground Z adjustment
Error Handling and Best Practices
Thread Safety
Most functions are safe to call from any thread
Camera and teleportation functions may require main thread execution
Performance Considerations
Use
DrawText3Dsparingly in loopsCache entity handles when possible
Avoid calling expensive functions like
GetCurrentTownName()every frame
Common Patterns
This framework provides a comprehensive set of tools for RedM server development, focusing on player interaction, world manipulation, and user interface elements.
Last updated