void main()
{
    object oPC = GetPCSpeaker(); 
    int nValue = StringToInt(GetLocalString(oPC, "I_SAID")); // Value set in conversation for tokens

    // Locate the casino handle item in the player's inventory
    object oCasinoHandle = GetItemPossessedBy(oPC, "I_CAS_CASINOHANDLE");
    if (!GetIsObjectValid(oCasinoHandle))
    {
        SendMessageToPC(oPC, "Casino handle not found in your inventory.");
        return;
    }

    // Compare nValue with nCAS_TOKEN on the casino handle
    int nCurrentTokenCount = GetLocalInt(oCasinoHandle, "nCAS_TOKEN");
    if (nValue > nCurrentTokenCount)
    {
        SendMessageToPC(oPC, "You don't have enough tokens to fill out the note.");
        return;
    }

    // Deduct nValue from nCAS_TOKEN on the casino handle
    SetLocalInt(oCasinoHandle, "nCAS_TOKEN", nCurrentTokenCount - nValue);

    // Create the token slip holder item
    object oSlipHolder = CreateItemOnObject("cas_slipholder", oPC);

    // Ensure the item was created successfully
    if (!GetIsObjectValid(oSlipHolder))
    {
        SendMessageToPC(oPC, "Failed to create the item. Please check your inventory space.");
        return;
    }

    SetTag(oSlipHolder, "I_CAS_TOKEN");

    // Set name and variable for tokens
    SetName(oSlipHolder, "Token Slip Holder: " + IntToString(nValue));
    SetLocalInt(oSlipHolder, "nCAS_TOKEN", nValue);
}
