# xakra\_races

## Requirements

* [oxmysql](https://github.com/overextended/oxmysql)
* [vorp\_menu](https://github.com/VORPCORE/vorp_menu)
* [vorp\_core](https://github.com/VORPCORE/vorp-core-lua)
* [vorp\_inventory](https://github.com/VORPCORE/vorp_inventory-v2)

***

## Installation

1. Copy the script into a folder (to choose) from the 'resources' folder.
2. Add 'ensure xakra\_races' in the 'Resources.cfg' document.

***

## Config & Framework

<details open>

<summary>config.lua</summary>

{% code expandable="true" %}

```lua
Config = {}

Config.defaultlang = 'es'

Config.Align = 'top-left'   -- 'center', 'top-left' or 'top-right'

Config.Webhook = '' -- WEBHOOK

-- Keys: https://github.com/femga/rdr3_discoveries/tree/master/Controls
Config.KeyCancel = 'INPUT_PC_FREE_LOOK'    -- ALT
Config.KeyChangeRange = { 'INPUT_CURSOR_SCROLL_UP', 'INPUT_CURSOR_SCROLL_DOWN' }    -- MOUSE SCROLL UP and MOUSE SCROLL DOWN
Config.KeyChangeObject = { 'INPUT_GAME_MENU_LEFT', 'INPUT_GAME_MENU_RIGHT' }    -- LEFT ARROW UP and RIGHT ARROW
Config.KeyNewCheckpoint = 'INPUT_CREATOR_ACCEPT'  -- ENTER
Config.KeyDelLastCheckpoint = 'INPUT_GAME_MENU_CANCEL'  -- BACKSPACE
Config.KeyCreateRacer = 'INPUT_INTERACT_POS'  -- R

Config.KeyStartRace = 'INPUT_GAME_MENU_OPTION'  -- SPACE
Config.KeyRegisterRace = 'INPUT_CREATOR_ACCEPT'  -- ENTER

-- Colors modifiers: https://github.com/femga/rdr3_discoveries/tree/master/useful_info_from_rpfs/blip_modifiers
Config.ColorBlips = 'BLIP_MODIFIER_MP_COLOR_11'
Config.ColorFlagBlips = 'BLIP_MODIFIER_MP_COLOR_20'

-- Colors: https://github.com/femga/rdr3_discoveries/tree/master/useful_info_from_rpfs/colours
Config.ColorGPS = 'COLOR_PLATFORM_GREEN'

Config.ShareNames = 'Name' -- 'Name' (Show id and first and last name) or 'Steam' (Show id and steam name) or false (Only the player ID will be shown)

Config.RaceManager = {
    Jobs = { -- Jobs required to use the menu or false
        'racecreator',
        -- 'example',
    },
    Groups = {  --  List of groups or false
        'admin',
        -- 'example',
    },
    Command = 'race',   -- Command to open the menu
    Items = {   -- Items to open the menu
        'racecreator',
        -- 'example',
    },
    Objects = {
        { Object = 'mp001_p_mp_pickup_barrel_logo17x', Type = 'side', Smoke = true },
        { Object = 's_splitfirelog02x', Type = 'side', Smoke = true },
        { Object = 'mp001_p_mp_finishline_bonfire02x', Type = 'side', Smoke = true },
        { Object = 'mp001_p_racesignpost03x', Type = 'side', Smoke = true },
        { Object = 'mp001_p_racesignpost04x', Type = 'side', Smoke = true },
        { Object = 'mp001_p_racesignpost15x', Type = 'side', Smoke = true },
        { Object = 'mp001_s_mp_racecheckflag01x', Type = 'side', Smoke = true },
        { Object = 'mp001_s_mp_racecheckflag02x', Type = 'side', Smoke = true },
        { Object = 'mp001_s_mp_racefinishflag01x', Type = 'side', Smoke = true },
        { Object = 'mp006_s_racexmasflag01x', Type = 'side', Smoke = true},
        { Object = 'mp001_p_mp_finishlinefire01x', Type = 'side', Smoke = true },
        { Object = 'mp001_s_mp_finishline_banner01x', Type = 'side', Smoke = true },

        { Object = 'mp001_p_mp_jump_barrellong01', Type = 'jump', Smoke = false },
        { Object = 'mp001_p_mp_jump_barrelshort01', Type = 'jump', Smoke = false },
        { Object = 'mp001_p_mp_jump_dock01', Type = 'jump', Smoke = false },
        { Object = 'mp001_p_mp_jump_fencelong01', Type = 'jump', Smoke = false },
        { Object = 'mp001_p_mp_jump_fenceshort02', Type = 'jump', Smoke = false },
        { Object = 'mp001_p_mp_jump_haybalelong01', Type = 'jump', Smoke = false },
        { Object = 'mp001_p_mp_jump_haybaleshort01', Type = 'jump', Smoke = false },
        { Object = 'p_jumphurdles01x', Type = 'jump', Smoke = false },
    },
    RangeObjects = {    -- List of ranges that can be used in the distance between control point objects
        2,
        4,
        6,
    },
    StartNotification = true,   -- true (Enable notification when starting a race) or false (Disable notification when starting a race)
    DrawGo123 = true,   -- true (Enable Go123 numbers when starting the race) or false (Disable Go123 numbers when starting the race)
}

Config.SmokeColor = { r = 79, g = 124, b = 0 }  -- RGB Color (min = 0, max = 255)
Config.Go123Color = { r = 0, g = 128, b = 0 }  -- RGB Color (min = 0, max = 255)
Config.StatsRiceAlign = { x = 0.9, y = 0.7 }    -- (min 0.0/ max 1.0)
Config.DrawSpriteColor = {
    Background = { r = 0, g = 0, b = 0 },  -- RGB Color (min = 0, max = 255)
    Header = { r = 255, g = 255, b = 255 },  -- RGB Color (min = 0, max = 255)
}
-- COLORS: https://github.com/femga/rdr3_discoveries/tree/master/useful_info_from_rpfs/colours
Config.EndTimeColors = {
	Icon = 'COLOR_PLATFORM_GREEN',
	Progress = 'COLOR_PLATFORM_GREEN',
}

Config.TimeEndRace = 60 -- (seconds) Time the runners will have to reach the finish line when the first player arrives
```

{% endcode %}

</details>

<details open>

<summary>framework</summary>

client.lua

{% code expandable="true" %}

```lua
TriggerEvent("vorp_menu:getData", function(call)
    MenuData = call
end)
```

{% endcode %}

server.lua

{% code expandable="true" %}

```lua
local VORPcore = exports.vorp_core:GetCore()

local VORPInv = exports.vorp_inventory:vorp_inventoryApi()

function NotifyTip(source, text, time)
    VORPcore.NotifyTip(source, text, time)
end

function NotifyObjective(source, text, time)
    VORPcore.NotifyObjective(source, text, time)
end

function NotifyAvanced(source, title, dict, icon, color, time)
    VORPcore.NotifyAvanced(source, title, dict, icon, color, time)
end

function NotifySimpleTop(source, title, subtitle, time)
    VORPcore.NotifySimpleTop(source, title, subtitle, time)
end

function GetCharacter(source)
    -- .job
    -- .group
    -- .identifier
    -- .charIdentifier
    -- .money
    -- .firstname
    -- .lastname
    return VORPcore.getUser(source).getUsedCharacter
end

function GetCharacterJob(source)
    return Player(source).state.Character and Player(source).state.Character.Job
end

function GetCharacterName(source)
    return {
        FirstName = Player(source).state.Character and Player(source).state.Character.FirstName,
        LastName = Player(source).state.Character and Player(source).state.Character.LastName,
    }
end

function removeCurrency(source, currency, amount)
    local Character = GetCharacter(source)
    Character.removeCurrency(currency, amount)
end

function addCurrency(source, currency, amount)
    local Character = GetCharacter(source)
    Character.addCurrency(currency, amount)
end

function RegisterUsableItem(item, cb)
    VORPInv.RegisterUsableItem(item, function(data)
        return cb(data)
    end)
end

function AddWebhook(title, webhook, description, color, name, logo, footerlogo, avatar)
    VORPcore.AddWebhook(title, webhook, description, color, name, logo, footerlogo, avatar)
end
```

{% endcode %}

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xakra-scripts.gitbook.io/xakra-scripts-docs/redm-docs/xakra_races.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
