Browse docs
Exports
Call client exports from a client script and server exports from a server script. Keep the resource folder named sky_pets. These are the exports registered by the core resource; its Sky.Cb requests and NUI callbacks are internal protocols.
Client exports
OpenShop(shopId)
Opens the configured pet shop directly, without the NPC's pets/supplies choice screen. shopId is a string key in Config.Shops, such as "pet_shop". The function starts the client flow and has no success return value. The server still checks proximity and the catalogue request.
The default shop point is at the cashier inside the bundled MLO: vector3(-169.0462, 226.0295, 92.27). This export does not move the player there.
exports["sky_pets"]:OpenShop("pet_shop")
OpenSuppliesShop(shopId)
Opens a configured supplies shop directly. shopId must be a string key in Config.SuppliesShops, such as "pet_supplies"; passing the pet-shop ID does not choose its linked supplies shop for you. It shares the shop-opening function and has no success return value.
By default, the supplies shop uses the same cashier point inside the MLO. Saved /petsconfig locations can change it independently.
exports["sky_pets"]:OpenSuppliesShop("pet_supplies")
OpenAnimalMenu()
Opens the local animal-form editor. Returns { ok = true } on success or { ok = false, error = "..." } for a local/server rejection. The player needs access, a valid state and no nearby player within the configured safety radius.
local result = exports["sky_pets"]:OpenAnimalMenu()
if not result.ok then
print(("Animal menu unavailable: %s"):format(result.error))
end
TogglePetHud() and TogglePetMenu()
These client exports toggle the local player's HUD and pet radial. Config.Hud.openMethod and Config.Radial.openMethod each support "export", "key" and "both". The default is "both": exports and the F7/F6 key bindings are enabled together. The exports remain registered in every mode, but return false when the matching mode is keybind-only or when the current player state blocks the menu. A successful toggle returns true.
Choose the access mode in the in-game configurator under General → Menu access. Saved access-mode and key changes apply immediately. For file-based changes, edit config/config.lua, restart the resource and import the configuration as described in Configuration. Legacy "command" mode remains supported for existing configurations.
-- Enabled by default with Config.Radial.openMethod = "both".
local opened = exports["sky_pets"]:TogglePetMenu()
if not opened then
print("Pet menu cannot be toggled right now")
end
Server exports
GivePet(target, data)
Grants a permanently saved companion pet for quest rewards, promotions, staff tools or another server-controlled integration. It does not grant player animal-form access.
target accepts an online player source (number) or the exact persistent character identifier returned by Sky.FW.GetIdentifier (string). A string always means a character identifier, including while that character is offline. Use dependency "sky_pets" in the calling resource's manifest and call after the resource has started. The calling server script must authorize the reward before invoking the export.
local result = exports["sky_pets"]:GivePet(player_source, {
breed = "rottweiler",
name = "Buddy",
coat = 0,
gender = "male",
collar = 0,
requestId = "quest-123-completion",
})
if result.ok then
print("Granted pet:", result.id, result.alreadyGranted)
else
print("Pet reward failed:", result.error, result.requestId)
end
| Field | Required / default | Meaning |
|---|---|---|
breed | Required | Configured breed ID, such as rottweiler, pug or pug_puppy; use the breed ID rather than the GTA model name. The breed must be enabled and its resource available. |
name | Required | Pet name, validated and normalized using the shop's configured name limits. |
coat | First configured coat | Must be a configured coat ID for the breed. |
gender | "male" | "male" or "female". |
collar | 0 | Must be supported by the selected breed/coat. |
requestId | Generated 32-character key | Reward key for this character: 1–74 letters, digits, underscores or hyphens. |
Success returns { ok = true, id = string, requestId = string, alreadyGranted = boolean }. The pet starts with the normal care, combat and growth defaults and an empty wardrobe. No money or inventory items are removed, and the pet is not automatically summoned. Open pet menus/HUDs are refreshed for the character after a successful grant.
This trusted server grant does not require shop proximity, shop stock, puppy-only shop stock or VIP entitlement. Existing VIP restrictions still apply when the player opens the pet menu. Never forward unvalidated client reward parameters directly to this export.
Use a stable requestId when a reward must be delivered only once. Repeating the same key for the same character returns the original pet ID with alreadyGranted = true, including after a resource restart. It does not reset the pet's care, appearance or growth. Keys are shared by all server integrations for that character, so use a distinct prefix for each integration. Shop request keys are separate.
Omitting requestId intentionally creates a new pet on every call. Keep the returned key to retry an uncertain result. Operational errors also retain the generated/supplied key. A database readback can fail after the pet has already been saved; retry with the same key to avoid granting a second pet. Overlapping purchases or grants for the same owner return busy.
Numeric sources are checked again before the write. If a character disconnects during the commit, ownership stays with the captured character identifier. A source reused by another character is not notified for the previous owner.
GetPets(target)
Returns all saved pets belonging to the target character, ordered by purchase time and pet ID. It accepts the same online source or persistent identifier as GivePet, including offline characters.
local result = exports["sky_pets"]:GetPets(player_source)
if result.ok then
for _, pet in ipairs(result.pets) do
print(pet.id, pet.name, pet.breed, pet.available)
end
end
Success returns { ok = true, pets = {...} }. A character without pets receives an empty list. Each ownership snapshot contains:
| Field | Meaning |
|---|---|
id | Pet ID as a string. |
owner | Persistent character identifier. |
name, breed, coat, collar, gender | Saved pet identity and appearance choices. Legacy pets may have no gender. |
paidPrice, purchasedAt | Saved purchase amount and time; granted pets have paidPrice = 0. |
available | Whether the breed is currently enabled and its resource available. |
growth | Current stage/progress from the existing growth clock. |
Unavailable breed packs remain in the results with available = false; saved ownership is preserved. The snapshot does not contain live health, needs or entity state.
GetPet(target, id)
Returns one saved pet belonging to the target character. id accepts a positive numeric pet ID or its decimal string. The target types and pet fields match GetPets.
local result = exports["sky_pets"]:GetPet("char1:license:example", "42")
if result.ok then
print(result.pet.name, result.pet.growth.stage)
end
Success returns { ok = true, pet = {...} }. An unknown ID or a pet belonging to another character returns { ok = false, error = "notOwned" }.
HasPet(target, breedId?)
Checks whether the target owns any saved pet, or a pet of the supplied breed ID. It accepts online sources and offline character identifiers. Ownership of an unavailable breed pack still counts.
local any_pet = exports["sky_pets"]:HasPet(player_source)
local rottweiler = exports["sky_pets"]:HasPet(player_source, "rottweiler")
if rottweiler.ok and rottweiler.hasPet then
print("Character owns a Rottweiler")
end
Returns { ok = true, hasPet = boolean }. The return value is a result table, so check result.ok and result.hasPet. A database failure returns ok = false; it is not treated as the character having no pets.
Ownership export errors
The four ownership exports return { ok = false, error = code } on failure. GivePet also includes requestId after validating the target/payload and preparing the reward key.
| Error | Meaning |
|---|---|
unavailable | Invalid target, offline numeric source, missing identifier or character changed during the initial read. |
invalid | Invalid payload, breed ID, coat, gender, collar, pet ID or reward key. |
name | Invalid pet name. |
breedUnavailable | A new grant uses a disabled or unavailable breed. |
notOwned | The pet ID does not belong to the target, or a grant tries to equip unowned clothing. |
busy | Another purchase or grant is operating on this character. |
database | A database read/write failed. For an uncertain grant, retry with the same reward key. |
unknown | An unexpected provider exception interrupted the grant; the owner lock is released and the reward key is retained. |
These exports require the resource version containing the persistent ownership API. Restart sky_pets after installing the update. No additional SQL or configuration migration is required.
GiveAnimalAccess(target)
Grants access to the separate player animal-form feature. target is an online player source (number) or a validated persistent owner identifier (string). Returns { ok = true, hasAccess = boolean } or { ok = false, error = string }. An eligible staff command permission may also give the player effective access without an explicit grant.
local result = exports["sky_pets"]:GiveAnimalAccess(player_source)
if not result.ok then
print(("Grant failed: %s"):format(result.error))
end
RemoveAnimalAccess(target)
Revokes a grant using the same target types and result shape. If a player's staff permission still allows the animal menu, hasAccess can remain true; the return reports effective access. Active sessions are closed when effective access is lost.
local result = exports["sky_pets"]:RemoveAnimalAccess(player_source)
if result.ok then
print(("Effective animal access: %s"):format(tostring(result.hasAccess)))
end
HasAnimalAccess(target)
Returns a boolean for effective access. An invalid target returns false. This reads the saved grant and, for an online player, the configured command permission.
if exports["sky_pets"]:HasAnimalAccess(player_source) then
print("Animal form is available to this player")
end
OpenAnimalMenu(source)
Requests that the server open the animal-form editor for an online player source. Returns { ok = true } or { ok = false, error = string }. It validates access and rejects a nearby-player conflict before sending the menu-open message. This is distinct from the client export of the same name.
local result = exports["sky_pets"]:OpenAnimalMenu(player_source)
if not result.ok then
print(("Animal menu denied: %s"):format(result.error))
end
Combat XP and pet health changes remain part of the validated gameplay flows.