citizenfx/natives

repository·master·Indexed 19 days ago

https://github.com/citizenfx/natives

Documentation source for the original GTA V native function database used in CFX/FiveM development. Includes detailed references for native functions, parameters, and return types across various namespaces such as APP and AUDIO.

Tokens
859.9K
Snippets
5.9K
Records
6.2K
Agent score
66%

What's inside citizenfx-natives

  1. Locate CFX namespace natives

    master

    This repository contains only the original GTA V natives. If you are looking for natives belonging to the cfx namespace, they are located in the FiveM source repository under the ext/native-decls directory.

    https://github.com/citizenfx/fivem/tree/master/ext/native-decls
  2. How to create custom patrol routes

    master

    You can define custom patrol routes by following a specific sequence of TASK commands. This allows you to control exactly where a Ped walks and how they interact with specific locations.

    Workflow:

    1. Initialize: Call TASK::CREATE_PATROL_ROUTE().
    2. Open: Call TASK::OPEN_PATROL_ROUTE(char* routeName) to start defining a specific route by name.
    3. Add Nodes: Use TASK::ADD_PATROL_ROUTE_NODE(int index, char* model, float heading, float x, float y, float z, int waitTime) to place points on the route. The waitTime parameter typically uses a random integer range to prevent robotic behavior.
    4. Link Nodes: Use TASK::ADD_PATROL_ROUTE_LINK(int fromIndex, int toIndex) to define the path between nodes. For a loop, ensure the last node links back to the first.
    5. Finalize: Call TASK::CLOSE_PATROL_ROUTE() to save the route definition.
    6. Execute: Use TASK_PATROL with the routeName used in step 2.
    TASK::CREATE_PATROL_ROUTE();
    TASK::OPEN_PATROL_ROUTE("miss_Ass0");
    TASK::ADD_PATROL_ROUTE_NODE(0, "WORLD_HUMAN_GUARD_STAND", heading, -139.40, -993.47, 26.27, MISC::GET_RANDOM_INT_IN_RANGE(5000, 10000));
    TASK::ADD_PATROL_ROUTE_NODE(1, "WORLD_HUMAN_GUARD_STAND", heading, -116.13, -987.49, 26.38, MISC::GET_RANDOM_INT_IN_RANGE(5000, 10000));
    TASK::ADD_PATROL_ROUTE_LINK(0, 1);
    TASK::ADD_PATROL_ROUTE_LINK(1, 0);
    TASK::CLOSE_PATROL_ROUTE();
  3. How to change the player's wallet money value

    master

    To modify the actual money value shown in the multiplayer wallet, do not attempt to pass a value to SET_MULTIPLAYER_WALLET_CASH. Instead, use STAT_SET_INT targeting the specific statistic key "MP0_WALLET_BALANCE".

    // Use STAT_SET_INT with "MP0_WALLET_BALANCE" to change the money value
  4. Control camera spline progress with GET_CAM_SPLINE_PHASE and SET_CAM_SPLINE_PHASE

    master
    The GET_CAM_SPLINE_PHASE native can be used in conjunction with SET_CAM_SPLINE_PHASE to create a loop or manual control over camera movement. You can retrieve the current phase using GET_CAM_SPLINE_PHASE and then use SET_CAM_SPLINE_PHASE to overwrite it with a specific float value to manipulate the camera's position along the spline.
  5. How menu contexts work in pausemenu.xml

    master

    Menu contexts are conditional states defined in pausemenu.xml that allow developers to show or hide specific menu elements (like buttons or options) based on the current game state.

    Example of context logic in pausemenu.xml: <Contexts>*ALL*, DISPLAY_CORONA_BUTTONS, *NONE*, BET_LOCKED, BET_AVAILABLE, SCROLL_OPTION</Contexts>

    In this example:

    1. Elements are active if DISPLAY_CORONA_BUTTONS is met (*ALL* logic).
    2. Elements are hidden if BET_LOCKED, BET_AVAILABLE, or SCROLL_OPTION are met (*NONE* logic).
  6. How to delete mission entities

    master

    Some objects in the game world are designated as 'mission entities', which prevents them from being deleted by standard commands. To delete a mission entity, you must follow this pattern:

    1. Check if the entity is a mission entity using IsEntityAMissionEntity(object).
    2. If it is, call SetEntityAsMissionEntity(object, false, true) to strip its mission status.
    3. Call DeleteObject(object) to remove it from the world.
    if IsEntityAMissionEntity(object) then
        SetEntityAsMissionEntity(object, false, true)
    end
    DeleteObject(object)
  7. Configure and activate the terrain grid

    master

    To display a terrain grid (specifically for golf), you must perform three steps:

    1. Activate the grid: Use TERRAINGRID_ACTIVATE to toggle the grid on or off.
    2. Set grid parameters: Use TERRAINGRID_SET_PARAMS to define the grid's location, size, rotation, normal height, and the height ratios between the minimum, normal, and maximum levels.
    3. Set grid colors: Use TERRAINGRID_SET_COLOURS to define the color scheme for the different elevation levels.
    // 1. Toggle the grid on
    N_0xa356990e161c9e65(true);
    
    // 2. Configure location, size, rotation, normal height, and height ratios
    N_0x1c4fc5752bcd8e48(-1114.121f, 220.789f, 63.78f, -1f, 0.85f, 0f, 15f, 15f, -1f, 20f, 40f, 63.78f, 0.2f);
    
    // 3. Define colors: red for lower, white for normal, yellow for higher
    N_0x5ce62918f8d703c7(255, 0, 0, 64, 255, 255, 255, 5, 255, 255, 0, 64);