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 #156 from FiveM-Scripts/hotfix
Browse files Browse the repository at this point in the history
1.4.6
  • Loading branch information
ghermans authored Mar 18, 2019
2 parents 0c4ad88 + 4a77607 commit c099006
Show file tree
Hide file tree
Showing 13 changed files with 237 additions and 110 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.4.6
* Undercover cops are using their own skin instead of a random model, but still receive the basic kit loadout.
* Players who are cuffed can walk.
* Added more objects to be spawned.
* Fixed a bug where ghmattimysql was still being used when whitelist is disabled.

## 1.4.5
* Improved the menu theme.
* Resolved a issue where cop skins would not be displayed inside **the police locker room menu** when whitelisting is disabled.
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@ You can find the latest changes [here](CHANGELOG.md).
A Discord server is available: [![](https://discordapp.com/api/guilds/361144123681538060/widget.png)](https://discord.gg/qnAqCEd)

## Requirements
- [Mysql](https://dev.mysql.com/downloads/mysql/)
- [ghmattimysql](https://github.com/GHMatti/ghmattimysql)
If you are using a database then you need to setup **ghmattimysql** you can start using Cops_FiveM.
Are you using **ZAP-Hosting** and don't know what your database name/username/password is then [watch this video](https://www.youtube.com/watch?v=4UcC9zNZkFc).

- Download [ghmattimysql](https://github.com/GHMatti/ghmattimysql/releases/download/1.1.0/ghmattimysql.zip)
- Extract the zipfile and make sure that the folder is named **ghmattimysql**.
- Open ghmattimysql/config.json and edit the config lines with your db name/user/password/host.
- Copy the **ghmattimysql** folder to resources/.
- Open server.cfg and add **start 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) to your preferences.
5. Add *start police* in your server.cfg (make sure you start this resource after all dependencies).
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 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` or `CopAdd 1` press **enter** and you should receive a confirmation message.

Expand Down
9 changes: 4 additions & 5 deletions police/__resource.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
resource_manifest_version '05cfa83c-a124-4cfa-a768-c24a5811d8f9'
resource_version '1.4.5'
resource_versionNum '145'
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
resource_version '1.4.6'
resource_versionNum '146'
resource_Isdev 'no'

dependency 'ghmattimysql'
resource_fname 'Cops FiveM'

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

Expand Down
10 changes: 7 additions & 3 deletions police/client/armory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ function createArmoryPed()
end

function giveBasicKit()
GiveWeaponToPed(PlayerPedId(), GetHashKey("WEAPON_STUNGUN"), -1, true, true)
GiveWeaponToPed(PlayerPedId(), GetHashKey("WEAPON_NIGHTSTICK"), -1, true, true)
GiveWeaponToPed(PlayerPedId(), GetHashKey("WEAPON_FLASHLIGHT"), 200, true, true)
GiveWeaponToPed(PlayerPedId(), GetHashKey("WEAPON_PISTOL"), -1, true, false)
GiveWeaponToPed(PlayerPedId(), GetHashKey("WEAPON_STUNGUN"), -1, true, false)
GiveWeaponToPed(PlayerPedId(), GetHashKey("WEAPON_NIGHTSTICK"), -1, true, false)
GiveWeaponToPed(PlayerPedId(), GetHashKey("WEAPON_FLASHLIGHT"), 200, true, false)

SetCurrentPedWeapon(PlayerPedId(), GetHashKey("WEAPON_UNARMED"), true)
PlaySoundFrontend(-1, "PICK_UP", "HUD_FRONTEND_DEFAULT_SOUNDSET", true)

end

function giveBasicPrisonKit()
Expand Down Expand Up @@ -100,6 +103,7 @@ end

function GiveCustomWeapon(weaponData)
GiveWeaponToPed(PlayerPedId(), GetHashKey(weaponData), -1, false, true)
SetCurrentPedWeapon(PlayerPedId(), GetHashKey("WEAPON_UNARMED"), true)
PlaySoundFrontend(-1, "PICK_UP", "HUD_FRONTEND_DEFAULT_SOUNDSET", true)
end

Expand Down
128 changes: 91 additions & 37 deletions police/client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ along with Cops_FiveM in the file "LICENSE". If not, see <http://www.gnu.org/lic
--
--Local variables : Please do not touch theses variables
--
handCuffed = false

if(config.useCopWhitelist == true) then
isCop = false
Expand Down Expand Up @@ -47,18 +48,25 @@ SpawnedSpikes = {}
--

AddEventHandler("playerSpawned", function()
TriggerServerEvent("police:checkIsCop")
if config.useCopWhitelist then
TriggerServerEvent("police:checkIsCop")
else
isCop = true
TriggerServerEvent("police:checkIsCop")
load_armory()
load_garage()
end
end)

RegisterNetEvent('police:receiveIsCop')
AddEventHandler('police:receiveIsCop', function(svrank,svdept)
AddEventHandler('police:receiveIsCop', function(svrank, svdept)
if(svrank == -1) then
if(config.useCopWhitelist == true) then
isCop = false
else
isCop = true
rank = 0
dept = 0
dept = 1

load_armory()
load_garage()
Expand Down Expand Up @@ -87,6 +95,15 @@ if(config.useCopWhitelist == true) then
end)
end

RegisterNetEvent('police:Update')
AddEventHandler('police:Update', function(boolState)
local data = GetResourceMetadata(GetCurrentResourceName(), 'resource_fname', 0)

if boolState then
DisplayNotificationLabel("FMMC_ENDVERC1", "~y~" .. data .. "~s~")
end
end)

if(config.useCopWhitelist == true) then
RegisterNetEvent('police:noLongerCop')
AddEventHandler('police:noLongerCop', function()
Expand Down Expand Up @@ -129,7 +146,9 @@ AddEventHandler('police:getArrested', function()
TriggerEvent("police:notify", "CHAR_AGENT14", 1, i18n.translate("title_notification"), false, i18n.translate("now_cuffed"))
else
TriggerEvent("police:notify", "CHAR_AGENT14", 1, i18n.translate("title_notification"), false, i18n.translate("now_uncuffed"))
cuffing = false
drag = false
ClearPedTasksImmediately(PlayerPedId())
end
end)

Expand Down Expand Up @@ -256,6 +275,15 @@ function drawNotification(text)
DrawNotification(false, false)
end

function DisplayNotificationLabel(label, sublabel)
SetNotificationTextEntry(label)
if sublabel then
AddTextComponentSubstringPlayerName(sublabel)
end

DrawNotification(true, true)
end

--From Player Blips and Above Head Display (by Scammer : https://forum.fivem.net/t/release-scammers-script-collection-09-03-17/3313)
function enableCopBlips()
for k, existingBlip in pairs(blipsCops) do
Expand All @@ -280,7 +308,6 @@ function enableCopBlips()
local blip = GetBlipFromEntity(ped)

if not DoesBlipExist(blip) then

blip = AddBlipForEntity(ped)
SetBlipSprite(blip, 1)
Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, true)
Expand Down Expand Up @@ -373,11 +400,13 @@ function isNearTakeService()
if anyMenuOpen.menuName == "cloackroom" and anyMenuOpen.isActive and distance > 3 then
CloseMenu()
end

if(distance < 30) then
if anyMenuOpen.menuName ~= "cloackroom" and not anyMenuOpen.isActive then
DrawMarker(1, pos.x, pos.y, pos.z-1, 0, 0, 0, 0, 0, 0, 1.0, 1.0, 1.0, 0, 155, 255, 200, 0, 0, 2, 0, 0, 0, 0)
end
end

if(distance < 2) then
return true
end
Expand Down Expand Up @@ -409,6 +438,7 @@ function isNearStationGarage()
return true
end
end

function isNearHelicopterStation()
local distance = 10000
local pos = {}
Expand Down Expand Up @@ -514,42 +544,40 @@ Citizen.CreateThread(function()
while not HasThisAdditionalTextLoaded(gxt, CurrentSlot) do
Wait(0)
end
end

RequestAnimDict('mp_arresting')
while not HasAnimDictLoaded('mp_arresting') do
Citizen.Wait(50)
end

if not IsIplActive("FIBlobby") then
RequestIpl("FIBlobbyfake")
end

TriggerServerEvent("police:checkIsCop")
--Embedded NeverWanted script // Non loop part
if(config.enableNeverWanted == true) then
SetPoliceIgnorePlayer(PlayerId(), true)
SetDispatchCopsForPlayer(PlayerId(), false)

Citizen.InvokeNative(0xDC0F817884CDD856, 1, false)
Citizen.InvokeNative(0xDC0F817884CDD856, 2, false)
Citizen.InvokeNative(0xDC0F817884CDD856, 3, false)
Citizen.InvokeNative(0xDC0F817884CDD856, 5, false)
Citizen.InvokeNative(0xDC0F817884CDD856, 8, false)
Citizen.InvokeNative(0xDC0F817884CDD856, 9, false)
Citizen.InvokeNative(0xDC0F817884CDD856, 10, false)
Citizen.InvokeNative(0xDC0F817884CDD856, 11, false)
if config.enableNeverWanted then
SetMaxWantedLevel(0)
SetWantedLevelMultiplier(0.0)
else
SetMaxWantedLevel(5)
SetWantedLevelMultiplier(1.0)
end

if config.stationBlipsEnabled then
for _, item in pairs(clockInStation) do
item.blip = AddBlipForCoord(item.x, item.y, item.z)
SetBlipSprite(item.blip, 60)
SetBlipScale(item.blip, 0.8)
SetBlipAsShortRange(item.blip, true)
end
end
while true do
Citizen.Wait(5)
DisablePlayerVehicleRewards(PlayerId())

if(config.enableNeverWanted == true) then
SetPlayerWantedLevel(PlayerId(), 0, false)
SetPlayerWantedLevelNow(PlayerId(), false)
HideHudComponentThisFrame(1)
end

if(anyMenuOpen.isActive) then
DisableControlAction(1, 21)
DisableControlAction(1, 140)
Expand Down Expand Up @@ -619,19 +647,39 @@ Citizen.CreateThread(function()
end

if (handCuffed == true) then
RequestAnimDict('mp_arresting')
while not HasAnimDictLoaded('mp_arresting') do
Citizen.Wait(0)
end

local myPed = PlayerPedId()
local animation = 'idle'
local flags = 16
local flags = 50

while(IsPedBeingStunned(myPed, 0)) do
ClearPedTasksImmediately(myPed)
end
TaskPlayAnim(myPed, 'mp_arresting', animation, 8.0, -8, -1, flags, 0, 0, 0, 0)

if not cuffing then
DisableControlAction(1, 12, true)
DisableControlAction(1, 13, true)
DisableControlAction(1, 14, true)

DisableControlAction(1, 15, true)
DisableControlAction(1, 16, true)
DisableControlAction(1, 17, true)

SetCurrentPedWeapon(myPed, GetHashKey("WEAPON_UNARMED"), true)
TaskPlayAnim(myPed, "mp_arresting", animation, 8.0, -8.0, -1, flags, 0, 0, 0, 0 )

Wait(4000)
cuffing = true
end
else
EnableControlAction(1, 12, false)
EnableControlAction(1, 13, false)
EnableControlAction(1, 14, false)

EnableControlAction(1, 15, false)
EnableControlAction(1, 16, false)
EnableControlAction(1, 17, false)
cuffing = false
end

--Piece of code from Drag command (by Frazzle, Valk, Michael_Sanelli, NYKILLA1127 : https://forum.fivem.net/t/release-drag-command/22174)
Expand All @@ -646,6 +694,12 @@ Citizen.CreateThread(function()
playerStillDragged = false
end
end

if config.enableNeverWanted then
if IsPlayerWantedLevelGreater(PlayerId(), 0) then
ClearPlayerWantedLevel(PlayerId())
end
end

if(isCop) then
if(isNearTakeService()) then
Expand Down Expand Up @@ -689,14 +743,9 @@ Citizen.CreateThread(function()
Wait(600)

SetEntityCoords(PlayerPedId(), 452.119966796875, -980.061966796875, 30.690966796875)
Wait(800)
armoryPed = createArmoryPed()

if DoesEntityExist(armoryPed) then
TaskTurnPedToFaceEntity(PlayerPedId(), armoryPed, -1)
end

Wait(500)

if not DoesCamExist(ArmoryRoomCam) then
ArmoryRoomCam = CreateCam("DEFAULT_SCRIPTED_FLY_CAMERA", true)
AttachCamToEntity(ArmoryRoomCam, PlayerPedId(), 0.0, 0.0, 1.0, true)
Expand All @@ -708,6 +757,11 @@ Citizen.CreateThread(function()

Wait(100)
DoScreenFadeIn(500)

if DoesEntityExist(armoryPed) then
TaskTurnPedToFaceEntity(PlayerPedId(), armoryPed, -1)
end

Wait(300)
OpenArmory()
if not IsAmbientSpeechPlaying(armoryPed) then
Expand Down Expand Up @@ -772,7 +826,7 @@ Citizen.CreateThread(function()
if drag then
local ped = GetPlayerPed(GetPlayerFromServerId(playerPedDragged))
plyPos = GetEntityCoords(ped, true)
SetEntityCoords(ped, plyPos.x, plyPos.y, plyPos.z)
SetEntityCoords(ped, plyPos.x, plyPos.y, plyPos.z)
end
Citizen.Wait(1000)
end
Expand All @@ -786,7 +840,7 @@ Citizen.CreateThread(function()
x,y,z = table.unpack(GetEntityCoords(PlayerPedId(), true))

if DoesObjectOfTypeExistAtCoords(x, y, z, 0.9, GetHashKey("P_ld_stinger_s"), true) then
for i= 0, 7 do
for i= 0, 7 do
SetVehicleTyreBurst(currentVeh, i, true, 1148846080)
end

Expand Down
17 changes: 16 additions & 1 deletion police/client/cloackroom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ function cloackroom_rem_yellow_vest()
end

function SetCopModel(model)
SetMaxWantedLevel(0)
SetWantedLevelMultiplier(0.0)
SetRelationshipBetweenGroups(0, GetHashKey("police"), GetHashKey("PLAYER"))
SetRelationshipBetweenGroups(0, GetHashKey("PLAYER"), GetHashKey("police"))

modelHash = GetHashKey(model)

RequestModel(modelHash)
Expand Down Expand Up @@ -126,9 +131,10 @@ function SetCopModel(model)
SetPlayerModel(PlayerId(), modelHash)
SetPedComponentVariation(PlayerPedId(), 10, 7, config.rank.outfit_badge[rank], 2)
else
SetPlayerModel(PlayerId(), modelHash)
-- SetPlayerModel(PlayerId(), modelHash)
end

giveBasicKit()
SetModelAsNoLongerNeeded(modelHash)
end

Expand All @@ -145,6 +151,12 @@ function removeUniforme()

SetPlayerModel(PlayerId(), model)
SetModelAsNoLongerNeeded(model)

SetMaxWantedLevel(5)
SetWantedLevelMultiplier(1.0)

SetRelationshipBetweenGroups(3, GetHashKey("police"), GetHashKey("PLAYER"))
SetRelationshipBetweenGroups(3, GetHashKey("PLAYER"), GetHashKey("police"))
end
end

Expand All @@ -159,5 +171,8 @@ function OpenCloackroom()

anyMenuOpen.menuName = "cloackroom"
anyMenuOpen.isActive = true
if config.enableVersionNotifier then
TriggerServerEvent('police:UpdateNotifier')
end
end
end
Loading

0 comments on commit c099006

Please sign in to comment.