void main()
{
    object oSelf = OBJECT_SELF;
    object oArea = GetArea(oSelf);

    effect eLightSmall = EffectVisualEffect(VFX_COM_HIT_FIRE);
    effect eFinalEffect = EffectVisualEffect(769); // Big combust effect

    vector vPos;
    vector vPC = GetPosition(oSelf);

    location lStar;

    int iCount;
    int iRand = d4(1) + 2; // This can be adjusted if needed
    int iStopPoint = Random(12) + 1; // Random stop point between 1 and 12

    float fD;
    float fS = 2.5;
    float fTimer = 0.08;
    float fDelay = 0.03;

    for (iCount = 0; iCount <= iRand; iCount++)
    {
        for(fD = 0.0; fD < 360.0; fD += 18.0)
        {
            vPos = Vector(vPC.x + sin(fD) * fS,
                         vPC.y + cos(fD) * fS, vPC.z + 0.1);

            lStar = Location(oArea, vPos, 0.0);

            DelayCommand(fTimer, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eLightSmall, lStar));

            fDelay = fDelay * 1.02;

            if (fDelay < 0.01) fDelay = 0.01;

            fTimer += fDelay;

            // Check if it's time to stop
        if (iCount == iStopPoint)
        {
            DelayCommand(fTimer, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eFinalEffect, lStar));
            DelayCommand(fTimer, ActionSpeakString("The fires have ended on the number " + IntToString(iStopPoint) + "!"));

            // Set stop point on self for reference in reward script
            SetLocalInt(OBJECT_SELF, "WHEEL_STOP_POINT", iStopPoint);

            // Execute the reward script for each nearby player
            object oPlayer = GetFirstPC();
            while (GetIsObjectValid(oPlayer))
            {
                if (GetDistanceBetween(OBJECT_SELF, oPlayer) < 10.0) // Define your range here
                {
                    DelayCommand(fTimer, ExecuteScript("reward_script", oPlayer));
                }
                oPlayer = GetNextPC();
            }

            return; // Stop the loop
        }
    }
}

// Additional Script: reward_script.nss
/* void main()
{
    object oArea = GetArea(OBJECT_SELF);
    object oPlayer = GetFirstPC();
    int iStopPoint = GetLocalInt(OBJECT_SELF, "WHEEL_STOP_POINT");
    
    while (GetIsObjectValid(oPlayer))
    {
        if (GetDistanceBetween(OBJECT_SELF, oPlayer) < 10.0) // Assuming 10.0 as the proximity range
        {
            // Delete WHEEL_BET variable
            DeleteLocalInt(oPlayer, "WHEEL_BET");
            SendMessageToPC(oPlayer, "WHEEL_BET variable deleted.");

            // Check for correct WHEEL_BET
            int iBet = GetLocalInt(oPlayer, "WHEEL_BET");
            if (iBet == iStopPoint)
            {
                int iBetAmount = GetLocalInt(oPlayer, "WHEEL_BET_AMOUNT");
                int iReward = iBetAmount * 4;
                // Implement your reward logic here, for example:
                // GiveGoldToCreature(oPlayer, iReward);
                SendMessageToPC(oPlayer, "You won " + IntToString(iReward) + " tickets!");
            }
        }
        oPlayer = GetNextPC();
    }
}
 */