ESX Framework Core

repository·main·Indexed 19 days ago

https://github.com/esx-framework/esx_core

Core components for the ESX Legacy framework for FiveM roleplay servers. Includes resources for identity management (esx_identity), multi-character systems (esx_multicharacter), player skins (esx_skin, skinchanger), notifications (esx_notify, esx_textui), progress bars (esx_progressbar), and a cron task scheduler.

Tokens
34.7K
Snippets
150
Records
182
Agent score
63%

What's inside esx_core

  1. Overview of [ESX] Multi-Character

    main

    The esx_multicharacter resource provides a system that allows players to manage and switch between multiple characters.

    Key features include:

    • Configurable Slots: You can set a global character limit for all players using Config.Slots.
    • Individual Slot Management: Administrators can manage specific player character counts using commands.
    • Automatic Cleanup: When a character is deleted, the system automatically handles the removal of entries from the database tables, so no manual database cleanup is required.
  2. Overview of ESX Legacy

    main
    ESX Legacy is a leading framework for FiveM roleplay servers, used by over 12,000 communities. It provides the core infrastructure required to build and manage high-quality roleplay environments. For technical implementation details, developers should refer to the official documentation.
  3. Format text with color codes and line breaks

    main

    The notification system supports color coding and line breaks within the message string using specific tokens.

    Color Codes:

    • ~r~: Red
    • ~b~: Blue
    • ~g~: Green
    • ~y~: Yellow
    • ~p~: Purple
    • ~c~: Grey
    • ~m~: Dark Grey
    • ~u~: Black
    • ~o~: Orange

    Line Breaks:

    • ~br~: Inserts a line break in the message.

    Example:

    ESX.ShowNotification("You received ~br~1x ~g~ball~s~!", "success", 3000, "Item Received")
    ESX.ShowNotification("I i ~r~love~s~ donuts", "success", 3000)
    
    -- Line break example
    ESX.ShowNotification("You received ~br~1x ~g~ball~s~!", "success", 3000, "Item Received")
  4. How the ESX default menu system works

    main

    The default menu system ("default") is a client-side UI managed via NUI (Native User Interface). It operates on a namespace and name basis to track multiple open menus.

    When a menu is opened, it sends an openMenu action to the NUI. The system listens for NUI callbacks such as menu_submit, menu_cancel, and menu_change to trigger logic defined in the menu's registration.

    Key lifecycle events for a menu include:

    • Submit: Triggered when the user confirms a selection.
    • Cancel: Triggered when the user exits the menu.
    • Change: Triggered when the user navigates through menu elements or changes a value (like a slider).

    Input handling is managed via ESX.RegisterInput, mapping keyboard controls (ENTER, BACKSPACE, UP, DOWN, LEFT, RIGHT) to NUI messages to control menu focus and selection.

  5. Schedule tasks with `cron:runAt`

    main

    You can schedule tasks to run at specific times using the cron:runAt event. The event accepts time parameters and a callback function. The callback function receives three arguments representing the current time context: d (day), h (hour), and m (minute).

    Usage Patterns

    Run a task at a specific time every day: Pass the hour and minute to TriggerEvent. The task will execute when the server time matches those values.

    Run a task on a specific day of the week: Pass the hour and minute, then check the d (day) argument within your callback function to ensure the logic only executes on the desired day (e.g., d == 1 for Monday).

    Note: The d parameter represents the day of the week.

    -- Execute task 5:10, every day
    function CronTask(d, h, m)
      print('Task done')
    end
    
    TriggerEvent('cron:runAt', 5, 10, CronTask)
    
    -- Execute task every monday at 18:30
    function CronTask(d, h, m)
      if d == 1 then
        print('Task done')
      end
    end
    
    TriggerEvent('cron:runAt', 18, 30, CronTask)
  6. Install esx_skin

    main

    You can install esx_skin using one of the following three methods:

    Using fvm

    Run the following command to save the resource to your esx folder:

    fvm install --save --folder=esx esx-org/esx_skin

    Using Git

    Clone the repository directly into your [esx] directory:

    cd resources
    git clone https://github.com/ESX-Org/esx_skin [esx]/esx_skin

    Manually

    1. Download the source from: https://github.com/ESX-Org/esx_skin/archive/master.zip
    2. Extract the contents into your [esx] directory.
    fvm install --save --folder=esx esx-org/esx_skin
  7. Set player clothing and model with SkinChanger

    main

    Use skinchanger to apply specific clothing, accessories, and ped models to a player. It supports mp_m_freemode_01 (male) and mp_f_freemode_01 (female) models and all Ped Features.

    To apply a skin, you must first load the appropriate freemode model using skinchanger:loadDefaultModel, then apply the skin data using skinchanger:loadSkin.

    local isMale = true
    
    local skin = {
     sex          = 1,
     face         = 0,
     skin         = 0,
     beard_1      = 0,
     beard_2      = 0,
     beard_3      = 0,
     beard_4      = 0,
     hair_1       = 0,
     hair_2       = 0,
     hair_color_1 = 0,
     hair_color_2 = 0,
     tshirt_1     = 0,
     tshirt_2     = 0,
     torso_1      = 0,
     torso_2      = 0,
     decals_1     = 0,
     decals_2     = 0,
     arms         = 0,
     pants_1      = 0,
     pants_2      = 0,
     shoes_1      = 0,
     shoes_2      = 0,
     mask_1       = 0,
     mask_2       = 0,
     bproof_1     = 0,
     bproof_2     = 0,
     chain_1      = 0,
     chain_2      = 0,
     helmet_1     = 0,
     helmet_2     = 0,
     glasses_1    = 0,
     glasses_2    = 0,
    }
    
    -- 1. Load the correct freemode model
    TriggerEvent('skinchanger:loadDefaultModel', isMale)
    
    -- 2. Apply the full skin
    TriggerEvent('skinchanger:loadSkin', skin)
    
    -- Alternatively, apply only specific components:
    TriggerEvent('skinchanger:loadSkin', {
     sex          = 0,
     beard_1      = 0,
     beard_2      = 0,
    })
  8. Configure esx_skin installation

    main

    After downloading the files, complete the setup with these two steps:

    1. Database Setup: Import the esx_skin.sql file provided in the resource folder into your database.
    2. Server Configuration: Add the following line to your server.cfg to ensure the resource starts with the server:
    start esx_skin
    start esx_skin