onGiftReceived

Purpose

Triggered on the recipient's client when they receive a gift from another player. Use this hook to play sounds and show who sent the gift.

When It Triggers

  • Another player successfully purchases items for this player

  • Fires on the recipient's client, not the buyer's

Parameters

Parameter
Type
Description

data.shopId

string

Unique shop identifier

data.shopName

string

Display name of the shop

data.senderName

string

Name of person who sent the gift

data.items

table

Items received

data.items[i].item

string

Item spawn name

data.items[i].label

string

Item display name

data.items[i].quantity

number

Quantity received

Example

exports['sd-shops']:registerClientHook('onGiftReceived', function(data)
    -- Play receive sound
    PlaySoundFrontend(-1, 'MEDAL_UP', 'HUD_MINI_GAME_SOUNDSET', true)

    -- Build item list
    local itemList = {}
    for _, item in ipairs(data.items) do
        table.insert(itemList, ('%dx %s'):format(item.quantity, item.label))
    end

    -- Show gift notification
    lib.notify({
        title = 'Gift Received!',
        description = ('%s sent you: %s'):format(data.senderName, table.concat(itemList, ', ')),
        type = 'success',
        duration = 10000
    })

    -- Log received gift
    print(('[GIFT] Received gift from %s: %s'):format(
        data.senderName, table.concat(itemList, ', ')
    ))
end)

Last updated