fivem icon indicating copy to clipboard operation
fivem copied to clipboard

Implement Server Setters; RPC are broken

Open spacevx opened this issue 5 months ago • 40 comments

Feature Request: Server Setters for Authority and Stability

Background

For a considerable time, many developers have been requesting Server Setters as an alternative to RPC natives. It's widely acknowledged in the FiveM community that RPC natives are often unstable or broken.

@prikolium-cfx mentioned the reliability issues of RPC natives in this pull request.

Current Issues

  1. Unreliability of RPC Natives:

    • Blip natives work approximately 20% of the time.
    • SetPedConfigFlag and vehicle RPC natives frequently require workarounds. (when they work)
    • Developers often need to implement delays to ensure entity existence before manipulation.
  2. Lack of Server Authority:

    • Current methods heavily rely on client-side operations, reducing server control.
  3. Code Cleanliness:

    • Reliance on RPC natives often leads to complex, less maintainable code.

Proposed Solution

Implement a comprehensive set of Server Setters to complement existing server-side functions.

Current Server-Side Functions

  • CreateVehicleServerSetter
  • CreatePed
  • CreateObjectNoOffset

While these are beneficial, they are insufficient for a robust server API.

Requested Server Setters

Please note that this list is not exhaustive and is intended to provide examples of the types of setters that would be useful:

Entity Setters

  • SetEntityHeading
  • SetEntityCoords
  • SetEntityRotation
  • SetEntityVelocity

Vehicle Setters

  • SetVehicleNumberPlateText
  • SetVehicleDoorsLocked

Vehicle Modification Setters

  • GetVehicleMod
  • GetVehicleModKit
  • GetVehicleModKitType
  • GetVehicleModVariation
  • SetVehicleMod
  • SetVehicleModKit

Benefits

  1. Server Authority:

    • Direct server control over entity properties and behaviors.
  2. Improved Stability:

    • Reduction in reliance on unstable RPC natives.
  3. Cleaner Code:

    • Simplified server-side logic without complex client-side workarounds.
  4. Better Synchronization:

    • Potential for improved entity sync across clients.

Use Cases

  1. Vehicle Management:

    • Server can directly modify vehicle properties (e.g., locking doors, changing plates) without client intervention.
  2. NPC Behavior Control:

    • Precise control over NPC movements and actions from the server.
  3. Anti-Cheat Measures:

    • Server can validate and correct entities properties to prevent client-side manipulation.
  4. Manipulating multiple entities :

    • Server can orchestrate complex scenarios by manipulating multiple entities simultaneously.

Expected result

Server setters

Reproduction steps

  1. Use RPC natives
  2. See rpc natives are broken
  3. Use weird workaround to use them or directly use client side code

Importancy

There's a workaround

Area(s)

FiveM, FXServer, OneSync, Natives

Specific version(s)

Every version

Additional information

No response

spacevx avatar Sep 12 '24 15:09 spacevx