Skip to content

Commit

Permalink
Merge pull request #528 from bitpredator/develop
Browse files Browse the repository at this point in the history
refactor: replace ox_doorlock with bpt_doorlock
  • Loading branch information
bitpredator authored Sep 23, 2023
2 parents 0fa0abc + 4d08d74 commit f75fe75
Show file tree
Hide file tree
Showing 58 changed files with 333 additions and 2,029 deletions.
199 changes: 115 additions & 84 deletions server-data/[SQL]/es_extended.sql

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_doorlock/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 bitpredator

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
44 changes: 44 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_doorlock/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# bpt_doorlock

Port management resource, currently only compatible with es_extended.
[latest release](https://github.com/bitpredator/bpt_doorlock/releases/latest/download/bpt_doorlock.zip)

## Dependencies

### [oxmysql](https://github.com/overextended/oxmysql)

The ports are stored in a database to facilitate the use of the resource

## Client API

```lua
exports.bpt_doorlock:useClosestDoor()
```

```lua
exports.bpt_doorlock:pickClosestDoor()
```

## Server API

```lua
local mrpd_locker_rooms = exports.bpt_doorlock:getDoor(1)
local mrpd_locker_rooms = exports.bpt_doorlock:getDoorFromName('mrpd locker rooms')
```

- Set door state (0: unlocked, 1: locked)

```lua
TriggerEvent('bpt_doorlock:setState', mrpd_locker_rooms.id, state)
```

- Listen for event when door is toggled

```lua
AddEventHandler('bpt_doorlock:stateChanged', function(source, doorId, state, usedItem)
if usedItem == 'trainticket' then
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeInventoryItem(usedItem, 1)
end
end)
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Dat54>
<Version value="7314721" />
<ContainerPaths>
<Item>dlc_oxdoorlock\oxdoorlock</Item>
<Item>dlc_bptdoorlock\bptdoorlock</Item>
</ContainerPaths>
<Items>
<!-- SimpleSounds -->
Expand All @@ -13,7 +13,7 @@
<Volume value="200" />
<Category>scripted</Category>
</Header>
<ContainerName>dlc_oxdoorlock/oxdoorlock</ContainerName>
<ContainerName>dlc_bptdoorlock/bptdoorlock</ContainerName>
<FileName>button_remote</FileName>
<WaveSlotNum value="0" />
</Item>
Expand All @@ -25,7 +25,7 @@
<Volume value="200" />
<Category>scripted</Category>
</Header>
<ContainerName>dlc_oxdoorlock/oxdoorlock</ContainerName>
<ContainerName>dlc_bptdoorlock/bptdoorlock</ContainerName>
<FileName>door_bolt</FileName>
<WaveSlotNum value="0" />
</Item>
Expand All @@ -37,7 +37,7 @@
<Volume value="200" />
<Category>scripted</Category>
</Header>
<ContainerName>dlc_oxdoorlock/oxdoorlock</ContainerName>
<ContainerName>dlc_bptdoorlock/bptdoorlock</ContainerName>
<FileName>metal_locker</FileName>
<WaveSlotNum value="0" />
</Item>
Expand All @@ -49,7 +49,7 @@
<Volume value="200" />
<Category>scripted</Category>
</Header>
<ContainerName>dlc_oxdoorlock/oxdoorlock</ContainerName>
<ContainerName>dlc_bptdoorlock/bptdoorlock</ContainerName>
<FileName>metallic_creak</FileName>
<WaveSlotNum value="0" />
</Item>
Expand All @@ -58,7 +58,7 @@

<!-- SoundSets !-->
<Item type="SoundSet">
<Name>dlc_oxdoorlock_set</Name>
<Name>dlc_bptdoorlock_set</Name>
<Header>
<Flags value="0xAAAAAAAA" />
</Header>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if not LoadResourceFile(lib.name, 'web/build/index.html') then
error('Unable to load UI. Build ox_doorlock or download the latest release.\n ^3https://github.com/overextended/ox_doorlock/releases/latest/download/ox_doorlock.zip^0')
error('Unable to load UI. Build bpt_doorlock or download the latest release.\n ^3https://github.com/bitpredator/bpt_doorlock/releases/latest/download/bpt_doorlock.zip^0')
end

do
Expand Down Expand Up @@ -37,7 +37,7 @@ end
local nearbyDoors = {}
local Entity = Entity

lib.callback('ox_doorlock:getDoors', false, function(data)
lib.callback('bpt_doorlock:getDoors', false, function(data)
doors = data

for _, door in pairs(data) do
Expand Down Expand Up @@ -115,7 +115,7 @@ lib.callback('ox_doorlock:getDoors', false, function(data)
end
end)

RegisterNetEvent('ox_doorlock:setState', function(id, state, source, data)
RegisterNetEvent('bpt_doorlock:setState', function(id, state, source, data)
if not doors then return end

if data then
Expand Down Expand Up @@ -192,7 +192,7 @@ RegisterNetEvent('ox_doorlock:setState', function(id, state, source, data)
end
end)

RegisterNetEvent('ox_doorlock:editDoorlock', function(id, data)
RegisterNetEvent('bpt_doorlock:editDoorlock', function(id, data)
if source == '' then return end

local door = doors[id]
Expand Down Expand Up @@ -260,7 +260,7 @@ end)

ClosestDoor = nil

lib.callback.register('ox_doorlock:inputPassCode', function()
lib.callback.register('bpt_doorlock:inputPassCode', function()
return ClosestDoor?.passcode and lib.inputDialog(locale('door_lock'), {
{
type = 'input',
Expand All @@ -280,7 +280,7 @@ local function useClosestDoor()

if gameTimer - lastTriggered > 500 then
lastTriggered = gameTimer
TriggerServerEvent('ox_doorlock:setState', ClosestDoor.id, ClosestDoor.state == 1 and 0 or 1)
TriggerServerEvent('bpt_doorlock:setState', ClosestDoor.id, ClosestDoor.state == 1 and 0 or 1)
end
end

Expand Down Expand Up @@ -351,4 +351,4 @@ CreateThread(function()

Wait(num > 0 and 0 or 500)
end
end)
end)
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ local function pickLock(entity)
local rand = math.random(1, success and 100 or 5)

if success then
TriggerServerEvent('ox_doorlock:setState', door.id, door.state == 1 and 0 or 1, true)
TriggerServerEvent('bpt_doorlock:setState', door.id, door.state == 1 and 0 or 1, true)
end

if rand == 1 then
TriggerServerEvent('ox_doorlock:breakLockpick')
TriggerServerEvent('bpt_doorlock:breakLockpick')
lib.notify({ type = 'error', description = locale('lockpick_broke') })
end

Expand Down Expand Up @@ -201,13 +201,13 @@ RegisterNUICallback('createDoor', function(data, cb)

isAddingDoorlock = false

TriggerServerEvent('ox_doorlock:editDoorlock', data.id or false, data)
TriggerServerEvent('bpt_doorlock:editDoorlock', data.id or false, data)
table.wipe(tempData)
end)

RegisterNUICallback('deleteDoor', function(id, cb)
cb(1)
TriggerServerEvent('ox_doorlock:editDoorlock', id)
TriggerServerEvent('bpt_doorlock:editDoorlock', id)
end)

RegisterNUICallback('teleportToDoor', function(id, cb)
Expand Down Expand Up @@ -237,7 +237,7 @@ local function openUi(id)

SendNUIMessage({
action = 'setSoundFiles',
data = lib.callback.await('ox_doorlock:getSounds', false)
data = lib.callback.await('bpt_doorlock:getSounds', false)
})
end

Expand All @@ -248,7 +248,7 @@ local function openUi(id)
}))
end

RegisterNetEvent('ox_doorlock:triggeredCommand', function(closest)
RegisterNetEvent('bpt_doorlock:triggeredCommand', function(closest)
openUi(closest and ClosestDoor?.id or nil)
end)

Expand Down Expand Up @@ -321,4 +321,4 @@ CreateThread(function()
end
end)
end
end)
end)
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ Config.LockpickItems = {
}

---Play sounds using game audio (sound natives) instead of through NUI.
Config.NativeAudio = true
Config.NativeAudio = false
48 changes: 48 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_doorlock/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
-- FX Information
fx_version 'cerulean'
use_experimental_fxv2_oal 'yes'
lua54 'yes'
game 'gta5'

-- Resource Information
name 'bpt_doorlock'
version '1.0.0'
license 'MIT'
author 'bitpredator'
repository 'https://github.com/bitpredator/bpt_doorlock'

-- Manifest
shared_script {
'@ox_lib/init.lua',
'config.lua',
}

client_script {
'client/main.lua',
'client/utils.lua',
}

server_script {
'@oxmysql/lib/MySQL.lua',
'server/convert.lua',
'server/framework/*.lua',
'server/main.lua',
}

ui_page 'web/build/index.html'

files {
'web/build/index.html',
'web/build/**/*',
'locales/*.json',
'audio/data/bptdoorlock_sounds.dat54.rel',
'audio/dlc_bptdoorlock/bptdoorlock.awc',
}

data_file 'AUDIO_WAVEPACK' 'audio/dlc_bptdoorlock'
data_file 'AUDIO_SOUNDDATA' 'audio/data/bptdoorlock_sounds.dat'

dependencies {
'oxmysql',
'ox_lib'
}
18 changes: 18 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_doorlock/locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"unlocked_door": "Unlocked door",
"locked_door": "Locked door",
"lock_door": "[E] Lock door",
"unlock_door": "[E] Unlock door",
"door_lock": "Door lock",
"passcode": "Passcode",
"lockpick_broke": "Your lockpick broke",
"pick_lock": "Pick lock",
"add_lock": "Add doorlock",
"edit_lock": "Edit doorlock",
"remove_lock": "Remove doorlock",
"cannot_unlock": "Unable to unlock door",
"cannot_lock": "Unable to lock door",
"create_modify_lock": "Create a doorlock, or modify an existing one",
"add_door_textui": "**Create new door** \nInteract with [LMB] \nCancel with [RMB]",
"command_closest": "Open UI directly to closest doorlock"
}
18 changes: 18 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_doorlock/locales/it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"unlocked_door": "Porta sbloccata",
"locked_door": "Porta chiusa",
"lock_door": "[E] Chiudi porta",
"unlock_door": "[E] Apri porta",
"door_lock": "Serratura della porta",
"passcode": "codice di accesso",
"lockpick_broke": "il tuo grimaldello si è rotto",
"pick_lock": "Scassina serratura",
"add_lock": "Aggiungi serratura",
"edit_lock": "Modifica serratura",
"remove_lock": "Rimuovi serratura",
"cannot_unlock": "Impossibile aprire la porta",
"cannot_lock": "Impossibile chiudere la porta",
"create_modify_lock": "Crea una serratura o modificane una esistente",
"add_door_textui": "**Crea una nuova porta** \nInteragire con [LMB] \nAnnulla con [RMB]",
"command_closest": "Apri l'interfaccia utente direttamente alla serratura più vicina"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
CREATE TABLE
IF NOT EXISTS `ox_doorlock` (
IF NOT EXISTS `bpt_doorlock` (
`id` int (11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`data` longtext NOT NULL,
PRIMARY KEY (`id`)
);
)
;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
Run this file after ox_doorlock.sql
Run this file after bpt_doorlock.sql
Works with https://www.gta5-mods.com/maps/community-mission-row-pd
*/

INSERT INTO `ox_doorlock` (`id`, `name`, `data`) VALUES
INSERT INTO `bpt_doorlock` (`id`, `name`, `data`) VALUES
(1, 'community_mrpd 1', '{"coords":{"x":434.7478942871094,"y":-981.916748046875,"z":30.83926963806152},"groups":{"police":0,"offpolice":0},"maxDistance":2.5,"state":0,"doors":[{"coords":{"x":434.7478942871094,"y":-980.618408203125,"z":30.83926963806152},"model":-1215222675,"heading":270},{"coords":{"x":434.7478942871094,"y":-983.215087890625,"z":30.83926963806152},"model":320433149,"heading":270}],"hideUi":false}'),
(2, 'community_mrpd 2', '{"coords":{"x":468.6697998046875,"y":-1014.4520263671875,"z":26.53623962402343},"groups":{"police":0},"maxDistance":2.5,"state":1,"doors":[{"coords":{"x":469.9679870605469,"y":-1014.4520263671875,"z":26.53623962402343},"model":-2023754432,"heading":180},{"coords":{"x":467.3716125488281,"y":-1014.4520263671875,"z":26.53623962402343},"model":-2023754432,"heading":0}],"hideUi":false}'),
(3, 'community_mrpd 3', '{"coords":{"x":463.4783020019531,"y":-1003.5380249023438,"z":25.00598907470703},"model":-1033001619,"groups":{"police":0},"heading":0,"maxDistance":2,"state":1,"hideUi":false}'),
Expand Down Expand Up @@ -34,4 +34,5 @@ INSERT INTO `ox_doorlock` (`id`, `name`, `data`) VALUES
(28, 'community_mrpd 28', '{"coords":{"x":480.03009033203127,"y":-1003.5380249023438,"z":25.00598907470703},"model":-1033001619,"groups":{"police":0},"heading":0,"maxDistance":2,"state":1,"hideUi":false}'),
(29, 'community_mrpd 29', '{"coords":{"x":444.7078857421875,"y":-989.4453735351563,"z":30.83930969238281},"groups":{"police":0},"maxDistance":2.5,"state":1,"doors":[{"coords":{"x":443.4078063964844,"y":-989.4453735351563,"z":30.83930969238281},"model":185711165,"heading":180},{"coords":{"x":446.00799560546877,"y":-989.4453735351563,"z":30.83930969238281},"model":185711165,"heading":0}],"hideUi":false}'),
(30, 'community_mrpd 30', '{"coords":{"x":445.9197998046875,"y":-999.0016479492188,"z":30.7890396118164},"groups":{"police":0},"maxDistance":2.5,"state":1,"doors":[{"coords":{"x":447.2184143066406,"y":-999.0023193359375,"z":30.78941917419433},"model":-1033001619,"heading":180},{"coords":{"x":444.6211853027344,"y":-999.0009765625,"z":30.78866004943847},"model":-1033001619,"heading":0}],"hideUi":false}'),
(31, 'community_mrpd 31', '{"coords":{"x":445.9298400878906,"y":-997.044677734375,"z":30.84351921081543},"groups":{"police":0},"maxDistance":2.5,"state":0,"doors":[{"coords":{"x":444.62939453125,"y":-997.044677734375,"z":30.84351921081543},"model":-2023754432,"heading":0},{"coords":{"x":447.23028564453127,"y":-997.044677734375,"z":30.84351921081543},"model":-2023754432,"heading":180}],"hideUi":false}');
(31, 'community_mrpd 31', '{"coords":{"x":445.9298400878906,"y":-997.044677734375,"z":30.84351921081543},"groups":{"police":0},"maxDistance":2.5,"state":0,"doors":[{"coords":{"x":444.62939453125,"y":-997.044677734375,"z":30.84351921081543},"model":-2023754432,"heading":0},{"coords":{"x":447.23028564453127,"y":-997.044677734375,"z":30.84351921081543},"model":-2023754432,"heading":180}],"hideUi":false}')
;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
Run this file after ox_doorlock.sql
Run this file after bpt_doorlock.sql
Works with the standard Mission Row PD interior
*/

INSERT INTO `ox_doorlock` (`id`, `name`, `data`) VALUES
INSERT INTO `bpt_doorlock` (`id`, `name`, `data`) VALUES
(1, 'mrpd locker rooms', '{"maxDistance":2,"heading":90,"coords":{"x":450.1041259765625,"y":-985.7384033203125,"z":30.83930206298828},"groups":{"police":0},"state":1,"model":1557126584,"hideUi":false}'),
(2, 'mrpd cells/briefing', '{"maxDistance":2,"coords":{"x":444.7078552246094,"y":-989.4454345703125,"z":30.83930206298828},"doors":[{"model":185711165,"coords":{"x":446.0079345703125,"y":-989.4454345703125,"z":30.83930206298828},"heading":0},{"model":185711165,"coords":{"x":443.40777587890627,"y":-989.4454345703125,"z":30.83930206298828},"heading":180}],"groups":{"police":0},"state":1,"hideUi":false}'),
(3, 'mrpd cell 3', '{"maxDistance":2,"heading":90,"coords":{"x":461.8065185546875,"y":-1001.9515380859375,"z":25.06442832946777},"lockSound":"metal-locker","groups":{"police":0},"state":1,"unlockSound":"metallic-creak","model":631614199,"hideUi":false}'),
Expand All @@ -14,4 +14,5 @@ INSERT INTO `ox_doorlock` (`id`, `name`, `data`) VALUES
(8, 'mrpd gate', '{"maxDistance":6,"heading":90,"coords":{"x":488.894775390625,"y":-1017.2102661132813,"z":27.14714050292968},"groups":{"police":0},"auto":true,"state":1,"model":-1603817716,"hideUi":false}'),
(9, 'mrpd cell 1', '{"maxDistance":2,"heading":270,"coords":{"x":461.8065185546875,"y":-993.7586059570313,"z":25.06442832946777},"lockSound":"metal-locker","groups":{"police":0},"state":1,"unlockSound":"metallic-creak","model":631614199,"hideUi":false}'),
(10, 'mrpd cells main', '{"maxDistance":2,"heading":360,"coords":{"x":463.92010498046877,"y":-992.6640625,"z":25.06442832946777},"lockSound":"metal-locker","groups":{"police":0},"state":1,"unlockSound":"metallic-creak","model":631614199,"hideUi":false}'),
(11, 'mrpd armoury', '{"maxDistance":2,"heading":270,"coords":{"x":453.08428955078127,"y":-982.5794677734375,"z":30.81926536560058},"autolock":5,"groups":{"police":0},"state":1,"model":749848321,"hideUi":false}');
(11, 'mrpd armoury', '{"maxDistance":2,"heading":270,"coords":{"x":453.08428955078127,"y":-982.5794677734375,"z":30.81926536560058},"autolock":5,"groups":{"police":0},"state":1,"model":749848321,"hideUi":false}')
;
Loading

0 comments on commit f75fe75

Please sign in to comment.