Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
License


update distributed json


README and other things


Add image


Woops


README


License


Update mute settings and README credits
  • Loading branch information
itsJarrett committed Dec 1, 2018
1 parent 0ee09cd commit 4b0e9fa
Show file tree
Hide file tree
Showing 7 changed files with 1,064 additions and 3 deletions.
49 changes: 46 additions & 3 deletions README.md
Expand Up @@ -3,14 +3,57 @@ A Jail and Justice System that gives power back to the players.
Copyright (C) 2018 Jarrett Boice

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU Affero General Public License for more details.

You should have received a copy of the GNU General Public License
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

---

## Description
FiveM-JailNJury or Jail N' Jury is a advanced jail, and justice system / resource for FiveM servers. Jail N' Jury offer's advanced jail features with a democratic justice system. If a arrestee feels that they have been falsely jailed, they may request a trial by a jury of their peers, the people of your server's state. Fear of arrestees escaping? Have no worry, this is literally impossible. People disconnecting to avoid jail? No problem, the justice system has your back and will jail them upon return!

## Rundown

### Arrest System
Law Enforcement Officers are able to jail arrestees via the jail command. The arrest is then logged via json and placed into the jailed players file. If the arrestee disconnects, their time is paused at whatever time was remaining when they left the server. When the player reconnects, they are re-jailed for the same time, and charges as prior. The prison is able to detect if a arrestee is attempting to escape and will teleport them back to the jail, it is literally impossible to escape the jail.

### Justice System
An arrestee may only request a court case if their time is longer than 10 minutes. Once the court case has been granted, their jail time is paused and an advertisement is given to all players regarding an upcoming court case. Players are given 5 minutes to make their way to the courthouse for a chance at becoming a juror. A minimum of 3 jurors must be present for the court case to proceed. There is a maximum of 5 jurors. Jurors are selected randomly from players at the courthouse and cannot be any police personnel. Selected jurors are then briefed on the suspect's charges. The arrestee and jurors are then teleported to the court room. The arrestee is given 1 minute to explain their charges to the jurors, at this time the jurors are muted and cannot speak or type. After the 1 minute has passed, the arrestee is teleported back to the prison and awaits the verdict. The jurors are then unmuted and are able to type and must deliberate for 1 minute. After the 1 minute has passed, the jurors are then muted again and asked to cast their verdict, they are given 30 seconds. After this, jurors are relieved from their duty and teleported back to the courthouse entrance. The verdict is then calculated. For a arrestee to be found not guilty, they must have a 2/3 or 3/5 vote. The verdict is then displayed to the public and the arrestee is either re-jailed for their remaining time or released depending on the outcome of the trial.

## Commands
| Command | Arguments | Explanation
| --- | --- | ---
| `/jail` | `PlayerID Time "Charges"` | This command is used by police to jail arrestees. The `PlayerID` is the ID of the player, the `Time` is the time in minutes, the `"Charges"` are the charges. The charges must be surrounded by quotes in order to capture all of the seperated words. |
| `/unjail` | `PlayerID` | This command is used by police to unjail an arrestee. The `PlayerID` is the ID of the player. |
| `/requesttrial` | None | This command is used by arrestees to request a court trial. There are no arguments for this command. |
| `/jurorverdict` | `yes` or `no` | This command is by jurors to send their verdict regarding the trial. `yes` is interpreted as guilty. `no` is interpreted as not guilty. |

## Configuration
The configuration file is located in `sh_config.lua`

| Configuration Key | Explanation
| --- | ---
| `JailConfig.jailFile` | A string of the filepath for the json file in which the jailed players are stored.
| `JailConfig.stateName` | This is a string that is used in many factors of the system for the state. Ex. Superior Court of San Andreas. |
| `JailConfig.policePeds` | This is an array that the system checks against to see if a player is a police officer via checking the ped model. |
| `JailConfig.courtStartTime` | The system interprets this integer as the amount of minutes to give potential jurors to show up to the courthouse location. |
| `JailConfig.courtEntraceLocation` | This is an array that the system interprets as a vector for the courthouse front entrance. This is used to display the blip as well as the area in which the system will select jurors. |
| `JailConfig.defendantLocation` | This is an array that the system interprets as a vector for the position at which the defendant or arrestee will be during the court case. |
| `JailConfig.jurorLocations` | This is an array of vector arrays for each of the juror locations inside the courthouse.
| `JailConfig.prisonLocation` | This is an array that the system interprets as a vector for the prison location where arrestees are sent to jail.
| `JailConfig.prisonEntraceLocation` | This an array that the system interprets as a vector for the entrance to the prison. This is where arrestees are sent after they are released.

## Credits
- [@rxi](https://github.com/rxi) - [json.lua](https://github.com/rxi/json.lua) - Rxi supplies the lightweight json lua encoding and decoding library this resource uses to save jailed players.
- [Gaming-Asylum](http://www.gaming-asylum.com/forums/index.php) - [Gaming-Asylum-Wiki](http://gaming-asylumwiki.com/wiki/Prison_Guide) - Gaming Asylum Servers have a similar jail and justice system on their Arma 3 servers. I drew inspiration from this server because their system is very effective and fun.

## Pictures
![Map Image of Courthouse](https://i.imgur.com/SHSOipy.jpg)
34 changes: 34 additions & 0 deletions __resource.lua
@@ -0,0 +1,34 @@
--[[
FiveM-JailNJury
A Jail and Justice System that gives power back to the players.
Copyright (C) 2018 Jarrett Boice
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]

resource_manifest_version "679-996150c95a1d251a5c0c7841ab2f0276878334f7"
description "Jail n' Jury"
author "Slavko Avsenik"
version "1.0.0"

client_scripts {
"sh_config.lua",
"cl_jailnjury.lua"
}

server_scripts {
"json.lua",
"sh_config.lua",
"sv_jailnjury.lua"
}
212 changes: 212 additions & 0 deletions cl_jailnjury.lua
@@ -0,0 +1,212 @@
--[[
FiveM-JailNJury
A Jail and Justice System that gives power back to the players.
Copyright (C) 2018 Jarrett Boice
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]

local isJailedG = false
local jailTimeG = 0

local courtCase = false
local muted = false
local notifyCourtHouseIn = false
local notifyCourtHouseOut = false

RegisterCommand("jail", function(source, args, rawCommand)
local _source = source
local targetPedId = args[1]
local jailTime = tonumber(args[2]) or 0
local jailCharges = args[3]
if isPolice(GetEntityModel(GetPlayerPed())) then
if targetPedId == nil then
return TriggerEvent("chatMessage", "^1You must enter the suspect's ID number.")
elseif jailTime <= 0 then
return TriggerEvent("chatMessage", "^1Invalid Jail Time, enter an amount greater than 0.")
elseif jailCharges == nil then
return TriggerEvent("chatMessage", "^1You must enter the suspect's charges.")
else
TriggerServerEvent("jnj:sendToJail", targetPedId, jailTime, jailCharges)
end
else
TriggerEvent("chatMessage", "^1You are not authorized to use this command. Consider joining a Police Department.")
end
end)

RegisterCommand("unjail", function(source, args, rawCommand)
local _source = source
local targetPedId = args[1]
if isPolice(GetEntityModel(GetPlayerPed())) then
if targetPedId == nil then
return TriggerEvent("chatMessage", "^1You must enter the prisoner's ID number.")
else
TriggerServerEvent("jnj:releaseFromJail", targetPedId)
end
else
TriggerEvent("chatMessage", "^1You are not authorized to use this command. Consider joining a Police Department.")
end
end)

RegisterNetEvent("jnj:sendToJail")
AddEventHandler("jnj:sendToJail", function(jailArray)
local targetPed = PlayerPedId()
local jailTime = jailArray[1]
RemoveAllPedWeapons(targetPed, true)
SetEntityInvincible(GetPlayerPed(targetPed), true)
SetEntityCoords(targetPed, JailConfig.prisonLocation.x, JailConfig.prisonLocation.y, JailConfig.prisonLocation.z, 0.0, 0.0, 0.0, false)
isJailedG = true
jailTimeG = jailTime
end)

RegisterNetEvent("jnj:releaseFromJail")
AddEventHandler("jnj:releaseFromJail", function()
local targetPed = PlayerPedId()
jailTimeG = 0
isJailedG = false
SetEntityInvincible(GetPlayerPed(targetPed), false)
SetEntityCoords(targetPed, JailConfig.prisonEntraceLocation.x, JailConfig.prisonEntraceLocation.y, JailConfig.prisonEntraceLocation.z, 0.0, 0.0, 0.0, false)
end)

RegisterNetEvent("jnj:teleportToCourt")
AddEventHandler("jnj:teleportToCourt", function(pmuted, vector)
local targetPed = PlayerPedId()
RemoveAllPedWeapons(targetPed, true)
SetEntityCoords(targetPed, vector.x, vector.y, vector.z, 0.0, 0.0, 0.0, false)
SetEntityHeading(targetPed, vector.h)
FreezeEntityPosition(targetPed, true)
if not pmuted then
DisableControlAction(0, 245, false)
DisableControlAction(0, 249, false)
else
muted = true
end
end)

RegisterNetEvent("jnj:teleportAwayCourt")
AddEventHandler("jnj:teleportAwayCourt", function(vector)
local targetPed = PlayerPedId()
SetEntityCoords(targetPed, vector.x, vector.y, vector.z, 0.0, 0.0, 0.0, false)
FreezeEntityPosition(targetPed, false)
muted = false
DisableControlAction(0, 245, false)
DisableControlAction(0, 249, false)
end)

RegisterNetEvent("jnj:courtCaseStatusAll")
AddEventHandler("jnj:courtCaseStatusAll", function(boolean)
courtCase = boolean
end)

RegisterNetEvent("jnj:courtCaseStatus")
AddEventHandler("jnj:courtCaseStatus", function(boolean)
isJailedG = not boolean
end)

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if muted then
DisableControlAction(0, 245, true)
DisableControlAction(0, 249, true)
end
end
end)

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if isJailedG then
local playerPed = PlayerPedId()
if GetDistanceBetweenCoords(GetEntityCoords(playerPed), JailConfig.prisonLocation.x, JailConfig.prisonLocation.y, JailConfig.prisonLocation.z) > 50 then
SetEntityCoords(playerPed, JailConfig.prisonLocation.x, JailConfig.prisonLocation.y, JailConfig.prisonLocation.z, 0.0, 0.0, 0.0, false)
TriggerEvent("chatMessage", "^1Do not attempt to escape.")
end
Citizen.Wait(1000)
end
end
end)

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if courtCase and not isPolice(GetEntityModel(GetPlayerPed())) then
local playerPed = PlayerPedId()
if GetDistanceBetweenCoords(GetEntityCoords(playerPed), JailConfig.courtEntraceLocation.x, JailConfig.courtEntraceLocation.y, JailConfig.courtEntraceLocation.z) < 10 then
if not notifyCourtHouseIn then
TriggerServerEvent("jnj:requestJuror", true)
notifyCourtHouseIn = true
notifyCourtHouseOut = false
end
else
if not notifyCourtHouseOut then
TriggerServerEvent("jnj:requestJuror", false)
notifyCourtHouseIn = false
notifyCourtHouseOut = true
end
end
Citizen.Wait(1000)
end
end
end)

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if isJailedG then
if jailTimeG == 0 then
isJailedG = false
TriggerServerEvent("jnj:releaseFromJail", GetPlayerServerId(PlayerId()))
end
Citizen.Wait(1000 * 60)
jailTimeG = jailTimeG - 1
TriggerServerEvent("jnj:updateJailTime", jailTimeG)
end
end
end)

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if jailTimeG > 0 then
SetTextFont(0)
SetTextProportional(1)
SetTextScale(0.0, 0.3)
SetTextColour(128, 128, 128, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
if isJailedG then
AddTextComponentString("Jail Time Remaining: " .. tostring(jailTimeG) .. " Minutes")
else
AddTextComponentString("Jail Time Remaining: " .. tostring(jailTimeG) .. " Minutes - PAUSED")
end
DrawText(0.5, 0.005)
end
local courthouseBlip = AddBlipForCoord(JailConfig.courtEntraceLocation.x, JailConfig.courtEntraceLocation.y, JailConfig.courtEntraceLocation.z)
SetBlipSprite(courthouseBlip, 419)
SetBlipDisplay(courthouseBlip, 4)
SetBlipScale(courthouseBlip, 1.0)
SetBlipAsShortRange(courthouseBlip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Superior Court of " .. JailConfig.stateName)
EndTextCommandSetBlipName(courthouseBlip)
end
end)

AddEventHandler("playerSpawned", function(spawnInfo)
TriggerServerEvent("jnj:checkJailed")
end)
1 change: 1 addition & 0 deletions jailed.json
@@ -0,0 +1 @@
[]

0 comments on commit 4b0e9fa

Please sign in to comment.