void LogWTF(string sMessage, string sTag)
{
    // Implementation of logging; for example, sending a message to the server console
    SendMessageToPC(GetFirstPC(), sTag + ": " + sMessage);
}

void main()
{
    object oPC = GetPCSpeaker();
    object oItem = GetItemPossessedBy(oPC, "I_CAS_CASINOHANDLE");

    // Check if the item exists in the PC's inventory
    if (!GetIsObjectValid(oItem))
    {
        // Exit the script if the item is not found
        SendMessageToPC(oPC, "You don't have a Token Pouch.");
        return;
    }

    int nTickets = GetLocalInt(oItem, "nCAS_TICKET");

    // Check if the PC has at least 50 tickets
    if (nTickets < 50)
    {
        // Exit the script if there aren't enough tickets
        SendMessageToPC(oPC, "You don't have enough tickets.");
        return;
    }

    // Deduct 50 tickets
    SetLocalInt(oItem, "nCAS_TICKET", nTickets - 50);

    // Transport the PC and their party to the waypoint
    object oWaypoint = GetWaypointByTag("CAS_WP_SHALAMOYAHARBOR");
    if (GetIsObjectValid(oWaypoint))
    {
        // Initialize the message with the PC's name
        string sMessage = "The player " + GetName(oPC);

        // Check for party members
        int nHasPartyMembers = FALSE;
        object oMember = GetFirstFactionMember(oPC, FALSE);
        while (GetIsObjectValid(oMember))
        {
            if (oMember != oPC)
            {
                // If this is the first party member, add an introductory phrase
                if (!nHasPartyMembers)
                {
                    sMessage += " and party members ";
                    nHasPartyMembers = TRUE;
                }

                sMessage += GetName(oMember) + ", ";
                AssignCommand(oMember, JumpToObject(oWaypoint));
            }
            oMember = GetNextFactionMember(oPC, FALSE);
        }

        // Format the message correctly depending on whether there were any party members
        if (nHasPartyMembers)
        {
            // Remove the last comma and space from the message
            sMessage = GetStringLeft(sMessage, strlen(sMessage) - 2);
        }
        sMessage += " went to the Island of Shalamoya.";

        // Log the message
        LogWTF(sMessage, "cas");

        // Finally, transport the PC
        AssignCommand(oPC, JumpToObject(oWaypoint));
    }

    // ... (rest of your code)
}

