# Lottery

## Installation

* Works with [RedEM:RP](https://github.com/RedEM-RP) and [VORP](https://github.com/VORPCORE). Be sure you installed one of them before to use this script.
* You need to have 2 utility scripts. These will be provided by discord
  * redemrp\_menu\_base
  * uiprompt
* Drag and drop the resource in your resources folder
  * lumen\_lottery
* Add this ensure in your server.cfg below under all utility scripts (uiprompt,xsound etc)
  * `ensure` lumen\_lottery
* Edit the config.lua to make sure to customize the code

If you have any questions, please contact our lumen works discord.

## Framework

```lua
Config.framework = "redemrp"
```

You can set the framework you need. The available options are "redemrp" or "vorp".

## Language

````lua
```lua
Config.Text = {
    [1] = "Talk",
    [2] = "Buy coupons",
    [3] = "See my coupons",
    [4] = "See previous rewards",
    [5] = "Claim rewards",
    [6] = "Explanation",
    [7] = "Choose how many tickets you want to buy",
    [8] = "Price per coupon: $",
    [9] = "Number: ",
    [10] = "Lottery",
    [11] = "Category: ",
    [12] = "You can't afford it",
    [13] = "Purchase done. Use the See coupons option to see your coupons",
    [14] = "You have reached the maximum number of coupons allowed for this category",
    [15] = "You have no tickets in this category",
    [16] = "Prize claimed",
    [17] = "No record of previous prizes",
    [18] = "You have no prizes to claim",
    [19] = "Date: ",
    [20] = " lottery prizes have been distributed, visit the vendor to see if you are a winner",
    [21] = "Distribute prize: ",
}
```
````

## Vendor Configuration

````lua
```lua
Config.Npcs = {

    { 
        coords = vector3(-791.500, -1320.89, 43.639),
        createNpc = true,
        model = "s_m_m_sdticketseller_01",
        heading = -67.97882080078,
        createblip = true,
        blipName = "Vendor 1",
        blipHash = -1656531561, 
        sellLottery = {1,2}
    }, 
```
````

Here you can add as many vendors as you want and you can customize it

* coords: Coordinates to open the lottery manager
* createNpc: True if you want the code to create a ped npc
* model: Ped model
* heading: Ped heading
* createblip: True if you want a blip to be shown on the map
* blipName: Name of the blip
* blipHash: hash for blip
* sellLottery:  Specifies which lottery categories this manager can sell (more information about the categories in the "Loterry Category Configuration" section.

## Notifications

<pre class="language-lua"><code class="lang-lua">Config.notifyServer = function(text,src)
<strong>    TriggerClientEvent('redem_roleplay:ShowObjective',src, text, 4000)
</strong>end
</code></pre>

You can set your custom notification system here, by default redemrp is added

## Lottery Category Configuration

````lua
```lua
Config.TableLottery = {
    [1] = {
        name = "Red Lottery",
        priceCoupon = 3,
        numbersTotalLottery = {min = 1000, max = 1100},
        drawDay = {day = "Monday", hour = 15},
        maxCoupon = 3,
        reward = {
            money = 10, 
            items = {itemname = "bread", qty = 1},
        },
    },
     }, 
```
````

Here you can create as many lottery categories as you need.

* name: Lottery category name
* priceCoupon: Price of each coupon
* numbersTotalLottery: Maximum number of coupons for each category
* drawDay:  Here you can set the date and time of the prize distribution
  * day: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
  * hour: 00 to 23
* maxCoupon: Maximum number of coupons allowed per player and per category
* reward: Specify the award for the category.
  * money: Money added, in case you do not want to give money as a prize, add the value 0
  * items: Add an object as a prize.&#x20;

## Others params

```lua
Config.button = "INPUT_INTERACT_ANIMAL"
Config.webhook = ""
Config.info = 'Here you can detail the information of your lottery categories and general operation to the players.'

```
