Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #139 from FiveM-Scripts/ghmattimysql
Browse files Browse the repository at this point in the history
v1.4.4.4
  • Loading branch information
ghermans authored Oct 13, 2018
2 parents e1f8513 + 7aa9fdd commit f1149fe
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 287 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.4.4.4
* Removed support for `mysql-async` and replaced it with `ghmattimysql` for better performance.
* Removed support for additional resources (Vdk_inventory, JobSystem, es_weashop, garages, emergency).

## 1.4.4.3
* Added missing command `CopDept`.

Expand Down
27 changes: 8 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Cops_FiveM
[![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)
[![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, ...
You can find the complete list with all the features [here](docs/features.md).
Cops_FiveM is a resource mainly for RP servers. It gives servers a cops system with loadouts, vehicles, fines, ...
You can find a complete overview with all the features [here](docs/features.md).

## Changelog
You can find the changelog [here](CHANGELOG.md).
Expand All @@ -13,23 +12,16 @@ A Discord server is available: [![](https://discordapp.com/api/guilds/3611441236

## Requirements
- [Mysql](https://dev.mysql.com/downloads/mysql/)
- [Mysql-Async](https://forum.fivem.net/t/beta-mysql-async-library-v0-2-2/21881)
- [ghmattimysql](https://github.com/GHMatti/ghmattimysql)

## Installation
1. Verify that you have installed the requirements from above.
2. Download the latest version from the [GitHub repository](https://github.com/FiveM-Scripts/Cops_FiveM/releases/latest).
3. Only copy the subdirectory *police* to the *resources* folder on your server.
4. Edit [config file](https://github.com/FiveM-Scripts/Cops_FiveM/blob/master/police/config/config.lua) as you want.
4. Edit [config file](https://github.com/FiveM-Scripts/Cops_FiveM/blob/master/police/config/config.lua) to your preferences.
5. Add *start police* in your server.cfg (make sure you start this resource after all dependencies).
6. The first time when you enter the game you will need to add yourself to the police database.
you can do this in your server console enter `CopAddAdmin 1` press enter and you should receive a confirmation message.

### Important
When you restart your server you will see a mysql error inside your server console.
```
[ERROR] [MySQL] An error happens on MySQL for query "ALTER TABLE police ADD dept int(11) NOT NULL DEFAULT '0' {=}": Duplicate column name 'dept'
```
This is just confirmation that your new database column has been added.
you can do this in your server console enter `CopAddAdmin 1` or `CopAdd 1` press **enter** and you should receive a confirmation message.

## Commands
You can use these commands with RCON (`CopAdd` / `CopAddAdmin` / `CopDept`/ `CopRem` / `CopRank`).
Expand Down Expand Up @@ -57,11 +49,8 @@ To see how to use them, just type the command you want without any parameter.
| 7 | Admin Police Rank|

## Contribute
If you are a developer and would like to contribute any help is welcome!.
If you are a developer and would like to contribute any help is welcome!.
The contribution guide can be found [here](https://github.com/Kyominii/Cops_FiveM/blob/master/CONTRIBUTING.md).
(Readme, Contributing and Changelog files from by [FiveM Script](https://github.com/FiveM-Scripts/), thanks ^^).

## Supported Scripts
you can find some supported scripts [here](docs/scripts.md).

### Thanks to the whole community of FiveM which help to improve this script
you can find some supported scripts [here](docs/scripts.md).
40 changes: 4 additions & 36 deletions docs/scripts.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Supported scripts
* [mysql-async](https://forum.fivem.net/t/beta-mysql-async-library-v0-2-2/21881)
* [fs_freemode](https://github.com/FiveM-Scripts/fs_freemode)
* [Vdk_inventory](https://forum.fivem.net/t/release-inventory-system-v1-4/14477) (legacy script)
* [ghmattimysql](https://github.com/GHMatti/ghmattimysql)
* [Simple Banking](https://forum.fivem.net/t/release-simple-banking-2-0-now-with-gui/13896) (legacy script)

If you are using this script, add this piece of code in server.lua (banking)
If you are using Simple Banking, add this piece of code in **server.lua**


```lua
Expand All @@ -28,37 +27,6 @@ AddEventHandler('bank:withdrawAmende', function(amount)
end)
end)
```

* [JobSystem](https://forum.fivem.net/t/release-jobs-system-v1-0-and-paycheck-v2-0/14054) (legacy script)
* [Venomous Freemode](https://github.com/FiveM-Scripts/venomous-freemode)
* [Skin Customization](https://forum.fivem.net/t/release-skin-customization-v1-0/16491) (legacy script)
* [Player in db](https://forum.fivem.net/t/release-nameofplayers-v-1-get-name-of-players-in-database/17983) (legacy script)
* [es_weashop](https://forum.fivem.net/t/release-es-weapon-store-v1-1/12195) (legacy script)
* [garages](https://forum.fivem.net/t/release-garages-v4-1-fr-en-03-06-17-updated/13066) (legacy script)
* [emergency](https://forum.fivem.net/t/release-job-save-people-be-a-hero-paramedic-emergency-coma-ko/19773) (legacy script)

If you are using this script, add this piece of code in cl_healthplayer.lua (line 196 -- function ResPlayer() -- emergency)

```lua
TriggerEvent("es_em:cl_ResPlayer")
```

* [Heli Script](https://forum.fivem.net/t/release-heli-script/24094) : it is not really "supported" because it's working without anything, but I recommand this script for the cop helicopter
* [gc_identity](https://github.com/Gannon001/gcidentity)

If you are using this script, add this event in server.lua (gc_identity)
```lua
RegisterServerEvent('gc:copOpenIdentity')
AddEventHandler('gc:copOpenIdentity',function(other)
local data = getIdentity(other)
if data ~= nil then
TriggerClientEvent('gc:showItentity', source, {
nom = data.nom,
prenom = data.prenom,
sexe = data.sexe,
dateNaissance = tostring(data.dateNaissance),
jobs = data.jobs,
taille = data.taille
})
end
end)
```
* [Player in db](https://forum.fivem.net/t/release-nameofplayers-v-1-get-name-of-players-in-database/17983) (legacy script)
6 changes: 3 additions & 3 deletions police/__resource.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource_manifest_version '05cfa83c-a124-4cfa-a768-c24a5811d8f9'
resource_version '1.4.4.3'
resource_versionNum '1443'
resource_version '1.4.4.4'
resource_versionNum '1444'
resource_Isdev 'no'

dependency 'mysql-async'
dependency 'ghmattimysql'

ui_page('client/html/index.html')

Expand Down
56 changes: 7 additions & 49 deletions police/client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,6 @@ AddEventHandler('police:receiveIsCop', function(svrank,svdept)
load_armory()
load_garage()
load_menu()
if(rank >= config.rank.min_rank_set_rank) then
TriggerEvent('chat:addSuggestion', "/copadd", "Add a cop into the whitelist", {{name = "id", help = "The ID of the player"}})
TriggerEvent('chat:addSuggestion', "/coprem", "Remove a cop from the whitelist", {{name = "id", help = "The ID of the player"}})
TriggerEvent('chat:addSuggestion', "/coprank", "Set rank of a cop officier", {{name = "id", help = "The ID of the player"}, {name = "rank", help = "The numeric value of the rank"}})
TriggerEvent('chat:addSuggestion', "/copdept", "Set rank of a cop officier", {{name = "id", help = "The ID of the player"}, {name = "dept", help = "The numeric value of the department"}})
else
TriggerEvent('chat:removeSuggestion', "/copadd")
TriggerEvent('chat:removeSuggestion', "/coprem")
TriggerEvent('chat:removeSuggestion', "/coprank")
TriggerEvent('chat:removeSuggestion', "/copdept")
end
end
end)

Expand Down Expand Up @@ -131,11 +120,6 @@ if(config.useCopWhitelist == true) then
Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(policeHeli))
policeHeli = nil
end

TriggerEvent('chat:removeSuggestion', "/copadd")
TriggerEvent('chat:removeSuggestion', "/coprem")
TriggerEvent('chat:removeSuggestion', "/coprank")
TriggerEvent('chat:removeSuggestion', "/copdept")

ServiceOff()
end)
Expand All @@ -145,9 +129,9 @@ RegisterNetEvent('police:getArrested')
AddEventHandler('police:getArrested', function()
handCuffed = not handCuffed
if(handCuffed) then
TriggerEvent("police:notify", "CHAR_ANDREAS", 1, i18n.translate("title_notification"), false, i18n.translate("now_cuffed"))
TriggerEvent("police:notify", "CHAR_AGENT14", 1, i18n.translate("title_notification"), false, i18n.translate("now_cuffed"))
else
TriggerEvent("police:notify", "CHAR_ANDREAS", 1, i18n.translate("title_notification"), false, i18n.translate("now_uncuffed"))
TriggerEvent("police:notify", "CHAR_AGENT14", 1, i18n.translate("title_notification"), false, i18n.translate("now_uncuffed"))
drag = false
end
end)
Expand Down Expand Up @@ -199,19 +183,12 @@ end)
-- Copy/paste from fs_freemode (by FiveM-Script: https://github.com/FiveM-Scripts/fs_freemode)
RegisterNetEvent("police:notify")
AddEventHandler("police:notify", function(icon, type, sender, title, text)
SetNotificationTextEntry("STRING");
AddTextComponentString(text);
SetNotificationMessage(icon, icon, true, type, sender, title, text);
DrawNotification(false, true);
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
SetNotificationMessage(icon, icon, true, type, sender, title, text)
DrawNotification(false, true)
end)

if(config.useVDKInventory == true) then
RegisterNetEvent('police:dropIllegalItem')
AddEventHandler('police:dropIllegalItem', function(id)
TriggerEvent("player:looseItem", tonumber(id), exports.vdk_inventory:getQuantity(id))
end)
end

--Piece of code given by Thefoxeur54
RegisterNetEvent('police:unseatme')
AddEventHandler('police:unseatme', function(t)
Expand Down Expand Up @@ -266,19 +243,6 @@ if(config.enableOtherCopsBlips == true) then
end)
end

if(config.useModifiedEmergency == true) then
RegisterNetEvent('es_em:cl_ResPlayer')
AddEventHandler('es_em:cl_ResPlayer', function()
if(isCop and isInService) then
ServiceOff()
end

if(handCuffed == true) then
handCuffed = false
end
end)
end

--
--Functions
--
Expand Down Expand Up @@ -488,20 +452,14 @@ end

function ServiceOn()
isInService = true
if(config.useJobSystem == true) then
TriggerServerEvent("jobssystem:jobs", config.job.officer_on_duty_job_id)
end
TriggerServerEvent("police:takeService")
end

function ServiceOff()
isInService = false
if(config.useJobSystem == true) then
TriggerServerEvent("jobssystem:jobs", config.job.officer_not_on_duty_job_id)
end
TriggerServerEvent("police:breakService")

if(config.enableOtherCopsBlips == true) then
if config.enableOtherCopsBlips == true then
allServiceCops = {}

for k, existingBlip in pairs(blipsCops) do
Expand Down
35 changes: 0 additions & 35 deletions police/client/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ function load_menu()
buttonsAnimation[#buttonsAnimation+1] = {name = i18n.translate("menu_anim_Cancel_emote_title"), func = 'CancelEmote', params = ""}

--Citizens
if(config.useGcIdentity == true) then
buttonsCitizen[#buttonsCitizen+1] = {name = i18n.translate("menu_id_card_title"), func = 'CheckId', params = ""}
end

if(config.useVDKInventory == true or config.useWeashop == true) then
buttonsCitizen[#buttonsCitizen+1] = {name = i18n.translate("menu_check_inventory_title"), func = 'CheckInventory', params = ""}
end

buttonsCitizen[#buttonsCitizen+1] = {name = i18n.translate("menu_weapons_title"), func = 'RemoveWeapons', params = ""}
buttonsCitizen[#buttonsCitizen+1] = {name = i18n.translate("menu_toggle_cuff_title"), func = 'ToggleCuff', params = ""}
buttonsCitizen[#buttonsCitizen+1] = {name = i18n.translate("menu_force_player_get_in_car_title"), func = 'PutInVehicle', params = ""}
Expand All @@ -86,11 +78,6 @@ function load_menu()
buttonsFine[#buttonsFine+1] = {name = "$8000", func = 'Fines', params = 8000}
buttonsFine[#buttonsFine+1] = {name = "$10000", func = 'Fines', params = 10000}
buttonsFine[#buttonsFine+1] = {name = i18n.translate("menu_custom_amount_fine_title"), func = 'Fines', params = -1}

--Vehicles
if(config.enableCheckPlate == true) then
buttonsVehicle[#buttonsVehicle+1] = {name = i18n.translate("menu_check_plate_title"), func = 'CheckPlate', params = ""}
end

buttonsVehicle[#buttonsVehicle+1] = {name = i18n.translate("menu_crochet_veh_title"), func = 'Crochet', params = ""}
buttonsVehicle[#buttonsVehicle+1] = {name = "Spike Stripes", func = 'SpawnSpikesStripe', params = ""}
Expand Down Expand Up @@ -155,15 +142,6 @@ function CheckInventory()
end
end

function CheckId()
local t , distance = GetClosestPlayer()
if(distance ~= -1 and distance < 3) then
TriggerServerEvent('gc:copOpenIdentity', GetPlayerServerId(t))
else
TriggerEvent('chatMessage', i18n.translate("title_notification"), {255, 0, 0}, i18n.translate("no_player_near_ped"))
end
end

function RemoveWeapons()
local t, distance = GetClosestPlayer()
if(distance ~= -1 and distance < 3) then
Expand Down Expand Up @@ -313,19 +291,6 @@ function DeleteSpike()
end
end

function CheckPlate()
local pos = GetEntityCoords(PlayerPedId())
local entityWorld = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 20.0, 0.0)

local rayHandle = CastRayPointToPoint(pos.x, pos.y, pos.z, entityWorld.x, entityWorld.y, entityWorld.z, 10, PlayerPedId(), 0)
local _, _, _, _, vehicleHandle = GetRaycastResult(rayHandle)
if(DoesEntityExist(vehicleHandle)) then
TriggerServerEvent("police:checkingPlate", GetVehicleNumberPlateText(vehicleHandle))
else
drawNotification(i18n.translate("no_veh_near_ped"))
end
end

local propslist = {}

function SpawnProps(model)
Expand Down
6 changes: 0 additions & 6 deletions police/config/config.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
config = {
enableVersionNotifier = true, --notify if a new version is available (server console)

useModifiedEmergency = false, --require modified emergency script
useModifiedBanking = false, --require Simple Banking
useVDKInventory = false, --require VDK Inventory script
useGcIdentity = false, --require GCIdentity
enableOutfits = false, --require Skin Customization
useJobSystem = false, -- require job system
useWeashop = false, -- require es_weashop

stationBlipsEnabled = true, -- switch between true or false to enable/disable blips for police stations
useCopWhitelist = true,
enableCheckPlate = false, --require garages

enableOtherCopsBlips = true,
useNativePoliceGarage = true,
Expand Down
Loading

0 comments on commit f1149fe

Please sign in to comment.