Иконка ресурса

[GAMECMS] Hit Map 0.1

Нет прав для скачивания

WowCMS

🤖
Команда форума
Участник
03.04.2023
88
98
  • Друг форума
  • #1

WILL_BE

Пользователь
04.10.2023
28
2
Плагин сделан был под старый gamecms, переделал:
plugin:
#define VALID_PLAYER(%1)        (1 <= (%1) <= MaxClients)


#define MIN_ROUND 10
#define MIN_TIME 300.0 // 300.0 / 60.0 = 5 min


#include <amxmodx>
#include <reapi>
#include <gamecms5>

// сколько рублей давать на баланс
new Float:REWARD = 5.0;

enum _:CMS_DATA
{
    KILLS,
    HS,
    DEATHS,
    TEAM_KILLS,
    TIME_RESPONSE,
    
};    new eUserData[MAX_PLAYERS + 1][CMS_DATA];

new Trie:g_tUserRewards;
new mp_freeforall;

public plugin_end()
{
    if (g_tUserRewards)
        TrieDestroy(g_tUserRewards);
}

public plugin_init()
{
    register_plugin("[CMS] Rewards", "0.1", "Emma Jule");
    
    RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed", true);
    RegisterHookChain(RG_CSGameRules_GoToIntermission, "CSGameRules_GoToIntermission", false);
    
    bind_pcvar_num(get_cvar_pointer("mp_freeforall"), mp_freeforall);
    
    g_tUserRewards = TrieCreate();
}

public OnConfigsExecuted()
{
    if (~cmsapi_get_api_status() & UseGameCms)
    {
        server_print("[CMS Rewards] Необходим рабочий плагин GameCMS_API");
        pause("ad");
    }
}

public client_authorized(id, const szAuth[])
{
    // if (strcmp(szAuth, "BOT") == 0 /* is_user_bot(id) */ )
        // return;
    
    if (!TrieGetArray(g_tUserRewards, szAuth, eUserData[id], CMS_DATA))
    {
        arrayset(eUserData[id], 0, CMS_DATA);
    }
}

public client_disconnected(id)
{
    new szAuth[MAX_AUTHID_LENGTH];
    get_user_authid(id, szAuth, charsmax(szAuth));
    {
        eUserData[id][TIME_RESPONSE] += get_user_time(id, .flag = 1);
        TrieSetArray(g_tUserRewards, szAuth, eUserData[id], CMS_DATA);
    }
}

public CBasePlayer_Killed(id, pevAttacker, pGib)
{
    eUserData[id][DEATHS]++;
    
/*
#if defined HARD_SCORE
    if (id != pevAttacker && VALID_PLAYER(pevAttacker) && pevInflictor == pevAttacker)
*/
    if (id != pevAttacker && VALID_PLAYER(pevAttacker))
    {
        // eUserData[pevAttacker][get_member(id, m_bHeadshotKilled) ? HS : KILLS]++;
        if (get_member(pevAttacker, m_iTeam) == get_member(id, m_iTeam) && mp_freeforall < 1)
        {
            eUserData[pevAttacker][TEAM_KILLS]++;
        }
        else
        {
            eUserData[pevAttacker][KILLS]++;
            if (get_member(id, m_bHeadshotKilled))
                eUserData[pevAttacker][HS]++;
        }
    }
}

public CSGameRules_GoToIntermission()
{
#if defined ROUND
    if (get_member_game(m_iTotalRoundsPlayed) < ROUND)
        return;
#endif

#if defined MIN_TIME
    if (get_gametime() - Float:get_member_game(m_flGameStartTime) < MIN_TIME)
        return;
#endif
    
    new pArray[MAX_PLAYERS], pNum;
    get_players(pArray, pNum, "ch");
    
    if (!pNum)
        return;
    
    new pPlayer, aData[MAX_PLAYERS + 1][2];
    for (--pNum; pNum >= 0; pNum--)
    {
        pPlayer = pArray[pNum];
        
        if (!cmsapi_is_user_member(pPlayer))
            continue;
        
        // необходимо пробыть как минимум 5 минут на сервере
        if ((!eUserData[pPlayer][TIME_RESPONSE] ? get_user_time(pPlayer, .flag = 1) : eUserData[pPlayer][TIME_RESPONSE]) < 300)
            continue;
        
        aData[pPlayer][0] = pPlayer;
        aData[pPlayer][1] = (eUserData[pPlayer][KILLS] + eUserData[pPlayer][HS]) - (eUserData[pPlayer][DEATHS] + (eUserData[pPlayer][TEAM_KILLS] * 2));
    }
    
    if (!VALID_PLAYER((pPlayer = aData[0][0])))
        return;
    
    SortCustom2D(aData, sizeof(aData), "SortArray");
    
    cmsapi_reload_wallet(pPlayer, REWARD);
    
/*
    for (pNum = 0; pNum < sizeof(aData); pNum++) {
        server_print("%d. %n - %d sec", pNum, aData[pNum][0], aData[pNum][1]);
    }
    
#if defined FREE_FLAGS
    if (cmsapi_get_api_status() & UseGameCmsAdmins)
        cmsapi_add_account(pPlayer, "ce", FLAGS_TIME, .szFlags = FREE_FLAGS, .check_params = false);
#endif
*/

}

public SortArray(const elem1[], const elem2[])
{
    return strcmp(elem2[1], elem1[1]);
    // return (elem1[1] < elem2[1]) ? 1 : (elem1[1] > elem2[1]) ? -1 : 0;
}
 
Сверху Снизу