For the complete documentation index, see llms.txt. This page is also available as Markdown.

Misc Integrations

Vehicle interaction

By default the script uses the target system to interact with the vehicle in order to seat the pet. If you disabled that in the config file you can use the following events from your own script:

  • Check if your pet can be placed in a vehicle

    • exports["cdev_pets"]:CanEnterVehicle(vehicle)

  • Check if your pet can be taken out of a vehicle

    • exports["cdev_pets"]:CanExitVehicle(vehicle)

  • Request to place your pet in a vehicle

    • TriggerEvent("cdev_pets:onTargetPlaceVehicle", { entity = vehicle })

  • Request to take your pet out of a vehicle

    • TriggerEvent("cdev_pets:onTargetTakeVehicle", { entity = vehicle })

Example for QBCore Framework

Snippet provided by @MikeyB
RegisterNetEvent("putpetincar", function()
    local playerPed = PlayerPedId()
    local playerCoords = GetEntityCoords(playerPed)
    local closestVehicle = QBCore.Functions.GetClosestVehicle(playerCoords)
    local vehicle = closestVehicle
    if exports["cdev_pets"]:CanEnterVehicle(vehicle) then
        TriggerEvent("cdev_pets:onTargetPlaceVehicle", { entity = vehicle })
    else
        QBCore.Functions.Notify("Can not enter, try getting in and out of the vehicle..", "error")
    end
  end)
  
  RegisterNetEvent("removepetincar", function()
    local playerPed = PlayerPedId()
    local playerCoords = GetEntityCoords(playerPed)
    local closestVehicle = QBCore.Functions.GetClosestVehicle(playerCoords)
    local vehicle = closestVehicle
    if exports["cdev_pets"]:CanExitVehicle(vehicle) then
      TriggerEvent("cdev_pets:onTargetTakeVehicle", { entity = vehicle })
    else
        QBCore.Functions.Notify("Can not enter, try getting in and out of the vehicle..", "error")
    end
  end)

Quick Actions Keybinds

If you opt to disable keybinds for quick actions, you can use the following events from your own script:

Attacking

If you opt to disable attacking automatically when aiming at a ped, you can use the following export to start attacking a target:

K9

To determine what players can purchase K9s, you can modify the integration in cdev_pets/public/server/api.lua in the function:

By default it checks for players who have the police job.

Bark

Play Emote

If you opt to disable the target resource or for other reason you can trigger pet emotes from your own script with the following event:

The built in emotes that the pets play are Sit and Lay Down:

AddPet EXPORT

The addpet function adds a pet for a player or character, supporting both regular pets and K9 units.

Parameters

  • PlayerId (optional): Player's source ID.

  • CharacterId (optional): Character ID if PlayerId is not provided.

  • petShopId (required): ID of the pet from the pet shop.

  • isK9 (optional, boolean): true if the pet is a K9 unit, false otherwise (default: false).

  • petName (required): Name of the pet.

Function Workflow

  1. Checks if data exists.

  2. Verifies that either PlayerId or CharacterId is provided.

  3. Looks up the pet's details from petShopId.

  4. If the pet is a K9, it assigns K9 skills like sniff and attack.

  5. Adds the pet to the database.

  6. If the pet is a K9, it gives the player a K9-related item.

Example

This will add a K9 pet named "Buddy" for the player with PlayerId 2.

Last updated