> For the complete documentation index, see [llms.txt](https://darksouls-script-stash.gitbook.io/darksouls-script-stash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://darksouls-script-stash.gitbook.io/darksouls-script-stash/reference/texas-holdem.md). Agents can also search and read this documentation through its [MCP server](https://darksouls-script-stash.gitbook.io/darksouls-script-stash/~gitbook/mcp).

# Texas Holdem

Custom Texas Holdem Poker script for RedM by DArkSouL - now with the original RDR2 poker animations.

**\~ Made with&#x20;**<mark style="color:red;">**♥**</mark>**&#x20;and used world wide by happy players since 2022 \~**

{% hint style="info" %}
This is the documentation for **version 4** of the script. Version 4 replaces the complete animation layer: every player, the dealer, the cards, the deck and the chips now move exactly like in the poker minigame of Red Dead Redemption 2. Game logic, configuration, frameworks and events stay compatible with version 3 - see [Update to v4](https://darksouls-script-stash.gitbook.io/darksouls-script-stash/reference/texas-holdem/update-to-v4.md).
{% endhint %}

## <mark style="color:red;">Disclaimer</mark>

This script was developed for a **custom framework** in mind, which has a similar approach on getting character information (e.g. character money, character name) via events like RedEM:RP (more in the compatibility chapter).\
If you intend to use this script with other RedM frameworks, this is still possible, but you may need to write a wrapper for the internal events listed in the compatibility chapter to get the required information from your framework to the script and vice versa.

## <mark style="color:red;">Requirements</mark>

* A framework (<mark style="color:red;">**RedEM:RP, VORP, GUM, RSG-Core, QB-Core**</mark> *<mark style="color:red;">or a custom framework</mark>*) or script which can provide the following information:
  1. Character money (get + add + remove)
  2. Character name (get full name + first name)
  3. Character item check/removal (get item count and remove item functions)
* RedM server, forcing game build **1491** for clients (`sv_enforceGameBuild 1491`). Other builds are untested - the animations depend on the game's own poker assets.
* OneSync is recommended. With OneSync, table events are only sent to players near the table (see `tblLod`); without it they go to every player on the server.
* Custom card images (the script ships with a default deck style which imitates the original RDR2 cards, redone from scratch)
* Script [*<mark style="color:red;">**tm\_modals**</mark>*](https://darksoul.tebex.io/package/5377476) for displaying the rules

## <mark style="color:red;">Features</mark>

* <mark style="color:yellow;">**NEW v4**</mark> **Dealer sequences like in the game.** Shuffling, dealing to every seat, flop/turn/river, collecting the board and passing the deck to the next dealer are played as the original anim scenes and clips.
* <mark style="color:yellow;">**NEW v4**</mark> **Animated table objects.** Cards, deck and chips are moved by the animations themselves - cards land in the hands of the player, chips are pushed into the pot.
* <mark style="color:yellow;">**NEW v4**</mark> **Real chip stacks.** Four stacks in front of every player and four stacks per player in the pot, each showing up to ten chips, coloured by denomination. Stacks grow and shrink with the money.
* <mark style="color:yellow;">**NEW v4**</mark> **Your character looks at the cards** while the card camera is on your own cards, and you can **change your sitting posture** (default `Space`) - for male and female characters.
* <mark style="color:yellow;">**NEW v4**</mark> **Idle variations.** Seated players fidget and glance at their cards every 15-35 seconds, just like the NPCs in the game.
* <mark style="color:yellow;">**NEW v4**</mark> **Card camera follows your cards**, also while they are held in the hands.
* <mark style="color:yellow;">**NEW v4**</mark> **More secure:** hole cards are only sent to their owner, nobody can read other hands from the network traffic or the NUI. Players can no longer remove other players from a table, and tables can only be added or removed by server scripts.
* Immersive poker script for RedM - close to RDR2
* Set the max amount of money a player can bet each round (Limit / No Limit)
* Can be used on *<mark style="color:red;">**ANY location**</mark>* you like. It includes a custom object spawn and object deletion mechanism which makes it possible to place custom objects anywhere you like:
  * Create a poker table in the moonshine shack beside the piano? **Yep!**
  * Clear an area of objects to place a table object and chairs at places which are normally blocked? **Sure!**
  * Use MLO & YMAP mappings with this script! It works that great, that this is the recommended way!
* *<mark style="color:red;">**Highly customizable**</mark>* (locations, blips, prompts, keys, holdem modes, all texts, NUI)
* Props spawn only when a player is nearby to reduce the usage of RDR2 object limits
* Up to 6 players per table, any number of tables ***in parallel***
* Sexy animated UI. You can edit it to your needs using CSS/JS
* General events give other scripts entry points to act on wins/losses or players joining/leaving a table:
  * Example: provide job systems with wins by the dealer to gain income for their company
  * Example: deactivate metabolism while playing
* Check for an item to access a table, e.g. a VIP ticket
* Discord webhook for admins to monitor common table interactions
* Voice lines per table
* Decide for yourself which chair you want to sit on
* [Template mode](https://darksouls-script-stash.gitbook.io/darksouls-script-stash/reference/texas-holdem/background-information.md#table-template-mode) for creating new table config entries and getting exact chair coordinates for your mappings
* Included frameworks: RedEM:RP, VORP, GUM, RSG-Core, QB-Core
* [Adding/removing](https://darksouls-script-stash.gitbook.io/darksouls-script-stash/reference/texas-holdem/background-information.md#add-remove-table-entries-through-events) table entries during runtime through events, e.g. from your casino job

## <mark style="color:red;">Limitations</mark>

* The script includes nine card styles (`deckStyle` 1-9, folders `html/img/cards/playing_cards_01` to `_09`). For the original deck styles, visit [RDR3 DISCOVERIES GITHUB](https://github.com/femga/rdr3_discoveries/tree/a63669efcfea34915c53dbd29724a2a7103f822f/useful_info_from_rpfs/textures/ui_minigames/cards).
* There is no NPC dealer. The dealer button moves between the seated players, and the player holding it performs the dealer animations.
* Seated players are shown to players within `tblLod` meters of the table. Players further away see the table without them - set `tblLod` to the distance from which your table should be visible (see [Configuration File](https://darksouls-script-stash.gitbook.io/darksouls-script-stash/reference/texas-holdem/configuration-file.md)).

## <mark style="color:red;">Encryption</mark>

The script itself is mostly encrypted. You can edit the config, webhook and compatibility file for your framework (if needed), and the language files. Also all GUI related stuff is changeable (HTML/CSS/JS).

## <mark style="color:red;">Installation</mark>

* Copy **d\_texasholdem** into your resource folder

{% hint style="danger" %}
The folder name must remain `"d_texasholdem"`. The NUI and all card images are loaded from `nui://d_texasholdem/...`; with another folder name the script will not work properly.
{% endhint %}

* Add **ensure d\_texasholdem** to your server config **after** the [<mark style="color:red;">required scripts</mark>](#requirements)
* If you want to use the original Red Dead Redemption 2 poker graphics, download them from [here](https://github.com/femga/rdr3_discoveries/tree/a4b4bcd5a3006b0c1434b03e4095d038164932f7/useful_info_from_rpfs/textures/ui_minigames/cards) and place them under **`d_texasholdem\html\img\cards\`**
* **That's it.** The script starts after a fresh server restart. If you are using txAdmin and the "Resources" panel in the web GUI, click "Refresh" and start the resource from there.

## <mark style="color:red;">Compatibility</mark>

This script was written for a non public roleplay framework which has its root in RedEM:RP. To make it compatible with your framework, follow these steps:

#### <mark style="color:red;">Existing (known) frameworks:</mark>

| Framework            | Description                                                                   |
| -------------------- | ----------------------------------------------------------------------------- |
| **RedEM:RP**         | Set `Config.Framework` to `"redemrp"`, or `"redemrp2"` for the 2023 reboot    |
| **VORP**             | Set `Config.Framework` to `"vorp"` (old C# core) or `"vorp2"` (Lua core)      |
| **GUM**              | Set `Config.Framework` to `"gum"`                                             |
| **RSG-Core**         | Set `Config.Framework` to `"rsg"`, or `"rsg2"` for the newest RSG version     |
| **QB-Core**          | Set `Config.Framework` to `"qbc"`                                             |
| **other frameworks** | [<mark style="color:red;">see "custom frameworks"</mark>](#custom-frameworks) |

{% hint style="warning" %}
When you are using `rsg2`, you have to add ox\_lib as shared script in the `fxmanifest.lua` (the lines are already there, commented out). Otherwise the notifications won't work.

```lua
shared_scripts {
    '@ox_lib/init.lua',
}
```

{% endhint %}

#### <mark style="color:red;">Custom frameworks:</mark>

* If you are using a custom framework with its own functions and events, use a wrapper event to return or set the required data.
* Set `Config.Framework` to `"custom"` and adapt the wrapper in `public/compatibility.lua`.
* You can use the provided wrapper and change it to your needs. I cannot support you when you have trouble getting your custom framework working with my script - if you use a custom framework you should at least know how to do this ;)

#### <mark style="color:red;">Custom framework wrapper:</mark>

{% code fullWidth="true" %}

```lua
-- Value and function names obviously differ from what you are using.
-- In the end the script needs to call the functions within the if statement
-- to work properly, and your framework needs to return the required infos.

-- EXAMPLE CODE:
-- get your framework functions
local Framework = {}
TriggerEvent("getFrameworkCore", function(core) -- <- ADAPT THE EVENT OR REWRITE TO GET YOUR FRAMEWORK'S CORE FUNCTIONS
    Framework = core
end)

local currency = 0 -- <- ADAPT: currency id/name your framework uses for cash

AddEventHandler("d_texasholdem:custom:getCharacterFromId", function(source, cb)
    local _source = source
    local char = Framework.GetPlayer(_source) -- <- ADAPT TO RETURN THE CHARACTER OBJECT
    if char then
        local user = {}
        user.getName        = function() return char.data.firstname.." "..char.data.lastname end -- full name
        user.getFirstname   = function() return char.data.firstname end -- first name
        user.getMoney       = function() return char.func.getMoney(currency) end -- player money
        user.removeMoney    = function(amount) char.func.removeMoney(currency, amount) end -- remove money
        user.addMoney       = function(amount) char.func.addMoney(currency, amount) end -- add money
        user.getItemAmount  = function(name) return char.inventory.func.getItemCount(name) end -- item amount
        user.removeItem     = function(name, amount) char.inventory.func.removeItem(name, amount) end -- remove item
        cb(user)
    else
        cb(nil)
    end
end)
```

{% endcode %}

## <mark style="color:red;">Telemetry</mark>

For transparency: on startup, this asset sends data for identifying your server to me via a webhook. This includes the script version, the configured framework and the server information publicly available by CFX (host name, project name and description, owner, locale, game build and tags).

## <mark style="color:red;">Credits</mark>

<mark style="color:red;">@DArkSouL</mark>

<mark style="color:red;">@turbomodus (NUI stuff and base logic for game loop)</mark>
