onGiftPurchaseCompleted

Purpose

Triggered when a gift purchase is successfully completed. Use this hook to play celebration sounds and confirm the gift was sent.

When It Triggers

  • Server confirms the gift purchase was successful

  • Items have been given to the recipient

Parameters

Parameter
Type
Description

data.shopId

string

Unique shop identifier

data.shopName

string

Display name of the shop

data.targetPlayerId

number

Target player's server ID

data.targetPlayerName

string

Target player's name

data.items

table

Items gifted

data.totalAmount

number

Total spent

Example

exports['sd-shops']:registerClientHook('onGiftPurchaseCompleted', function(data)
    -- Play gift sound
    PlaySoundFrontend(-1, 'CHALLENGE_UNLOCKED', 'HUD_AWARDS', true)

    -- Show success notification
    lib.notify({
        title = 'Gift Sent!',
        description = ('Items sent to %s'):format(data.targetPlayerName),
        type = 'success'
    })

    -- Log completed gift
    print(('[GIFT] Successfully sent %d items ($%d) to %s'):format(
        #data.items, data.totalAmount, data.targetPlayerName
    ))
end)

Last updated