Exports
Client-Side Exports
TakeInPet
Description: Hides the player's current pet if it's within a certain range.
Export Statement:
exports("TakeInPet", TakeInPet)Usage:
exports.cdev_pets:TakeInPet()Parameters:
None
Returns:
None
Functionality:
Checks if the player owns a pet.
Verifies if the pet is within a 10-unit distance from the player.
If conditions are met, it triggers a server callback to hide the pet.
Notifies the player about the action's success or failure.
ForceTakeInPet
Description: Forcefully hides the player's current pet, regardless of its position.
Export Statement:
Usage:
Parameters:
None
Returns:
None
Functionality:
Checks if the player owns a pet.
Triggers a server callback to hide the pet without checking the distance.
Closes any open pet-related menus.
Attack
Description: Commands the player's pet to attack a specified target.
Export Statement:
Usage:
Parameters:
targetPed(Entity): The entity the pet should attack.
Returns:
None
Functionality:
Ensures the player owns a pet.
Checks if the pet is not already in an attack state.
Initiates the attack sequence on the target entity.
CanEnterVehicle
Description: Checks if the player's pet can enter a specific vehicle.
Export Statement:
Usage:
Parameters:
vehicle(Entity): The vehicle entity to check.
Returns:
boolean:trueif the pet can enter the vehicle,falseotherwise.
Functionality:
Determines if the player owns a pet.
Invokes the pet's method to verify if it can enter the specified vehicle.
CanExitVehicle
Description: Checks if the player's pet can exit a specific vehicle.
Export Statement:
Usage:
Parameters:
vehicle(Entity): The vehicle entity to check.
Returns:
boolean:trueif the pet can exit the vehicle,falseotherwise.
Functionality:
Determines if the player owns a pet.
Checks if the pet is currently in the specified vehicle.
Returns the pet's ability to exit based on its current state.
cdev_pets:onTargetPlaceVehicle
Places the player's spawned owned pet into a vehicle seat.
Trigger (client):
Payload fields:
entity
number
Vehicle entity handle.
payload.door
number
Door/seat index: 1, 2, or 3.
payload.doorname
string
Vehicle bone name (see table below).
Supported seat bones:
doorname
door
Seat
seat_pside_f
1
Front passenger
seat_dside_r
2
Rear driver side
seat_pside_r
3
Rear passenger side
What happens internally:
Resolves
PetManagerClient.ownedPet(pet must be spawned and out).Checks the pet is within 10 meters of the player.
Calls server callback
cdev_pets:attemptVehicle(e.g. stamina / tired checks).On success, runs
pet:EnterVehicle(entity, door, doorname).
Returns: None (failures are handled silently or via in-game notifications from cdev_pets).
cdev_pets:onTargetTakeVehicle
Removes the player's pet from a vehicle.
Trigger (client):
Requirements:
Pet must be spawned (
ownedPetexists).Pet state must be
VEHICLE.Pet must be attached to the given
entity.
What happens internally:
Calls
pet:Idle(), which plays the exit animation and detaches the pet.
Returns: None.
QBX_radialmenu Example
How Setup qbx_radialmenuExample client-side code using the pet interaction events and vehicle exports.
Add this to your resource's client script example inside your qbx_radialmenu (not inside cdev_pets):
Usage from anywhere on the client:
Replace print() with your notification system if desired.
spawnPet
Description: Spawns a pet with a specified ID at the player's location or custom coordinates.
Export Statement:
Usage:
Parameters:
id(number): The unique identifier of the pet to spawn.customCoords(table, optional): Coordinates to spawn the pet at. If not provided, spawns at the player's current location.
Returns:
None
Functionality:
Determines the spawn location based on provided coordinates or the player's current position.
Requests the server to spawn the pet.
Loads the pet's model and customization settings.
Adds the pet to the client's pet manager and sets up necessary interactions.
QuickActionFollow
Description:
Toggles follow/stay on the player's spawned owned pet from external menus (radial, custom UI). Uses the same logic as the in-game follow quick action but always targets ownedPet and skips the player whistle animation. Recommended for qb-radialmenu, ox_lib radial, and similar integrations.
Export Statement:
Usage:
Parameters: None
Returns: None
Functionality:
Resolves the pet as
PetManagerClient.ownedPet(orcurrentPetTargetif no owned pet is out).Validates
CanDrawQuickActions()(requiresKeybinds.Enabled = truein config, pet withinRange, player on foot, etc.).If the pet is not following: triggers server callback
cdev_pets:attemptFollow; on success, starts follow without player whistle animation.If the pet is already following: sets the pet to stay (
Idle).Handles attack stand-down and bed/dead states the same way as the default follow keybind.
Does nothing if no valid pet, cooldown is active, or conditions are not met (no error thrown).
Config requirements:
PublicSharedPetsConfig.Keybinds.Enabledmust betrue(even when using only a radial menu).Pet must be spawned and within
PublicSharedPetsConfig.Range(default5.0).
Related events (alternative to this export):
TriggerEvent('cdev_pets:quickAction:follow')— same handler; may play player whistle animation when not called via this export.
Server-Side Exports
addpet
Description: Adds a new pet for a specified player with given attributes.
Export Statement:
Usage:
Parameters:
data(table): Contains the following keys:PlayerId(number): The player's server ID.petShopId(string): Pet Identification for the Pet Shop You can find each pet'sPetShopIdin theshop.luafile, located at:cdev_pets/public/config/shop.lua.isK9(boolean): Indicates if the pet is a K9 (police dog).petName(string): Name of the pet.
Returns:
None
Functionality:
Validates the provided data.
Inserts the new pet into the database with specified attributes.
Assigns skills if the pet is designated as a K9.
Provides the pet with a K9 activation item if applicable.
givepetitem
Description: Gives an item to a player's pet's inventory.
Export Statement:
Usage:
Parameters:
data(table): Contains the following keys:PlayerId(number): The player's server ID.item(string): The identifier of the item to give.quantity(number): The quantity of the item to give.
Returns:
None
Functionality:
Validates the provided data.
Adds the specified item to the pet's inventory.
Notifies the player of the successful addition.
delpet
Description: Deletes a pet associated with a player.
Export Statement:
Usage:
Parameters:
data(table): Contains the following keys:PlayerId(number): The player's server ID.petId(number): The unique identifier of the pet to delete.
Returns:
None
Functionality:
Validates the provided data.
Removes the pet from the player's ownership.
Deletes the pet from the database.
Notifies the player of the successful deletion.
isPetOutBySource
Description: Checks if a player currently has a pet out (active).
Export Statement:
Usage:
Parameters:
source(number): The player's server ID.
Returns:
boolean:trueif the player has a pet out,falseotherwise.
Functionality:
Retrieves the pet associated with the player.
Returns whether the pet is currently active and out.
Last updated