[Outdated] [Release] Simple Police System [SQL] (Menu, Jail & Much more!)

OUTDATED

Simple Police System by Chezza

Information
Hey FiveM members, Today I release a Police System as stated above. The resource makes it so police can gain a better playing experience by the use of the menu that contains multiple options for players to access all in one. The menu contains: General Police Actions, Jail, Emotes and much more! (Images Below).

Configuration (Click the arrow to see)

Located in sv_polsystem.lua

local maxsecs = 500 -- Max seconds police can put people in jail for --
Perms/Ranks (Click the arrow to see)

Ranks (Only two for now more in the future if wanted)
Located in your Database in the Rank Column
’0’ - Not an Officer
’1’ - Normal police officer (Access to general actions and most options)
’2’ - Chief (Can add or remove other officers from the server)

Images (Click the arrow to see)

Main Menu (Normal Cop)

Actions Menu

Placeables Menu

Emote Menu

Main Menu (Chief Cop)

Requirements

Download

Installation

  • Install like any other FiveM Resource.
  • Then make sure to run the SQL file that is included in the resource to make it function correctly.
  • Join the game and it should create a new line in the database with your Steam Hex and rank next to it. Make sure to change the rank to 2 if you are an admin, so you can access the Police Management tab within the Menu.
  • Once done, load into your server and hit ‘F5’ and the menu should pop up. Happy policing ! :slight_smile:

Credits

Support

  • If you have any issues, suggestions or questions ask them below :slight_smile:

Changelog (Click the arrow to see)
  • 11/04/2019 | Added a Loadout tab under actions, where the officer can change their skin, also made it so it is no longer seconds in the Jail System it is now minutes (Displayed months in Chat to better the Roleplaying Experience). | Suggested by @NebelRebell & @hallux
14 Likes

is this dependent on any framework?

Are you really asking that question? If it required it you would know.

If not you you should say standalone

I haven’t looked at the code yet

Defiantly standalone you need WarMenu that’s it

You don’t need to look at the code.

im sorry but I tend to look at stuff before I add it to my server…lets not make a thing of it ok ??

how do i add perms

1 Like

Once you have added the resource make sure you have ran the SQL script in your database, then join the server and it should create a line in the police table (database) with your steam hex and edit the rank column to 1 or 2 depending on what you want as stated above in the main post in Perms/Ranks.

ok thanks

As much as I stay away from databases and such (Mainly cause I have no idea how to use them) this is actually a really neat menu and I might attempt to figure out exactly how to use it. Great work man!

1 Like

Missing Primerykey in SQL (DB)

Fix (drop table before using):
CREATE TABLE police (
identifier varchar(50) NOT NULL,
rank int(11) DEFAULT NULL,
PRIMARY KEY (identifier)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
;

NebelRebell wants to merge 1 commit into

1 Like

What is the default key for the menu and how will my members know that they have the rank after i set it on them

Insert this in your client.lua named cl_polsystem.lua

local Keys = {
[“ESC”] = 322, [“F1”] = 288, [“F2”] = 289, [“F3”] = 170, [“F5”] = 166, [“F6”] = 167, [“F7”] = 168, [“F8”] = 169,
[“F9”] = 56, [“F10”] = 57, ["~"] = 243, [“1”] = 157, [“2”] = 158, [“3”] = 160, [“4”] = 164, [“5”] = 165,
[“6”] = 159, [“7”] = 161, [“8”] = 162, [“9”] = 163, ["-"] = 84, ["="] = 83, [“BACKSPACE”] = 177, [“TAB”] = 37,
[“Q”] = 44, [“W”] = 32, [“E”] = 38, [“R”] = 45, [“T”] = 245, [“Y”] = 246, [“U”] = 303, [“P”] = 199, ["["] = 39,
["]"] = 40, [“ENTER”] = 18, [“CAPS”] = 137, [“A”] = 34, [“S”] = 8, [“D”] = 9, [“F”] = 23, [“G”] = 47, [“H”] = 74,
[“K”] = 311, [“L”] = 182, [“LEFTSHIFT”] = 21, [“Z”] = 20, [“X”] = 73, [“C”] = 26, [“V”] = 0, [“B”] = 29,
[“N”] = 249, [“M”] = 244, [","] = 82, ["."] = 81, [“LEFTCTRL”] = 36, [“LEFTALT”] = 19, [“SPACE”] = 22,
[“RIGHTCTRL”] = 70, [“HOME”] = 213, [“PAGEUP”] = 10, [“PAGEDOWN”] = 11, [“DELETE”] = 178, [“LEFT”] = 174,
[“RIGHT”] = 175, [“TOP”] = 27, [“DOWN”] = 173, [“NENTER”] = 201, [“N4”] = 108, [“N5”] = 60, [“N6”] = 107,
[“N+”] = 96, [“N-”] = 97, [“N7”] = 117, [“N8”] = 61, [“N9”] = 118
}

Default Key is 166 = F5

1 Like

If you use teh standard essentialmode Money & Job Hud change in warmenu-lua line 180 to

menus[id].x = 0.760
menus[id].y = 0.342	--Standard (Top-Right): menus[id].y = 0.042
menus[id].width = 0.23
1 Like

its not working

@Chezza Did even offert you an list with all the requirements

So no, only MySQL-Async and ofcourse all his dependencies.

Ciaoo’ :crossed_fingers:

Hey! I like the code, very clear, very basic, very easy to read. Good work on that end, the only suggestion I’d make is allowing people to use minutes to jail players, rather then using seconds. I haven’t tried it but something as the following may help.

RegisterServerEvent('jail')
AddEventHandler('jail', function(id1, time1)
	local pid = tonumber(id1)
	local time = tonumber(time1*60)
	if time > maxsecs then
		time = maxsecs
	end
	if GetPlayerName(pid) ~= nil then
		local playername = GetPlayerName(pid)
		TriggerClientEvent("jail", pid, time)
		TriggerClientEvent('chatMessage', -1, 'Jail', { 255, 0, 0 }, playername ..' has been jailed for '.. time ..' seconds.')
	else
		TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Incorrect player ID")
	end
end)

All i changed was one line at the tostring(time) to add *60 which would multiply the seconds to make it minutes so the player can simply do /jail id 5 and it’s 5 minutes.

Ps. It’s early here, I’m short on sleep…my logic may be fucked and I may have to refer back to my jailing script.

1 Like

I check your script and i really really like it. There are some changes and I send you pull request - if you like it.

If five Problems / Bug found:

Cops have the same skin (no idea how to change)
OffDuty old Character is gone - all OffDutyCops have same skin (no idea how to change)
Jail time is in Sekonds - Minutes are better, most servers give jail time like 10 - 30 minutes
The Objekts Prone are to fare away, maybe begin in front of the cop
PoliceMenu is in esssential Hud (Pullrequest)

Maybe you can change please something?

After a while running got this error

Error: Unhandled error in timer: Error: BUFFER_SHORTAGE
Error: BUFFER_SHORTAGE
    at n.e [as reserve] (citizen:/scripting/v8/msgpack.js:29:12766)
    at h (citizen:/scripting/v8/msgpack.js:29:15761)
    at n.r [as decode] (citizen:/scripting/v8/msgpack.js:29:13908)
    at n.fetch (citizen:/scripting/v8/msgpack.js:29:6972)
    at n.u [as read] (citizen:/scripting/v8/msgpack.js:29:12076)
    at Object.n [as decode] (citizen:/scripting/v8/msgpack.js:29:7097)
    at unpack (citizen:/scripting/v8/main.js:20:33)
    at citizen:/scripting/v8/main.js:51:20
    at setImmediate (mysql-async.js:4962:9)
    at Object.callback (citizen:/scripting/v8/timer.js:96:21)

[ERROR] [MySQL] [policesystem] An error happens on MySQL for query "[object Object]": ER_BAD_NULL_ERROR: Column 'identifier' cannot be null
Error: (node:8788) UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: unexpected PromiseRejectEvent
    at process.<anonymous> (internal/process/promises.js:27:25)
    at <anonymous>
    at Query.db.query [as _callback] (mysql-async.js:4973:13)
    at Query.Sequence.end (mysql-async.js:280:24)
    at Query.ErrorPacket (mysql-async.js:2122:8)
    at Protocol._parsePacket (mysql-async.js:5941:23)
    at Parser.write (mysql-async.js:6198:12)
    at Protocol.write (mysql-async.js:5701:16)
    at Socket.<anonymous> (mysql-async.js:693:28)
    at emitOne (events.js:116:13)
Error: (node:8788) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
Error: (node:8788) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Error: (node:8788) UnhandledPromiseRejectionWarning: Error: ER_BAD_NULL_ERROR: Column 'identifier' cannot be null
    at Query.Sequence._packetToError (mysql-async.js:244:14)
    at Query.ErrorPacket (mysql-async.js:2109:18)
    at Protocol._parsePacket (mysql-async.js:5941:23)
    at Parser.write (mysql-async.js:6198:12)
    at Protocol.write (mysql-async.js:5701:16)
    at Socket.<anonymous> (mysql-async.js:693:28)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    --------------------
    at Pool.query (mysql-async.js:4728:23)
    at Promise (mysql-async.js:4970:12)
    at new Promise (<anonymous>)
    at execute (mysql-async.js:4967:26)
    at Object.global.exports [as callback] (mysql-async.js:4985:5)
    at citizen:/scripting/v8/main.js:96:41
    at citizen:/scripting/v8/main.js:51:27
    at setImmediate (mysql-async.js:4962:9)
    at Object.callback (citizen:/scripting/v8/timer.js:96:21)
    at onTick (citizen:/scripting/v8/timer.js:121:27)
Error: (node:8788) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

Mysql is up to date also the scriptfiles. Get mass on errors, hope it will be fixed soon, is that we all need on roleplay servers :wink:

1 Like