# <img src='/images/cashregister.webp' /> Cash register Robbery
Documentation relating to the kd_robberyshop.

:::: tabs
::: tab BUY
[Buy the script](https://jumpon-studios.com/redm/cash-register-robbery)
:::

::: tab PREVIEW
<iframe width="560" height="315" src="https://www.youtube.com/embed/SFVCH-31S4A?si=hdSfSBlOr3uCDuRr" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
:::
::::

## 1. Installation
kd_robberyshop is a standalone script. So you don't need a specific framework to use it. It's also mean it works with all framework (VORP, RedEM:RP, QBCore, …).

- Drag and drop the resource in your resources folder
  - kd_robberyshop
- Add this ensure in your server.cfg
  - `ensure kd_robberyshop`
- Congratulation, the Cash register Robbery script is ready to be use !
## 2. Usage
Go near a cash register (need to be setup in the config file) and press R to rob it.
The configuration file is `config.lua` in the resource root. **Do not edit this file directly** as your changes may be lost during updates. Instead, use `overwriteConfig.lua` to store your customizations.

- **`config.lua`** - Default configuration maintained by developers. **Do not modify this file.**
- **`overwriteConfig.lua`** - This is where you place only the values you want to override.

### How to customize the configuration

1. Open `kd_robberyshop/overwriteConfig.lua`
2. Find the value you want to change in `config.lua` (e.g., `Config.language`)
3. Copy only that line into `overwriteConfig.lua`
4. Edit the copied value to your liking

The script loads `config.lua` first, then `overwriteConfig.lua` overwrites only the values you redefine. This ensures your customizations are preserved when updating the script.

`kd_robberyshop/config.lua`

```lua
Config = {}

Config.displayPrompt = true
Config.commandName = "StartRobbery" -- put false to disable the command

Config.keys = {
  start = 'INPUT_PICKUP_CARRIABLE'
}

Config.shops = {
  {
    name = "Charles De Coursey", --Name of the shop
    coords = vector3(2555.0,-1166.0,53.0), --coordinate of the shop
    distance = 2.0, --distance around the cash register to display the prompt
    minigame = true, --false to disable the lockpick minigame and use the shakeNumber
    shakeNumber = 5, --number of time player have to shake the picklock to open the cashregister (only if minigame = false)
    money = {500,1000}, --{min, max}
    cooldown = 10000 --ms
  }
}
-----------------
--Client Side
-----------------
local VORPCore = {}
local VORPInv = {}

TriggerEvent("getCore", function(core)
  VORPCore = core
end)

Config.displayTip = function(text,duration)
  VORPCore.NotifyObjective(text,duration)
end

----------------
--ServerSide
----------------

if IsDuplicityVersion() then
  VORPInv = exports.vorp_inventory:vorp_inventoryApi()
  
end

--Function to test if player can start the robbery
Config.canStartRobbery  = function(source,shopID)
  local item = VORPInv.getItem(source, "lockpick")
  -- if not item then
  --   VORPCore.NotifyObjective(source,"You need lockpick to do that",4000)
  --   return false
  -- end
  return true
end

--Function when the player fails the robbery minigame
Config.fail= function(source, shopID) 
  VORPInv.subItem(source, "lockpick", 1)
end

--Function when the robbery is stated
Config.startRobbery= function(source,shopID)
  --Fire when player start to rob the cash register
  local playerCoords = GetEntityCoords(GetPlayerPed(source))
  TriggerEvent("lawmen:policenotify",playerCoords)
end

--Function to give money to player
Config.giveMoney = function(source,money, shopID)
  local Character = VORPCore.getUser(source).getUsedCharacter
  Character.addCurrency(0, money)
end
```

`kd_robberyshop/lang.lua`

```lua
Lang = {}

Lang.NameScript = "Cash Register"
Lang.Rob = "Rob"
Lang.cashRegisterEmpty = "This cash register is empty"
Lang.Failed = "You failed to open the cash register"
Lang.noCashRegister = "No cash register around you"
```
