Skip to content

refactor(esx_property): optimize property synchronization to reduce network traffic#99

Closed
ifaisal-swe wants to merge 1 commit into
esx-framework:devfrom
ifaisal-swe:main
Closed

refactor(esx_property): optimize property synchronization to reduce network traffic#99
ifaisal-swe wants to merge 1 commit into
esx-framework:devfrom
ifaisal-swe:main

Conversation

@ifaisal-swe

Copy link
Copy Markdown

Description

This PR optimizes property synchronization by sending only the updated property to clients instead of the entire Properties array. This reduces network traffic.


Motivation

Previously, any property update sent the entire Properties array to all clients. With large property files, this caused:

  • Network bandwidth spikes
  • Client-side lag during property updates
  • Server performance issues with many players

Now only the single changed property is sent, dramatically reducing network traffic.


Implementation Details

Server (server/main.lua):

  • Replaced 18 instances of TriggerClientEvent("esx_property:syncProperties", -1, Properties)
  • Now uses TriggerClientEvent('esx_property:updateProperty', -1, PropertyId, Properties[PropertyId])

Client (client/main.lua):

  • Added RegisterNetEvent("esx_property:updateProperty") handler
  • Updates only the specific property in the Properties table
  • Maintains player keys and refreshes blips

Usage Example

-- Server: Send single property update

TriggerClientEvent('esx_property:updateProperty', -1, PropertyId, Properties[PropertyId])

-- Client: Receives and updates single property

RegisterNetEvent("esx_property:updateProperty", function(PropertyId, propertyData)
    Properties[PropertyId] = propertyData
    RefreshBlips()
end)

PR Checklist

  • My commit messages and PR title follow the Conventional Commits standard.
  • My changes have been tested locally and function as expected.
  • My PR does not introduce any breaking changes.
  • I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.

When properties are updated (bought, sold, modified), the server was sending
the entire Properties array to all clients, causing significant network lag
with large property files or many players online.

Changes:
- Added new client event handler `esx_property:updateProperty` that updates
  only the specific property instead of syncing all properties
@CLAassistant

CLAassistant commented Nov 16, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@ifaisal-swe ifaisal-swe closed this by deleting the head repository Dec 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants