Add files via upload

This commit is contained in:
Andyyy7666 authored and GitHub committed 2022-03-10 18:25:57 +01:00
1 parent 6d7cd2e3f7
commit 7eb2721824
9 files changed
+432

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
config = {
maxJailTime = 10, -- Max time in seconds that someone can jail another player.
jailDistance = 90.0, -- How far can the player go from the Jail coordinates. If the player is further than the set amount they will be teleported back.
jailCoords = {x = 1680.21, y = 2513.25, z = 44.56, h = 6.53},
releaseCoords = {x = 1840.22, y = 2608.42, z = 45.58, h = 270.09},
-- Where can players access it from.
accessLocation = {
{x = -449.61, y = 6012.42, z = 31.72}, -- Paleto Bay Sheriff's Office
{x = 1853.08, y = 3690.2, z = 34.27}, -- Sandy Shores Sheriff's Office
{x = 459.84, y = -989.15, z = 24.91}, -- Mission Row PD
},
-- Departments that can access the jail tablet.
accessDepartments = {
"SAHP",
"LSPD",
"BCSO"
},
-- How close does the player have to be to the coordiantes to be able to open the tablet.
accessDistance = 0.5,
}
+3
View File
@@ -0,0 +1,3 @@
config = {
discordWebhook = "https://discord.com/api/webhooks/873744008122335252/zk53XWv0ZfD-BD2Su6VYGPzUgNW0NjLrj7hVBQFVgp_ByO0f0rpMwx7fsNNNjyVp4GUT",
}
+38
View File
@@ -0,0 +1,38 @@
------------------------------------------------------------------------
------------------------------------------------------------------------
-- DO NOT EDIT IF YOU DON'T KNOW WHAT YOU'RE DOING --
-- --
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6 --
------------------------------------------------------------------------
------------------------------------------------------------------------
version "1.0"
description "Jail tablet"
author "Andyyy#7666"
fx_version "cerulean"
game "gta5"
lua54 "yes"
escrow_ignore {
"config_client.lua",
"config_server.lua"
}
ui_page "source/ui/index.html"
files {
"source/ui/index.html",
"source/ui/js/jquery-3.6.0.min.js",
"source/ui/js/listener.js",
"source/ui/style.css"
}
server_scripts {
"source/server.lua",
"config_server.lua"
}
client_scripts {
"source/client.lua",
"config_client.lua"
}
+151
View File
@@ -0,0 +1,151 @@
local display = false
local isJailed = false
function SetDisplay(bool)
display = bool
SetNuiFocus(bool, bool)
SendNUIMessage({
type = "ui",
status = bool
})
end
function alert(msg)
BeginTextCommandDisplayHelp("STRING")
AddTextComponentSubstringPlayerName(msg)
EndTextCommandDisplayHelp(0, 0, 1, -1)
end
-- Jail a player and loop to keep them in jail every second.
RegisterNetEvent("ND_Jailing:jailPlayer")
AddEventHandler("ND_Jailing:jailPlayer", function(time)
local player = PlayerPedId()
isJailed = true
SetEntityCoords(player, config.jailCoords.x, config.jailCoords.y, config.jailCoords.z, false, false, false, false)
SetEntityHeading(player, config.jailCoords.h)
while isJailed do
time = time -1
local pedCoords = GetEntityCoords(player)
if #(pedCoords - vector3(config.jailCoords.x, config.jailCoords.y, config.jailCoords.z)) > config.jailDistance then
SetEntityCoords(player, config.jailCoords.x, config.jailCoords.y, config.jailCoords.z, false, false, false, false)
end
if time == 0 then
SetEntityCoords(player, config.releaseCoords.x, config.releaseCoords.y, config.releaseCoords.z, false, false, false, false)
SetEntityHeading(player, config.releaseCoords.h)
Citizen.Wait(100)
TaskGoStraightToCoord(player, config.releaseCoords.x + 10, config.releaseCoords.y, config.releaseCoords.z, 1.0, 8000, config.releaseCoords.h, 0)
isJailed = false
end
Citizen.Wait(1000)
end
end)
-- Chat suggestion for command.
TriggerEvent("chat:addSuggestion", "/jail", "Jail a player", {
{name="Id", help="Player Id"},
{name="time", help="time to jail (seconds)"},
{name="Reason", help="Short reason or list of charges."}
})
-- Same jail function but with a command.
RegisterCommand("jail", function(source, args, rawCommand)
local id = tonumber(args[1])
local time = tonumber(args[2])
local reason = args[3]
local hasAccess = false
for _, dept in pairs(config.accessDepartments) do
if exports["ND_Core"]:getCharacterInfo(6) == dept then
hasAccess = true
break
end
end
if hasAccess then
local name = GetPlayerName(GetPlayerFromServerId(id))
if not GetPlayerFromServerId(id) then
TriggerEvent("chat:addMessage", {
color = { 255, 0, 0},
multiline = true,
args = {"[Error]", "couldn't find a player with id " .. id .. "."}
})
elseif time > config.maxJailTime then
TriggerEvent("chat:addMessage", {
color = { 255, 0, 0},
multiline = true,
args = {"[Error]", "max time to jail is: " .. config.maxJailTime .. " seconds."}
})
elseif time <= config.maxJailTime then
TriggerServerEvent("jailPlayer", id, name, time, reason)
SetDisplay(false)
end
else
TriggerEvent("chat:addMessage", {
color = { 255, 0, 0},
multiline = true,
args = {"[Error]", "You don't have permission to use this command."}
})
end
end, false)
-- Return list of all players on the server and open ui.
RegisterNetEvent("ND_Jailing:returnPlayers")
AddEventHandler("ND_Jailing:returnPlayers", function(players)
for _, player in pairs(players) do
SendNUIMessage({
type = "players",
players = player,
})
end
SetDisplay(true)
end)
-- Check permission and distance of player.
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local pedCoords = GetEntityCoords(PlayerPedId())
for locations in pairs(config.accessLocation) do
if #(pedCoords - vector3(config.accessLocation[locations].x, config.accessLocation[locations].y, config.accessLocation[locations].z)) < config.accessDistance then
for _, dept in pairs(config.accessDepartments) do
if exports["ND_Core"]:getCharacterInfo(6) == dept then
if not display then
alert("Press ~INPUT_CONTEXT~ to open the jail ui")
end
if IsControlJustPressed(1, 51) then
TriggerServerEvent("ND_Jailing:getPlayers")
end
end
end
end
end
end
end)
-- When form is submitted.
RegisterNUICallback("sumbit", function(data)
local id = tonumber(string.sub(data.id, 2, string.find(data.id, ")") - 1))
local time = tonumber(data.time)
local reason = data.reason
local name = GetPlayerName(GetPlayerFromServerId(id))
if time > config.maxJailTime then
SendNUIMessage({
error = "Error: max time to jail is: " .. config.maxJailTime .. " seconds."
})
Citizen.Wait(5000)
SendNUIMessage({
error = ""
})
else
TriggerServerEvent("ND_Jailing:jailPlayer", id, name, time, reason)
SendNUIMessage({
type = "clean"
})
SetDisplay(false)
end
end)
-- Close ui.
RegisterNUICallback("closeUI", function(data)
SetDisplay(false)
end)
+36
View File
@@ -0,0 +1,36 @@
function sendToDiscord(name, message, color)
local embed = {
{
title = name,
description = message,
footer = {
icon_url = "https://i.imgur.com/notBtrZ.png",
text = "Created by Andyyy#7666"
},
color = color
}
}
PerformHttpRequest(config.discordWebhook, function(err, text, headers) end, 'POST', json.encode({username = "ND Jailing", embeds = embed}), {["Content-Type"] = "application/json"})
end
-- Jail player discord log, trigger the even on the players client and send a message to everyone.
RegisterNetEvent("ND_Jailing:jailPlayer")
AddEventHandler("ND_Jailing:jailPlayer", function(id, name, time, reason)
TriggerClientEvent("ND_Jailing:jailPlayer", id, time)
sendToDiscord("Jail Logs", "**" .. GetPlayerName(source) .. "** Jailed **" .. name .. "** for **" .. time .. " seconds** with the reason: **" .. reason .. "**.", 1595381)
TriggerClientEvent('chat:addMessage', -1, {
color = { 255, 0, 0},
multiline = true,
args = {"[Judge]", name .. " was charaged with " .. reason .. " and will be spending " .. time .. " months in jail."}
})
end)
-- Gets all players on the server and adds them to a table.
RegisterNetEvent("ND_Jailing:getPlayers")
AddEventHandler("ND_Jailing:getPlayers", function()
local players = {}
for _, id in pairs(GetPlayers()) do
players[id] = "(" .. id .. ") " .. GetPlayerName(id)
end
TriggerClientEvent("ND_Jailing:returnPlayers", source, players)
end)
+31
View File
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
<script src="js/jquery-3.6.0.min.js" type="text/javascript"></script>
<script src="js/listener.js" type="text/javascript"></script>
</head>
<body>
<form id="overlay">
<p id="title">Jail Interface</p>
<hr id="line">
<div style="margin-top: 2vh; margin-left: 6.5vw;">
<label class="text" style="margin-right: 15.7vw;" for="playerid">Player id</label>
<select id="id" class="input" style="margin-right: 4.1vw;" name="Player" required>
</select>
<label class="text" style="margin-right: 15.7vw;" for="jailtime">Time</label>
<input id="time" class="input" style="margin-right: 4.1vw;" type="number" placeholder="In seconds" name="jailtime" min="1" required>
<label class="text" style="margin-right: 15.7vw;" for="reason">Reason</label>
<input id="reason" class="input" style="margin-right: 4.1vw;" type="text" placeholder="short reason" name="reason" required>
</div>
<hr id="line" style="margin-top: 5vh;">
<p id="error"></p>
<button class="resetButton" type="reset">Close</button>
<button class="submitButton" type="submit" form="overlay">Jail</button>
</form>
</body>
</html>
+2
View File
@@ -0,0 +1,2 @@
/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0<t&&t-1 in e)}S.fn=S.prototype={jquery:f,constructor:S,length:0,toArray:function(){return s.call(this)},get:function(e){return null==e?s.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=S.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return S.each(this,e)},map:function(n){return this.pushStack(S.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(s.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(S.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(S.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(0<=n&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:u,sort:t.sort,splice:t.splice},S.extend=S.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||m(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)r=e[t],"__proto__"!==t&&a!==r&&(l&&r&&(S.isPlainObject(r)||(i=Array.isArray(r)))?(n=a[t],o=i&&!Array.isArray(n)?[]:i||S.isPlainObject(n)?n:{},i=!1,a[t]=S.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},S.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==o.call(e))&&(!(t=r(e))||"function"==typeof(n=v.call(t,"constructor")&&t.constructor)&&a.call(n)===l)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t,n){b(e,{nonce:t&&t.nonce},n)},each:function(e,t){var n,r=0;if(p(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},makeArray:function(e,t){var n=t||[];return null!=e&&(p(Object(e))?S.merge(n,"string"==typeof e?[e]:e):u.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:i.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(p(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return g(a)},guid:1,support:y}),"function"==typeof Symbol&&(S.fn[Symbol.iterator]=t[Symbol.iterator]),S.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){n["[object "+t+"]"]=t.toLowerCase()});var d=function(n){var e,d,b,o,i,h,f,g,w,u,l,T,C,a,E,v,s,c,y,S="sizzle"+1*new Date,p=n.document,k=0,r=0,m=ue(),x=ue(),A=ue(),N=ue(),j=function(e,t){return e===t&&(l=!0),0},D={}.hasOwnProperty,t=[],q=t.pop,L=t.push,H=t.push,O=t.slice,P=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},R="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",I="(?:\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",W="\\["+M+"*("+I+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+I+"))|)"+M+"*\\]",F=":("+I+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+W+")*)|.*)\\)|)",B=new RegExp(M+"+","g"),$=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),_=new RegExp("^"+M+"*,"+M+"*"),z=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^Line truncated
+60
View File
@@ -0,0 +1,60 @@
$(document).ready(function() {
function display(bool) {
if (bool) {
$("#overlay").fadeIn("slow");
} else {
$("#overlay").fadeOut("slow");
}
}
display(false)
window.addEventListener('message', function(event) {
var item = event.data;
if (item.type === "ui") {
if (item.status == true) {
display(true)
} else {
display(false)
}
}
$("#error").text(item.error);
if (item.type === "players") {
$("#id").append($("<option>", {
text: item.players
}));
}
if (item.type === "clean") {
$("#id").empty();
$("#overlay").reset();
}
})
$("#overlay").submit(function() {
let id = $("#id").val();
let time = $("#time").val();
let reason = $("#reason").val();
$.post(`https://${GetParentResourceName()}/sumbit`, JSON.stringify({
id: id,
time: time,
reason: reason
}));
return false
})
$(".resetButton").click(function() {
$.post(`https://${GetParentResourceName()}/closeUI`);
$("#id").empty();
return
})
document.onkeyup = function(data) {
if (data.which == 27) {
$.post(`https://${GetParentResourceName()}/closeUI`);
$("#id").empty();
return
}
};
});
+87
View File
@@ -0,0 +1,87 @@
#overlay {
height: 50vh;
width: 50vw;
margin-top: 15vh;
margin-left: 24vw;
background-color: rgba(2, 2, 2, 0.911);
border-radius: 3vh;
}
#title {
padding-top: 2vh;
margin-left: 3vw;
color: white;
font-size: 120%;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-weight: bold;
}
#line {
background: rgb(255, 255, 255);
background: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, rgba(255,255,255,1) 15%, rgba(255,255,255,1) 85%, rgba(0, 0, 0, 0) 100%);
height: 0.1vh;
width: 95%;
border: none;
border-radius: 2vh;
}
.text {
color: white;
display: inline-block;
margin-top: 2vh;
margin-bottom: 1vh;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-weight: bold;
}
.input {
background: white;
color: black;
display: inline-block;
border: none;
border-radius: 0.2vw;
height: 4vh;
width: 80%;
}
.submitButton {
margin-top: 1vh;
margin-right: 0.3vw;
float: right;
width: 6vw;
background-color: rgb(17, 113, 238);
}
.resetButton {
margin-top: 1vh;
margin-right: 8.5vw;
float: right;
width: 4vw;
background-color: rgb(231, 50, 50);
}
.submitButton, .resetButton {
height: 4vh;
color: white;
font-weight: bold;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
border: none;
border-radius: 1vh;
transition: 0.3s;
}
.submitButton:hover, .resetButton:hover {
transition: 0.3s;
opacity: 0.7;
}
.submitButton:active, .resetButton:active {
transition: none;
opacity: 1;
}
#error {
margin-left: 6.4vw;
color: white;
display: inline-block;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-weight: bold;
}