В этом коде не работает выдача приза победителю. #include <sourcemod>
#include <shop>

enum Lotterystate
{
    LotteryState_None,
    LotteryState_InProgress
};

Lotterystate g_LotteryState = LotteryState_None;
int g_TotalBet = 0;
int g_PlayerBets[MAXPLAYERS + 1] = {0, ...};
bool g_PlayerHasBet[MAXPLAYERS + 1] = { false, ... };
ArrayList g_PlayerBetsID; // Список для хранения Steam ID игроков и ставок
Handle g_LotteryTimer = INVALID_HANDLE;

public Plugin myinfo = 
{
    name = "Lottery Plugin",
    author = "anon",
    description = "A simple lottery plugin for CS:Source",
    version = "13.37",
    url = "https://www.youtube.com"
};

public void OnPluginStart()
{
    RegConsoleCmd("sm_lot", Command_Lot);
    g_PlayerBetsID = CreateArray();
    g_LotteryState = LotteryState_None;
}

public Action Command_Lot(client, args)
{
    char steamId[32];
    GetClientAuthId(client, AuthId_Steam2, steamId, sizeof(steamId), true);

    if (g_PlayerHasBet[client])
    {
        PrintToChat(client, "\x07000000[Ставки] \x07ffffffВы уже сделали ставку. Вы не можете поменять ставку.");
        return Plugin_Handled;
    }

    char arg[64];
    GetCmdArg(1, arg, sizeof(arg));
    
    int credits = Shop_GetClientCredits(client);
    int amount = 0;
    int maxBet = (g_TotalBet == 0) ? credits : g_TotalBet * 2;

    if (maxBet > credits)
    {
        maxBet = credits;
    }

    if (StrEqual(arg, "x1"))
    {
        if (g_TotalBet == 0)
        {
            PrintToChat(client, "\x07000000[Ставки] \x07ffffffНикто не сделал ставку. Вы не можете использовать x1.");
            return Plugin_Handled;
        }
        amount = g_TotalBet;  
    }
    else if (StrEqual(arg, "x2"))
    {
        if (g_TotalBet == 0)
        {
            PrintToChat(client, "\x07000000[Ставки] \x07ffffffНикто не сделал ставку. Вы не можете использовать x2.");
            return Plugin_Handled;
        }
        amount = g_TotalBet * 2;
    }
    else if (StrEqual(arg, "all"))
    {
        amount = credits;
    }
    else
    {
        amount = StringToInt(arg);
    }
    
    if (amount <= 0 || amount > credits || amount > maxBet)
    {
        PrintToChat(client, "\x07000000[Ставки] \x07ffffffНекорректная ставка.");
        return Plugin_Handled;
    }

    g_PlayerBets[client] = amount;
    g_TotalBet += amount;
    Shop_SetClientCredits(client, credits - amount);
    g_PlayerHasBet[client] = true;

    int playerNum = FindSteamIDIndex(steamId);
    if (playerNum == -1)
    {
        g_PlayerBetsID.PushString(steamId);
        g_PlayerBetsID.Push(amount);
    }
    else
    {
        int currentBet = g_PlayerBetsID.Get(playerNum + 1);
        g_PlayerBetsID.Set(playerNum + 1, currentBet + amount);  
    }

    float winningChance = (float(amount) / float(g_TotalBet)) * 100.0;
    PrintToChatAll("\x07000000[Ставки] \x07ffffffИгрок \x07276f5c%N \x07ffffffпоставил \x04%d \x07ffffffкредитов. Джекпот: \x07af2a22%d \x07ffffffкредитов. Шанс на выигрыш: \x04%.2f%%", client, amount, g_TotalBet, winningChance);

    if (g_TotalBet > 0 && g_LotteryState == LotteryState_None)
    {
        g_LotteryState = LotteryState_InProgress;
        if (g_LotteryTimer != INVALID_HANDLE)
        {
            CloseHandle(g_LotteryTimer);
        }
        g_LotteryTimer = CreateTimer(30.0, Timer_LotteryEnd);
        PrintToChatAll("\x07000000[Ставки] \x07ffffffЛотерея началась. Таймер запущен на 30 секунд.");
    }

    return Plugin_Handled;
}

public Action Timer_LotteryEnd(Handle timer)
{
    g_LotteryTimer = INVALID_HANDLE;
    g_LotteryState = LotteryState_None;

    PrintToChatAll("\x07000000[Ставки] \x07ffffffЛотерея завершена. Определяем победителя…");

    int winner = GetRandomPlayerByChance();
    if (winner != -1)
    {
        int credits = g_TotalBet;

        char steamId[32];
        GetClientAuthId(winner, AuthId_Steam2, steamId, sizeof(steamId), true);
        int playerNum = FindSteamIDIndex(steamId);

        if (playerNum != -1)
        {
            float winningChance = (float(g_PlayerBetsID.Get(playerNum + 1)) / float(g_TotalBet)) * 100.0;
            PrintToServer("Победитель: %N, сумма ставки: %d, общий джекпот: %d, шанс: %.2f%%", winner, g_PlayerBetsID.Get(playerNum + 1), g_TotalBet, winningChance);
            Shop_SetClientCredits(winner, Shop_GetClientCredits(winner) + credits);
            PrintToChatAll("\x07000000[Ставки] \x07ffffffИгрок \x07276f5c%N \x07ffffffвыиграл \x04%d \x07ffffffкредитов с шансом \x04%.2f%%.", winner, credits, winningChance);

            g_PlayerBetsID.Erase(playerNum);
            g_PlayerBetsID.Erase(playerNum); // Удаляем также соответствующую ставку
        }
        else
        {
            PrintToServer("PlayerNum is -1");
        }
    }
    else
    {
        PrintToChatAll("\x07000000[Ставки] \x07ffffffНе удалось определить победителя.");
    }
  
    g_TotalBet = 0;
    for (int i = 1; i <= MaxClients; i++)
    {
        g_PlayerBets[i] = 0;
        g_PlayerHasBet[i] = false;
    }

    g_PlayerBetsID.Clear();

    return Plugin_Continue;
}

stock int GetRandomPlayerByChance()
{
    float totalWeight = 0.0;
    int players[MAXPLAYERS];
    int count = 0;

    for (int i = 1; i <= MaxClients; i++)
    {
        if (IsClientInGame(i) && g_PlayerBets[i] > 0)
        {
            totalWeight += g_PlayerBets[i];
            players[count++] = i;
        }
    }

    if (count == 0)
    {
        return -1;
    }

    float randomWeight = GetRandomFloat(0.0, totalWeight);
    float weightSoFar = 0.0;

    for (int i = 0; i < count; i++)
    {
        int client = players[i];
        weightSoFar += g_PlayerBets[client];
        if (randomWeight <= weightSoFar)
        {
            return client;
        }
    }

    return -1;
}

stock int CountBets()
{
    int count = 0;
    for (int i = 1; i <= MaxClients; i++)
    {
        if (g_PlayerBets[i] > 0)
        {
            count++;
        }
    }
    return count;
}

stock int FindSteamIDIndex(const char[] steamId)
{
    int count = g_PlayerBetsID.Length;
    for (int i = 0; i < count; i += 2) // Идем по 2, так как храним и Steam ID, и ставку
    {
        char storedSteamId[32];
        g_PlayerBetsID.GetString(i, storedSteamId, sizeof(storedSteamId));
        if (StrEqual(storedSteamId, steamId))
        {
            return i;
        }
    }
    return -1;
}