Robbery & Police

The robbery and police system is completely configurable and simple within config.lua.


Basic configuration

The basic configuration of polices and alarms will be configured as follows by default.

Read each comment within the configuration to understand what to do in each configuration.

Config.StartAlarm = true -- Alarm sound, if you do not enable this, the dispatch will not appear
Config.StartAlarmChance = 25 -- Percentage for the alarm to sound

Config.ReqPolice = true -- Do you want police in your city to enable robberies?
Config.ReqPoliceCount = 5 -- Minimum police to start a robbery
Config.ReqJobPolice = 'police' -- Police job name
Config.RefreshPolice = 1000 -- Ammount of time to check por police count again, higher for more performance, don't use below 1000ms

Dispatch configuration

If the alarm is false, it will never launch a dispatch.

Once we configure this section, we can go directly to configure the percentage of probability for the alarm to sound, if the alarm sounds, it will launch a dispatch, which is in client/custom/dispatch/*.lua.

You can completely remove the inside of the event and add your own dispatch.

RegisterNetEvent('motorhome:client:notifyCops')
AddEventHandler('motorhome:client:notifyCops', function(coords)
    if GetJobFramework() ~= nil and GetJobFramework().name == Config.ReqJobPolice then
        local transG = 300 * 2
        local blip = AddBlipForCoord(coords)
        local street = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
        local street2 = GetStreetNameFromHashKey(street)

        if Config.Smartphone then
            TriggerServerEvent("motorhome:server:phoneDispatch", coords, street2)
        else
            SendTextMessage(Lang("MOTORHOME_NOTIFICATION_POLICE_DISPATCH").." "..street2, 'inform')
        end

        SetBlipSprite(blip, 161)
        SetBlipColour(blip, 3)
        SetBlipDisplay(blip, 4)
        SetBlipAlpha(blip, transG)
        SetBlipScale(blip, 1.5)
        SetBlipFlashes(blip, true)
        BeginTextCommandSetBlipName('STRING')
        AddTextComponentString(Lang("MOTORHOME_NOTIFICATION_TITLE"))
        EndTextCommandSetBlipName(blip)
        while transG ~= 0 do
            Citizen.Wait(500)
            transG = transG - 1
            SetBlipAlpha(blip, transG)
            if transG == 0 then
                SetBlipSprite(blip, 2)
                RemoveBlip(blip)
                return
            end
        end
    end
end)

Last updated