Skip to content

Commit

Permalink
Update v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PickleModifications authored May 25, 2023
0 parents commit cb07c4a
Show file tree
Hide file tree
Showing 38 changed files with 2,872 additions and 0 deletions.
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<div align='center'><img src='https://github.com/PickleModifications/pickle_prisons/assets/111543470/4d581149-0128-46ab-a48e-b08246dfbfd6'/></div>
<div align='center'><h3><a href='https://picklemods.com/'>More Information & Scripts can be found here!</a></h3></div>

## Preview

https://www.youtube.com/watch?v=flCTCk4hW7g

## What is this?

This is a one-size fits all solution for jail systems, with high quality features that have yet to be seen in a free prison script.
It also has a lot of innovations, such as multiple prison support, which lets you send people to different prisons on the map (requires setup).

## Features

<ul>
<li>Supports both non-target and target!</li>
<li>Work & Activities (Kitchen, Cleaning, Workouts)</li>
<li>Create your own Work & Activities in the config! (Config.Activities)</li>
<li>Multiplayer Breakouts</li>
<li>Multiple Prison Support</li>
<li>Commands (/jail, /unjail, /jailstatus)</li>
<li>Takes & Returns Items Before & After Jail</li>
<li>Automatic Outfit Switcher</li>
<li>Commisary & Prison Plug (Used for Contraband Trades)</li>
<li>Collectable Items around the prison, with regen timer.</li>
<li>Custom Jail Siren System (Works with .MP3)</li>
<li>And more!</li>

</ul>

## Requirements

* ESX (1.1+) / QBCore, or code your own bridge to work with your framework. (the bridge is fully accessible!)
* <a href='https://github.com/overextended/ox_lib/releases/'>Ox Lib</a> (Required, Works anywhere).

## Optional XP Support

Use my free XP system below, or port to another one inside of the bridge!

https://forum.cfx.re/t/free-pickles-xp-system-standalone-works-with-esx-qb-multicharacter-identifiers/5088064

## Optional Metadata Support

<p><strong><em>This is not required to use the script, however enables you to generate items with metadata using the .createItem function in the rewards.</em></strong></p>

<ul>
<li>QBCore</li>
<li>Ox Inventory</li>
<li>ESX (Only if your inventory provider allows metadata to be set through &quot;xPlayer.addInventoryItem&quot;.</li>
</ul>

## Installation

<p>ensure pickle_prisons after ox_lib & pickle_xp (if using it).</p>
<p>Go to the "_INSTALL" folder.</p>
<p>Add the items.</p>
<p>Run the SQL file.</p>
<p>Go to the config, and set Config.UseTarget to true/false.</p>
<p>Restart the server.</p>

## Documentation

https://docs.picklemods.com/resources/prisons

## Need Support?

<a href='https://picklemods.com'>Click here!</a>
6 changes: 6 additions & 0 deletions _INSTALL/Items/esx_limit.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
INSERT INTO `items` (`name`, `label`, `limit`) VALUES
('wood', 'Wood', 100),
('metal', 'Metal', 100),
('rope', 'Rope', 100),
('shovel', 'Shovel', 100)
;
6 changes: 6 additions & 0 deletions _INSTALL/Items/esx_weight.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
INSERT INTO `items` (`name`, `label`, `weight`) VALUES
('wood', 'Wood', 1),
('metal', 'Metal', 1),
('rope', 'Rope', 1),
('shovel', 'Shovel', 1)
;
31 changes: 31 additions & 0 deletions _INSTALL/Items/ox_inventory.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
['wood'] = {
label = 'Wood',
weight = 1,
stack = true,
close = true,
description = nil
},

['metal'] = {
label = 'Metal',
weight = 1,
stack = true,
close = true,
description = nil
},

['rope'] = {
label = 'Rope',
weight = 1,
stack = true,
close = true,
description = nil
},

['shovel'] = {
label = 'Shovel',
weight = 1,
stack = true,
close = true,
description = nil
},
4 changes: 4 additions & 0 deletions _INSTALL/Items/qbcore.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
["wood"] = {["name"] = "wood", ["label"] = "Wood", ["weight"] = 1, ["type"] = "item", ["image"] = "wood.png", ["unique"] = false, ["useable"] = true, ["shouldClose"] = true, ["combinable"] = nil, ["description"] = ""},
["metal"] = {["name"] = "metal", ["label"] = "Metal", ["weight"] = 1, ["type"] = "item", ["image"] = "metal.png", ["unique"] = false, ["useable"] = true, ["shouldClose"] = true, ["combinable"] = nil, ["description"] = ""},
["rope"] = {["name"] = "rope", ["label"] = "Rope", ["weight"] = 1, ["type"] = "item", ["image"] = "rope.png", ["unique"] = false, ["useable"] = true, ["shouldClose"] = true, ["combinable"] = nil, ["description"] = ""},
["shovel"] = {["name"] = "shovel", ["label"] = "Shovel", ["weight"] = 1, ["type"] = "item", ["image"] = "shovel.png", ["unique"] = false, ["useable"] = true, ["shouldClose"] = true, ["combinable"] = nil, ["description"] = ""},
7 changes: 7 additions & 0 deletions _INSTALL/SQL/install.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS `pickle_prisons` (
`identifier` varchar(46) NOT NULL,
`prison` varchar(50) DEFAULT 'default',
`time` int(11) NOT NULL DEFAULT 0,
`inventory` longtext DEFAULT '[]',
`sentence_date` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
4 changes: 4 additions & 0 deletions bridge/custom/client.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if GetResourceState('es_extended') == 'started' then return end
if GetResourceState('qb-core') == 'started' then return end

print("You are not using a supported framework, it will be required to make edits to the bridge files.")
4 changes: 4 additions & 0 deletions bridge/custom/server.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if GetResourceState('es_extended') == 'started' then return end
if GetResourceState('qb-core') == 'started' then return end

print("You are not using a supported framework, it will be required to make edits to the bridge files.")
85 changes: 85 additions & 0 deletions bridge/esx/client.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
if GetResourceState('es_extended') ~= 'started' then return end

ESX = exports.es_extended:getSharedObject()

function ShowNotification(text)
ESX.ShowNotification(text)
end

function ServerCallback(name, cb, ...)
ESX.TriggerServerCallback(name, cb, ...)
end

function GetPlayersInArea(coords, radius)
local coords = coords or GetEntityCoords(PlayerPedId())
local radius = radius or 3.0
local list = ESX.Game.GetPlayersInArea(coords, radius)
local players = {}
for _, player in pairs(list) do
if player ~= PlayerId() then
players[#players + 1] = player
end
end
return players
end

RegisterNetEvent(GetCurrentResourceName()..":showNotification", function(text)
ShowNotification(text)
end)

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded',function(xPlayer, isNew, skin)
TriggerServerEvent("pickle_prisons:initializePlayer")
end)

local alreadySpawned = false

RegisterNetEvent('esx:onPlayerDeath', function()
CheckBreakout = false
end)

RegisterNetEvent('esx:onPlayerSpawn', function()
if not alreadySpawned then -- Prevents TP to hospital on-load.
alreadySpawned = true
return
end
TeleportHospital()
CheckBreakout = true
end)

function ToggleOutfit(inPrison)
if inPrison then
local prison = Config.Prisons[Prison.index]
local outfits = prison.outfit or Config.Default.outfit
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
local gender = skin.sex
local outfit = gender == 1 and outfits.female or outfits.male
if not outfit then return end
TriggerEvent('skinchanger:loadClothes', skin, outfit)
end)
else
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
TriggerEvent('skinchanger:loadSkin', skin)
TriggerEvent('esx:restoreLoadout')
end)
end
end

-- Inventory Fallback

CreateThread(function()
Wait(100)

if InitializeInventory then return InitializeInventory() end -- Already loaded through inventory folder.

Inventory = {}

Inventory.Items = {}

Inventory.Ready = false

RegisterNetEvent("pickle_prisons:setupInventory", function(data)
Inventory.Items = data.items
Inventory.Ready = true
end)
end)
138 changes: 138 additions & 0 deletions bridge/esx/server.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
if GetResourceState('es_extended') ~= 'started' then return end

ESX = exports.es_extended:getSharedObject()

function RegisterCallback(name, cb)
ESX.RegisterServerCallback(name, cb)
end

function RegisterUsableItem(...)
ESX.RegisterUsableItem(...)
end

function ShowNotification(target, text)
TriggerClientEvent(GetCurrentResourceName()..":showNotification", target, text)
end

function GetIdentifier(source)
local xPlayer = ESX.GetPlayerFromId(source)
return xPlayer.identifier
end

function SetPlayerMetadata(source, key, data)
-- No player metadata in ESX.
end

function AddMoney(source, count)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.addMoney(count)
end

function RemoveMoney(source, count)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeMoney(count)
end

function GetMoney(source)
local xPlayer = ESX.GetPlayerFromId(source)
return xPlayer.getMoney()
end

function CheckPermission(source, permission)
local xPlayer = ESX.GetPlayerFromId(source)
local name = xPlayer.job.name
local rank = xPlayer.job.grade
local group = xPlayer.getGroup()
if permission.jobs[name] and permission.jobs[name] <= rank then
return true
end
for i=1, #permission.groups do
if group == permission.groups[i] then
return true
end
end
end

-- Inventory Fallback

CreateThread(function()
Wait(100)

if InitializeInventory then return InitializeInventory() end -- Already loaded through inventory folder.

Inventory = {}

Inventory.Items = {}

Inventory.Ready = false

Inventory.CanCarryItem = function(source, name, count)
local xPlayer = ESX.GetPlayerFromId(source)
if Config.InventoryLimit then
local item = xPlayer.getInventoryItem(name)
return (item.limit >= item.count + count)
else
return xPlayer.canCarryItem(name, count)
end
end

Inventory.GetInventory = function(source)
local xPlayer = ESX.GetPlayerFromId(source)
local items = {}
local data = xPlayer.getInventory()
for i=1, #data do
local item = data[i]
items[#items + 1] = {
name = item.name,
label = item.label,
count = item.count,
weight = item.weight
}
end
return items
end

Inventory.AddItem = function(source, name, count, metadata) -- Metadata is not required.
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.addInventoryItem(name, count)
end

Inventory.RemoveItem = function(source, name, count)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeInventoryItem(name, count)
end

Inventory.AddWeapon = function(source, name, count, metadata) -- Metadata is not required.
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.addWeapon(name, 0)
end

Inventory.RemoveWeapon = function(source, name, count)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeWeapon(name, 0)
end

Inventory.GetItemCount = function(source, name)
local xPlayer = ESX.GetPlayerFromId(source)
local item = xPlayer.getInventoryItem(name)
return item and item.count or 0
end

Inventory.HasWeapon = function(source, name, count)
local xPlayer = ESX.GetPlayerFromId(source)
return xPlayer.hasWeapon(name)
end

RegisterCallback("pickle_prisons:getInventory", function(source, cb)
cb(Inventory.GetInventory(source))
end)

MySQL.ready(function()
MySQL.Async.fetchAll("SELECT * FROM items;", {}, function(results)
for i=1, #results do
Inventory.Items[results[i].name] = {label = results[i].label}
end
Inventory.Ready = true
end)
end)
end)
15 changes: 15 additions & 0 deletions bridge/inventory/ox_inventory/client.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if GetResourceState('ox_inventory') ~= 'started' then return end

Inventory = {}

Inventory.Items = {}

Inventory.Ready = false

RegisterNetEvent("pickle_prisons:setupInventory", function(data)
Inventory.Items = data.items
Inventory.Ready = true
end)

function InitializeInventory()
end
Loading

0 comments on commit cb07c4a

Please sign in to comment.