Skip to main content

Introduction

Client events are essential for handling player-specific actions, UI updates, and local game state changes in RSG Framework. They run on each playerโ€™s machine and allow for responsive, individualized gameplay experiences.
Client events run locally on each playerโ€™s machine and can be triggered by the server using TriggerClientEvent or by other client-side code using TriggerEvent.

How It Works

Event Flow

Or locally:

Registering Events

Client events are registered using RegisterNetEvent:
Client events are not synchronized between players. Each playerโ€™s client runs independently!

Core Lifecycle Events

RSGCore:Client:OnPlayerLoaded

Triggered when a player successfully loads into the server after character selection. This is the most important event for initializing player-specific client-side features.
Use Cases:
  • Initialize HUD elements
  • Start player status monitors
  • Load player-specific blips/markers
  • Set up keybinds
  • Initialize job-specific UI
  • Restore player settings
Complete Example:

RSGCore:Client:OnPlayerUnload

Triggered when a player logs out or returns to character selection. Use this to clean up client-side data and stop threads.
Use Cases:
  • Stop running threads
  • Clear temporary blips/markers
  • Reset UI to default state
  • Save client-side settings
  • Clean up job-specific features
Complete Example:

Player Data Events

RSGCore:Player:SetPlayerData

Triggered whenever player data changes (job update, money change, metadata update, etc.). Essential for keeping UI synchronized with server data.
Use Cases:
  • Update HUD when money changes
  • Refresh job display when job updates
  • Update status bars when metadata changes
  • Sync inventory UI
  • Update player name displays
Complete Example with Specific Updates:

Job & Duty Events

RSGCore:Client:OnJobUpdate

Triggered when a playerโ€™s job changes.
Complete Example:

RSGCore:Client:SetDuty

Triggered when a playerโ€™s duty status changes.

Vehicle Events

RSGCore:Command:SpawnVehicle

Spawns a vehicle near the player.
Trigger from Server:
Trigger from Client:

RSGCore:Command:DeleteVehicle

Deletes the vehicle the player is in or near.
Trigger from Command:

Item & Inventory Events

RSGCore:Client:UseItem

Triggered when a player uses an item. Often called by the server after validation.
Complete Example with Progress Bar:

System Events

RSGCore:Client:PvpHasToggled

Triggered when PVP mode is enabled or disabled for the player.

RSGCore:Client:UpdateObject

Used to refresh the RSGCore object when using shared exports. Important for hot-reloading.
This event is automatically triggered when rsg-core restarts. Include it in your resources to support hot-reloading!

Notification Events

Common Notification Pattern


Best Practices

1. Always Get Fresh PlayerData

2. Clean Up on Player Unload

3. Use Progress Bars for Actions

4. Validate Before Processing


Common Patterns

Pattern 1: Animation with Callback

Pattern 2: Proximity Activation

Pattern 3: Status Monitor


Troubleshooting

Event Not Triggering

Some events only work after RSGCore:Client:OnPlayerLoaded
Event names are case-sensitive and must match exactly
Press F8 to open client console and look for error messages

PlayerData is Nil

UI Not Updating


Summary


Next Steps


Need more help? Join the RSG Framework Discord!