/qb-k9-1

qb-k9 - AI K9 Script for QBCore - All Credits Below

Primary LanguageLuaGNU General Public License v3.0GPL-3.0

Police K9 Scripts

WARNING: Only works on old core!!! Have not tested on new core!!!

Support me on Ko-Fi!

- xViperAG

ko-fi

Credits:

How To Use:

  • Request a dog from the doghouses specified in the config

  • Press Z to follow or attack (Must be pointing a weapon to attack).

  • Press K to show K9 Commands (Both of these are now keymaps so its a on user basis)

How To Install The K-9 Ped

  • Take the german-shepherd file and place it in your [standalone] folder.
  • Restart and Clear Server Cache
  • Voila!

Config Use

You can place dog houses in areas of your choosing. The current locations are at Gabz Davis and MRPD (MRPD is commented out)

image

Added Patches for German Shepherd Ped (Please read Config THOROUGHLY!!!)

Searching

You must be facing your target (vehicle or player) when selecting the Search Action, except for Search Area. Sometimes the Search Person will pick up the dog. Best to have the dog behind you.

You must add this to QB Inventory Server main.lua.

    local function HasItem(list, item)

        for i = 1, #list do

            if item == list[i] then
                return true
            end
        end

        return false
    end

    AddEventHandler("inventory:server:SearchLocalVehicleInventory", function(plate, list, cb)
    local trunk = Trunks[plate]
    local glovebox = Gloveboxes[plate]
    local result = false

    if trunk ~= nil then
        for k, v in pairs(trunk.items) do
            local ITEM = trunk.items[k].name
            if HasItem(list, ITEM) then
                RESULT = true
            end
        end
    else
        trunk = GetOwnedVehicleItems(plate)

        for k, v in pairs(TRUNK) do

            local ITEM = TRUNK[k].name
            if HasItem(list, ITEM) then
                RESULT = true
            end
        end

    end

    if glovebox ~= nil then
        for k, v in pairs(glovebox.items) do

            local ITEM = glovebox.items[k].name
            if HasItem(list, ITEM) then
                RESULT = true
            end
        end
    else
        glovebox = GetOwnedVehicleGloveboxItems(plate)

        for k, v in pairs(glovebox) do
            local ITEM = glovebox[k].name
            if HasItem(list, ITEM) then
                RESULT = true
            end
        end
    end
    cb(RESULT)
end)