void main()
{
    // Get the player who disturbed the inventory
    object oPlayer = GetLastDisturbed();

    // Get the disturbed item
    object oDisturbedItem = GetInventoryDisturbItem();
    
    // Check if the disturbed item has the "iCopyMe" variable set to 1
    int iCopyMe = GetLocalInt(oDisturbedItem, "iCopyMe");
    if (iCopyMe != 1)
    {
        SendMessageToPC(oPlayer, "This item cannot be copied.");
        return;
    }

    // Get the container of the disturbed item
    object oContainer = GetItemPossessor(oDisturbedItem);
    object oChest = GetNearestObjectByTag("CAS_TIER1CHEST", oContainer);
    // Check if the player has a "I_CAS_CASINOHANDLE" item
    object oHandle = GetItemPossessedBy(oPlayer, "I_CAS_CASINOHANDLE");
    if (!GetIsObjectValid(oHandle))
    {
        SendMessageToPC(oPlayer, "You need a Casino Handle to make purchases.");

        // Copy the item back to the original container
        CopyItem(oDisturbedItem, oChest, TRUE);

        // Destroy the disturbed item in the player's inventory
        DestroyObject(oDisturbedItem);

        return;
    }

    // Get the number of tickets the player has
    int nPlayerTickets = GetLocalInt(oHandle, "nCAS_TICKET");

    // Check if the player has enough tickets
    int iCostTickets = GetLocalInt(oDisturbedItem, "iCostTickets");
    if (nPlayerTickets < iCostTickets)
    {
        SendMessageToPC(oPlayer, "You need " + IntToString(iCostTickets) + " tickets to copy this item.");
         CopyItem(oDisturbedItem, oChest, TRUE);

        // Destroy the disturbed item in the player's inventory
        DestroyObject(oDisturbedItem);

        return;
    }

    // Deduct the required tickets and notify the player
    SetLocalInt(oHandle, "nCAS_TICKET", nPlayerTickets - iCostTickets);
    SendMessageToPC(oPlayer, "Item copied successfully. Tickets deducted.");

    // Find the nearest chest with the specified tag

    // Check if the chest is found
    if (!GetIsObjectValid(oChest))
    {
        SendMessageToPC(oPlayer, "Error: Chest not found.");
        return;
    }

    // Copy the item to the chest
    object oNewItem = CopyItem(oDisturbedItem, oChest, TRUE);

}
