Skip to content

Commit

Permalink
Add MDT
Browse files Browse the repository at this point in the history
  • Loading branch information
KadDarem committed Apr 25, 2024
1 parent b3a241b commit 70b95bf
Show file tree
Hide file tree
Showing 2 changed files with 167 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export default defineConfig({
{ text: "🐎 Horse and Wagon sharing", link:'/RedM/horse-and-wagon-sharing'},
{ text: "🦌 Hunting wagon Storage", link:'/RedM/hunting-wagon-storage'},
{ text: "🔪 Knife game", link:'/RedM/knife-game'},
{ text: "🗒 MDT", link:'/RedM/mdt'},
{ text: "🖱️ Mouse selection", link:'/RedM/mouse-selection'},
{ text: "🐴 Stable", link:'/RedM/stable', items: [
{ text: 'Main script', link: '/RedM/stable'},
Expand Down
166 changes: 166 additions & 0 deletions docs/RedM/mdt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# 🗒 MDT
Documentation relating to the jo_mdt.

:::tabs
== BUY
[Buy the script](https://shop.jumpon-studios.com/redm/sheriff-mdt)
== PREVIEW
Coming soon
:::

## 1. Installation
To install jo_mdt:
- Drag and drop the resource into your resources folder
- jo_mdt
- Download the last update of the library : [jo_libs](https://github.com/kaddarem-tebex/RedM-jo_libs/releases)
- Drag and drop the library into your resources folder
- jo_libs
- Add these ensure in your server.cfg
- `ensure jo_libs`
- `ensure jo_mdt`
- *If you want use the MDT in the item configuration, add these two items in your inventory :*
- `mdt` for the MDT
- `mdt_report` for MDT reports

:::details For RedEM:RP (old)
Add this Shared functions in `redemrp_inventory/server/sv_main.lua`
```lua:line-numbers=902
end
return data
end
function SharedInventoryFunctions.addItemLocker(name, amount, meta, lockerId) // [!code ++]
if not Locker[lockerId] then Locker[lockerId] = {} end // [!code ++]
addItemLocker(name, amount, meta, lockerId) // [!code ++]
end // [!code ++]
function SharedInventoryFunctions.getLocker(lockerId) // [!code ++]
return PrepareToOutput(Locker[lockerId]) // [!code ++]
end // [!code ++]
----=======================SHARED FUNCTIONS ================================
```
:::
:::details For RedEM:RP (2023)
Add this Shared functions in `redemrp_inventory/server/main.lua`
```lua:line-numbers=1558
end
return data
end
function SharedInventoryFunctions.addItemStash(source, name, amount, meta, stashId) // [!code ++]
if not Stash[stashId] then Stash[stashId] = {} end // [!code ++]
addItemStash(source, name, amount, meta, stashId) // [!code ++]
end // [!code ++]
function SharedInventoryFunctions.getStash(stashId) // [!code ++]
return PrepareToOutput(Stash[stashId]) // [!code ++]
end // [!code ++]
RegisterServerEvent("redemrp_inventory:deleteInv",
```
:::

Congratulation, the **MDT** script is ready to be used!

## 2. Usage
- If you set `Config.openingMode = "item"`

Go to one of the sheriff station to get your MDT. Use the MDT item to open it.

- If you set `Config.openingMode = "command"`

Use `/mdt`to open the MDT

## 3. Script configuration
### Config.lua file

:::details Config.lua
```lua
Config = {}

Config.openingMode = "item"
-- "item": use the item to open the MDT
-- "command": use the command to open the MDT

Config.citizensSyncMode = "station"
-- "station": sync between all MDT from the same station (only if Config.openingMode = "item")
-- "global": sync between all MDT

Config.reportSyncMode = "mdt"
-- "mdt": only display reports included in the mdt inventory
-- "station": sync between all MDT from the same station (only if Config.openingMode = "item")
-- "global": sync between all MDT

Config.distanceToSyncStationContent = 5.0 --distance max between the player and station to sync his content

Config.keys = {
backToClipboard = "INPUT_FRONTEND_UP",
fileLockerAccess = "INPUT_FRONTEND_ACCEPT",
getMDT = "INPUT_INTERACT_OPTION1"
}

Config.commands = {
openMDT = "mdt" --if (Config.openingMode == "command")
}

Config.items = {
mdt = "mdt", -- MDT item name
report = "mdt_report", -- report item name
}

Config.stations = {
{
id = "saintDenis", --has to be unique
name = "Saint-Denis", --label of the station
location = vec3(2509.532, -1304.805, 48.954), --location of the file cabinet
distancePrompt = 1.0, --distance to access to the file cabinet
jobs = {'sheriff'} --list of job restriction
},
...
}
```
:::
## 4. For developers

### Actions

[Actions](/DeveloperResources/actions) are the new way to modify how the script works or add new features. These actions are event that occurs at a specific point in time during the execution of the script. But contrary to events, actions are **synchronous**.

### Filters

[Filters](/DeveloperResources/filters) are the new way to modify data used by the script added in the `v1.2.0`. These filters are fired at a specific point in time during the execution of the script. But contrary to events, filters are **synchronous**.

#### <Badge type="client" text="Client" /> canOpenMDT
Fires before open the MDT
```lua
---@param canOpen - boolean
exports.jo_mdt:RegisterFilter('canOpenMDT', function(canOpen, stable)
return canAccess
end)
```
#### <Badge type="client" text="Client" /> updateLangForNUI
Fires before update the NUI Lang
```lua
---@param Lang - table: list of lang strings
exports.jo_mdt:RegisterFilter('updateLangForNUI', function(Lang)
return Lang
end)
```
#### <Badge type="server" text="Server" /> canGetMDT
Fires before give the MDT to the player
```lua
---@param canGet - boolean
---@param source - integer: server ID of the player
---@param stationKey - integer: key of the station from Config.stations
exports.jo_mdt:RegisterFilter('canGetMDT', function(canGet,source,stationKey)
return canGet
end)
```
#### <Badge type="server" text="Server" /> canManageFileLocker
Fires before open the file cabinet
```lua
---@param canManage - boolean
---@param source - integer: server ID of the player
exports.jo_mdt:RegisterFilter('canManageFileLocker', function(canManage,source)
return canManage
end)
```

0 comments on commit 70b95bf

Please sign in to comment.