From 79c6adffa142898b486886cdf45575f2243912c1 Mon Sep 17 00:00:00 2001 From: Glenn Hermans Date: Sun, 30 Sep 2018 19:05:30 +0200 Subject: [PATCH 1/2] Update README.md --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index d827118..fdfdb05 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,7 @@ When you restart your server you will see a mysql error inside your server conso ``` This is just confirmation that your new database column has been added. -## Commands -* /copadd ID : Add the player as cop to the database. -* /coprem ID : Remove a player from the database. -* /coprank ID Rank : To change the rank of a police officer. -* /copdept ID Department : Add a player to a specific department id. - +## Server Commands **You can also use these commands with RCON (`CopAdd` / `CopAddAdmin` / `CopRem` / `CopRank`). To see how to use them, just type the command you want without any parameter.** From e2b4512b0f3010a197d3e128cc38d2bd9a6ff19e Mon Sep 17 00:00:00 2001 From: ghermans Date: Sun, 30 Sep 2018 19:48:42 +0200 Subject: [PATCH 2/2] hotfix --- CHANGELOG.md | 3 +++ README.md | 12 ++++-------- police/__resource.lua | 4 ++-- police/server/server.lua | 38 +++++++++++++++++++++++++++++++++++--- 4 files changed, 44 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b509a86..d066acf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.4.4.2 +* Added missing command `CopDept`. + ## 1.4.4.2 * A fix has been provided regarding the mysql error `MySQL-async.js:209563: uncaught type error: cannot convert undefined or null object.` * The vehicles list in the garage will only display vehicles that are assigned to the players department. diff --git a/README.md b/README.md index 320269b..ae67fef 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Cops_FiveM -[![Version](https://img.shields.io/badge/Version-v1.4.4.1-brightgreen.svg)](https://github.com/FiveM-Scripts/Cops_FiveM/releases) +[![GitHub release](https://img.shields.io/github/release/FiveM-Scripts/Cops_FiveM.svg)](https://github.com/FiveM-Scripts/Cops_FiveM/releases/latest) [![GitHub license](https://img.shields.io/github/license/FiveM-Scripts/Cops_FiveM.svg)](https://github.com/FiveM-Scripts/Cops_FiveM/blob/master/LICENSE) Cops_FiveM is a script for RP server mainly. It let servers to have a cops system with loadout, vehicles, inventory check, ... @@ -32,13 +32,9 @@ When you restart your server you will see a mysql error inside your server conso This is just confirmation that your new database column has been added. ## Commands -* /copadd ID : Add the player as cop to the database. -* /coprem ID : Remove a player from the database. -* /coprank ID Rank : To change the rank of a police officer. -* /copdept ID Department : Add a player to a specific department id. - -**You can also use these commands with RCON (`CopAdd` / `CopAddAdmin` / `CopRem` / `CopRank`). -To see how to use them, just type the command you want without any parameter.** +You can use these commands with RCON (`CopAdd` / `CopAddAdmin` / `CopDept`/ `CopRem` / `CopRank`). +To see how to use them, just type the command you want without any parameter. + ## Departments | ID | Name | diff --git a/police/__resource.lua b/police/__resource.lua index ca81719..cd2247a 100644 --- a/police/__resource.lua +++ b/police/__resource.lua @@ -1,6 +1,6 @@ resource_manifest_version '05cfa83c-a124-4cfa-a768-c24a5811d8f9' -resource_version 'v1.4.5' -resource_versionNum '144' +resource_version '1.4.4.3' +resource_versionNum '1443' resource_Isdev 'no' dependency 'mysql-async' diff --git a/police/server/server.lua b/police/server/server.lua index ed232a1..b4e5e70 100644 --- a/police/server/server.lua +++ b/police/server/server.lua @@ -75,7 +75,7 @@ function setDept(source, player,playerDept) if(result[1].dept ~= playerDept) then MySQL.Async.execute("UPDATE police SET dept="..playerDept.." WHERE identifier='"..identifier.."'", { ['@identifier'] = identifier}) TriggerClientEvent('chatMessage', source, i18n.translate("title_notification"), {255, 0, 0}, i18n.translate("command_received")) - TriggerClientEvent("police:notify", player, "CHAR_ANDREAS", 1, i18n.translate("title_notification"), false, i18n.translate("new_dept")..config.departments.label[playerDept]) + TriggerClientEvent("police:notify", player, "CHAR_ANDREAS", 1, i18n.translate("title_notification"), false, i18n.translate("new_dept") .. " " .. config.departments.label[playerDept]) TriggerClientEvent('police:receiveIsCop', source, result[1].rank, playerDept) else TriggerClientEvent('chatMessage', source, i18n.translate("title_notification"), {255, 0, 0}, i18n.translate("same_dept")) @@ -352,7 +352,7 @@ RegisterCommand("CopRem", function(source,args,raw) end, true) RegisterCommand("CopRank", function(source,args,raw) - if #args ~= 1 and #args ~= 2 then + if #args ~= 2 then RconPrint("Usage: CopRank [ingame-id] [rank]\n") CancelEvent() return @@ -382,6 +382,38 @@ RegisterCommand("CopRank", function(source,args,raw) end end, true) +RegisterCommand("CopDept", function(source,args,raw) + if #args ~= 2 then + RconPrint("Usage: CopDept [ingame-id] [department]\n") + CancelEvent() + return + else + if(GetPlayerName(tonumber(args[1])) == nil) then + RconPrint("Player is not ingame\n") + CancelEvent() + return + end + + local identifier = getPlayerID(tonumber(args[1])) + MySQL.Async.fetchAll("SELECT * FROM police WHERE identifier = @identifier", { ['@identifier'] = identifier}, function (result) + if(result[1]) then + if(GetPlayerName(tonumber(args[1])) ~= nil) then + local player = tonumber(args[1]) + local dept = tonumber(args[2]) + + setDept(args[1], player, dept) + else + TriggerClientEvent('chatMessage', args[1], i18n.translate("title_notification"), {255, 0, 0}, i18n.translate("no_player_with_this_id")) + end + else + TriggerClientEvent('chatMessage', args[1], i18n.translate("title_notification"), {255, 0, 0}, i18n.translate("not_enough_permission")) + end + end) + + CancelEvent() + end +end, true) + function getPlayerID(source) local identifiers = GetPlayerIdentifiers(source) local player = getIdentifiant(identifiers) @@ -392,4 +424,4 @@ function getIdentifiant(id) for _, v in ipairs(id) do return v end -end +end \ No newline at end of file