mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
Add files via upload
This commit is contained in:
24
ND_Jailing/config_client.lua
Normal file
24
ND_Jailing/config_client.lua
Normal 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
ND_Jailing/config_server.lua
Normal file
3
ND_Jailing/config_server.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
config = {
|
||||
discordWebhook = "https://discord.com/api/webhooks/873744008122335252/zk53XWv0ZfD-BD2Su6VYGPzUgNW0NjLrj7hVBQFVgp_ByO0f0rpMwx7fsNNNjyVp4GUT",
|
||||
}
|
||||
38
ND_Jailing/fxmanifest.lua
Normal file
38
ND_Jailing/fxmanifest.lua
Normal 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
ND_Jailing/source/client.lua
Normal file
151
ND_Jailing/source/client.lua
Normal 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
ND_Jailing/source/server.lua
Normal file
36
ND_Jailing/source/server.lua
Normal 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
ND_Jailing/source/ui/index.html
Normal file
31
ND_Jailing/source/ui/index.html
Normal 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
ND_Jailing/source/ui/js/jquery-3.6.0.min.js
vendored
Normal file
2
ND_Jailing/source/ui/js/jquery-3.6.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
60
ND_Jailing/source/ui/js/listener.js
Normal file
60
ND_Jailing/source/ui/js/listener.js
Normal 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
ND_Jailing/source/ui/style.css
Normal file
87
ND_Jailing/source/ui/style.css
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user