код гравитации и звука на разминке

Portugal

Пользователь
Регистрация
2 Мар 2018
Сообщения
257
Симпатии
5
Предупреждения
60
Пол
Мужской
Некорректное название темы
Привет народ , нужна помошь.

Отсюда вынуть код гравитации и звука на разминке

Код:
#include <amxmodx>
#include <reapi>

const WARMUP_TIME = 60;
static const g_szSound[] = "wrsnz/wrsnz.wav";

const TASK = 100;
new g_hookEventCurWeapon, HookChain:g_hookRoundRestart, HookChain:g_hookSpawn, HookChain:g_hookKilled;
new gCount;

public plugin_precache()
{
   precache_sound(g_szSound);
}

public plugin_init()
{
   register_plugin("Knife_RR", "0.1", "unnamed");
 
   disable_event((g_hookEventCurWeapon = register_event("CurWeapon", "switchweapon", "be", "1=1", "2!29")));
   g_hookRoundRestart = RegisterHookChain(RG_CSGameRules_RestartRound, "CSGameRules_RestartRound_Pre", false);
   DisableHookChain((g_hookSpawn = RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn_Post", true)));
   DisableHookChain((g_hookKilled = RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed_Post", true)));
}

public CSGameRules_RestartRound_Pre()
{
   if(get_member_game(m_bCompleteReset))
   {
      gCount = WARMUP_TIME;
      EnableHookChain(g_hookSpawn);
      EnableHookChain(g_hookKilled);
      DisableHookChain(g_hookRoundRestart);
      enable_event(g_hookEventCurWeapon);
     
      server_cmd("sv_gravity 350");
      if(task_exists(TASK)) remove_task(TASK);
      set_task(1.0, "DisableRR", TASK, .flags = "a", .repeat = WARMUP_TIME);
   }
}

public CBasePlayer_Spawn_Post(const this)
{
   if(is_user_connected(this))
   {
      set_entvar(this, var_health, 65.0);
   }
}

public CBasePlayer_Killed_Post(const this)
{
   set_task(1.0, "respawn_player", this);
}

public switchweapon(id)
{
   engclient_cmd(id, "weapon_knife");
}

public respawn_player(id)
{
   if(is_user_connected(id) && !is_user_alive(id) && TEAM_TERRORIST <= get_member(id, m_iTeam) <= TEAM_CT)
   {
      rg_round_respawn(id);
   }
}

public DisableRR()
{
   if(--gCount > 0)
      client_print(0, print_center, "The battle will begin in: %d sec", gCount);
   else   client_print(0, print_center, "Warm up is over!");
 
   switch(gCount)
   {
      case 1: client_cmd(0, "spk sound/%s", g_szSound);
      case 0:
      {
         DisableHookChain(g_hookSpawn);
         DisableHookChain(g_hookKilled);
         disable_event(g_hookEventCurWeapon);
     
         set_cvar_num("sv_restart", 2);
         server_cmd("sv_gravity 850");
      }
   }
}

И вставить в этот плагин + если есть возможность сделать чтоб в конце разминки проигрывался не один звук а один из 3 ;)

Код:
/* ===============================================================================
* Knife warmup 0.1 [28.03.2016]
* Благодарности:
* - Sanlerus: реализация отлова выбора класса
* - s1lent: реализация и возможность использования 'Regamedll_CS', 'RoundControl'
* - Safety1st: способы реализации некоторых функций из 'Uncommon Knife Warmup'
* ============================================================================ */

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <hamsandwich>
//#include <roundcontrol> // раскомментируйте эту строку, если на сервере не используется Regamedll_CS

#pragma semicolon 1

#define bit_set(%0,%1) (%1 |= (1<<%0))
#define bit_clear(%0,%1) (%1 &= ~(1<<%0))
#define bit_valid(%0,%1) (%1 & (1<<%0))
#define USE_PAUSE // раскомментируйте эту строку, если желаете, чтобы плагин прекратил работу после выполнения задачи

#if AMXX_VERSION_NUM < 183
const MAX_PLAYERS = 30; // максимальное кол-во игроков на сервере, заменить своим (по умолчанию 32)
#endif
const WARMUP_TIME = 70; // кол-во времени в секундах, отведённое на разминку (по умолчанию 90)
const Float:RESPAWN_DELAY = 0.75; // кол-во времени в секундах, отведённое на задержку перед респауном (по умолчанию 0.75)
const Float:SHOW_MSG_DELAY = 0.8; // кол-во времени в секундах, отведённое на задержку перед отправкой HUD-сообщения (по умолчанию 0.5)
const Float:WARMUP_HEALTH = 65.0; // кол-во ед. здоровья, устанавливаемое игроку при спауне во время разминки (по умолчанию 35.0)
const HW_CROSS_AMMO_WPNLIST = (1<<0);
const HW_TIMER = (1<<4);
const HW_MONEY = (1<<5);

new const KILL_SOUNDS[][] = {
    "misc/sheep.wav", "misc/killChicken.wav", "misc/cow.wav"
};

enum {
    WS_WAITING = 1,
    WS_BEGIN,
    WS_IN_PROGRESS,
    WS_ENDED
}

new HamHook:g_pHamSpawn, HamHook:g_pHamAddPlayerItem, HamHook:g_pHamGiveAmmo, HamHook:g_pHamUse, HamHook:g_pHamKilled;

#if defined _roundcontrol_included
new RoundControlHook:g_pCheckWinHook;
#else
new g_pRoundInfinite, g_szRoundInfinite[10];
#endif

new g_pRestartRound, g_pHideWeaponMsgId, g_pStatusIconMsgId, g_pHudSyncObj1, g_pHudSyncObj2, g_pThinkEnt, g_iConnectedBitsum, g_iAliveBitsum, g_iMessageBitsum, g_iFrags[MAX_PLAYERS + 1],
    g_iWarmupState = WS_WAITING, g_pHideWeapon, g_iTimerCount;

public plugin_precache() {
    for(new i; i < sizeof KILL_SOUNDS; i++) {
        precache_sound(KILL_SOUNDS[i]);
    }
}

public plugin_init() {
    register_plugin("Knife warmup", "0.1", "Subb98");
    register_clcmd("joinclass", "CmdJoinClass");
    const JOIN_CLASS_MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5;
    register_menucmd(register_menuid("Terrorist_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_menucmd(register_menuid("CT_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_event("HLTV", "EventHLTV", "a", "1=0", "2=0");
    register_logevent("EventGameCommencing", 2, "1=Game_Commencing");
    register_logevent("EventRoundStart", 2, "1=Round_Start");
    register_logevent("EventRoundEnd", 2, "1=Round_End");
    new const ENT_CLASSNAME[] = "player";
    DisableHamForward(g_pHamSpawn = RegisterHam(Ham_Spawn, ENT_CLASSNAME, "HamSpawnPlayerPost", 1));
    DisableHamForward(g_pHamAddPlayerItem = RegisterHam(Ham_AddPlayerItem, ENT_CLASSNAME, "HamAddPlayerItemPre"));
    DisableHamForward(g_pHamGiveAmmo = RegisterHam(Ham_GiveAmmo, ENT_CLASSNAME, "HamGiveAmmoPre"));
    DisableHamForward(g_pHamUse = RegisterHam(Ham_Use, "hostage_entity", "HamUseHostagePre"));
    DisableHamForward(g_pHamKilled = RegisterHam(Ham_Killed, ENT_CLASSNAME, "HamKilledPlayerPost", 1));
    #if !defined _roundcontrol_included
    g_pRoundInfinite = get_cvar_pointer("mp_round_infinite");
    #endif
    g_pRestartRound = get_cvar_pointer("sv_restartround");
    g_pHideWeaponMsgId = get_user_msgid("HideWeapon");
    g_pStatusIconMsgId = get_user_msgid("StatusIcon");
    g_pHudSyncObj1 = CreateHudSyncObj();
    g_pHudSyncObj2 = CreateHudSyncObj();
    CreateThinkEntity();
}

#if !defined _roundcontrol_included
public plugin_cfg() {
    if(g_pRoundInfinite) {
        get_pcvar_string(g_pRoundInfinite, g_szRoundInfinite, charsmax(g_szRoundInfinite));
    }
}
#endif

public client_putinserver(id) {
    ResetValues(id);
    if(!is_user_bot(id) && !is_user_hltv(id)) {
        bit_set(id, g_iConnectedBitsum);
    }
}

public client_disconnected(id) {
    ResetValues(id);
    remove_task(id);
}

public CmdJoinClass(const id) {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        set_task(RESPAWN_DELAY, "TaskRespawn", id);
    }
}

public EventHLTV() {
    switch(g_iWarmupState) {
        case WS_BEGIN: {
            g_iWarmupState = WS_IN_PROGRESS;
            g_iMessageBitsum = 0;
            EnableHamForward(g_pHamSpawn);
            EnableHamForward(g_pHamAddPlayerItem);
            EnableHamForward(g_pHamGiveAmmo);
            EnableHamForward(g_pHamUse);
            EnableHamForward(g_pHamKilled);
            g_pHideWeapon = register_message(g_pHideWeaponMsgId, "MessageHideWeapon");
            #if defined _roundcontrol_included
            g_pCheckWinHook = SetBlockControl(RC_CheckWinConditions);
            #else
            if(g_pRoundInfinite) {
                set_pcvar_num(g_pRoundInfinite, 1);
            }
            #endif
            set_msg_block(g_pStatusIconMsgId, BLOCK_SET);
        }
        case WS_ENDED: {
            entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + SHOW_MSG_DELAY);
        }
    }
}

public EventGameCommencing() {
    if(g_iWarmupState == WS_WAITING) {
        g_iWarmupState = WS_BEGIN;
    }
}

public EventRoundStart() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + 1.0);
    }
}

public EventRoundEnd() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        g_iWarmupState = WS_ENDED;
        DisableHamForward(g_pHamSpawn);
        DisableHamForward(g_pHamAddPlayerItem);
        DisableHamForward(g_pHamGiveAmmo);
        DisableHamForward(g_pHamUse);
        DisableHamForward(g_pHamKilled);
        unregister_message(g_pHideWeaponMsgId, g_pHideWeapon);
        #if defined _roundcontrol_included
        RemoveBlockControl(RC_CheckWinConditions, g_pCheckWinHook);
        #else
        if(g_pRoundInfinite) {
            set_pcvar_string(g_pRoundInfinite, g_szRoundInfinite);
        }
        #endif
        set_msg_block(g_pStatusIconMsgId, BLOCK_NOT);
        set_pcvar_float(g_pRestartRound, 1.0);
    }
}

public MessageHideWeapon() {
    const ARG_FLAGS = 1;
    set_msg_arg_int(ARG_FLAGS, ARG_BYTE, get_msg_arg_int(ARG_FLAGS) | HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
}

public HamSpawnPlayerPost(const id) {
    if(is_user_alive(id)) {
        bit_set(id, g_iAliveBitsum);
        if(!bit_valid(id, g_iMessageBitsum)) {
            set_task(SHOW_MSG_DELAY, "TaskWarmupStartMsg", id);
        }
        entity_set_float(id, EV_FL_health, WARMUP_HEALTH);
        engclient_cmd(id, "weapon_knife");
        message_begin(MSG_ONE, g_pHideWeaponMsgId, _, id);
        write_byte(HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
        message_end();
    }
}

public HamAddPlayerItemPre(const id, const pEnt) {
    if(cs_get_weapon_id(pEnt) != CSW_KNIFE) {
        entity_set_int(pEnt, EV_INT_flags, entity_get_int(pEnt, EV_INT_flags ) | FL_KILLME);
        SetHamReturnInteger(0);
        return HAM_SUPERCEDE;
    }
    return HAM_IGNORED;
}

public HamGiveAmmoPre() {
    const NO_AMMO_STOP_PROCESSING = -1;
    SetHamReturnInteger(NO_AMMO_STOP_PROCESSING);
    return HAM_SUPERCEDE;
}

public HamUseHostagePre() {
    return HAM_SUPERCEDE;
}

public HamKilledPlayerPost(const id, const pKiller) {
    bit_clear(id, g_iAliveBitsum);
    if(bit_valid(pKiller, g_iAliveBitsum)) {
        if(g_iFrags[pKiller] == sizeof KILL_SOUNDS) {
            g_iFrags[pKiller] = 0;
        }
        emit_sound(pKiller, CHAN_VOICE, KILL_SOUNDS[g_iFrags[pKiller]], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
        g_iFrags[pKiller]++;
    }
    set_task(RESPAWN_DELAY, "TaskRespawn", id);
}

public FwdThink(const pEnt) {
    switch(g_iWarmupState) {
        case WS_IN_PROGRESS: {
            static iDiff, iMin;
            iDiff = WARMUP_TIME - g_iTimerCount++, iMin = 0;
            GetMinutes(iDiff, iMin);
            set_hudmessage(255, 255, 255, _, 0.96, _, _, 1.0, 0.0, 0.01, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj1, "Iki warmup pabaigos: %d:%d", iMin, iDiff);
            if(iDiff || iMin) {
                entity_set_float(pEnt, EV_FL_nextthink, get_gametime() + 1.0);
            } else {
                EventRoundEnd();
            }
        }
        case WS_ENDED: {
            g_iWarmupState = WS_WAITING;
            g_iTimerCount = 0;
            set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj2, "Žaidimas prasideda!^nGL HF!");
            #if defined USE_PAUSE
            pause("d");
            #endif
        }
    }
}

public TaskRespawn(const id) {
    if(bit_valid(id, g_iConnectedBitsum) && !bit_valid(id, g_iAliveBitsum) && cs_get_user_team(id) != CS_TEAM_SPECTATOR) {
        ExecuteHamB(Ham_CS_RoundRespawn, id);
    }
}

public TaskWarmupStartMsg(const id) {
    if(bit_valid(id, g_iAliveBitsum)) {
        set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
        ShowSyncHudMsg(id, g_pHudSyncObj2, "Pasiruošk!^n[WARMUP] - Prasideda!");
        bit_set(id, g_iMessageBitsum);
    }
}

CreateThinkEntity() {
    new const ENT_CLASSNAME[] = "_warmup_think_ent";
    if((g_pThinkEnt = create_entity("info_target"))) {
        entity_set_string(g_pThinkEnt, EV_SZ_classname, ENT_CLASSNAME);
        register_think(ENT_CLASSNAME, "FwdThink");
    } else {
        set_fail_state("Failed to create think entity");
    }
}

ResetValues(const id) {
    bit_clear(id, g_iConnectedBitsum);
    bit_clear(id, g_iAliveBitsum);
    bit_clear(id, g_iMessageBitsum);
    g_iFrags[id] = 0;
}

GetMinutes(&iSec, &iMin) {
    const SECONDS_IN_MINUTE = 60;
    iMin = iSec / SECONDS_IN_MINUTE, iSec %= SECONDS_IN_MINUTE;
}
 
Последнее редактирование модератором:

gesk1995

Пользователь
Регистрация
8 Июн 2017
Сообщения
339
Симпатии
12
Пол
Мужской
За тебя никто делать не будет, если вы хотите что бы за вас всё сделали , вам сюда ------->>>> Куплю/заплачу
 

Portugal

Пользователь
Регистрация
2 Мар 2018
Сообщения
257
Симпатии
5
Предупреждения
60
Пол
Мужской

Mandar1n

theRoone
Пользователь
Регистрация
13 Янв 2018
Сообщения
394
Симпатии
71
Пол
Мужской
Не видно цены
 

perfectblood0

Команда форума
Администратор
Регистрация
29 Окт 2017
Сообщения
2.578
Симпатии
914
Пол
Женский
У нас все таки комьюнити, оставьте призывы о платном решении проблемы автору.
 

Musamuhamed

Заблокированные
Пользователь
Регистрация
24 Июл 2017
Сообщения
133
Симпатии
18
Пол
Мужской
Привет народ , нужна помошь.

Отсюда вынуть код гравитации и звука на разминке

Код:
#include <amxmodx>
#include <reapi>

const WARMUP_TIME = 60;
static const g_szSound[] = "wrsnz/wrsnz.wav";

const TASK = 100;
new g_hookEventCurWeapon, HookChain:g_hookRoundRestart, HookChain:g_hookSpawn, HookChain:g_hookKilled;
new gCount;

public plugin_precache()
{
   precache_sound(g_szSound);
}

public plugin_init()
{
   register_plugin("Knife_RR", "0.1", "unnamed");

   disable_event((g_hookEventCurWeapon = register_event("CurWeapon", "switchweapon", "be", "1=1", "2!29")));
   g_hookRoundRestart = RegisterHookChain(RG_CSGameRules_RestartRound, "CSGameRules_RestartRound_Pre", false);
   DisableHookChain((g_hookSpawn = RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn_Post", true)));
   DisableHookChain((g_hookKilled = RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed_Post", true)));
}

public CSGameRules_RestartRound_Pre()
{
   if(get_member_game(m_bCompleteReset))
   {
      gCount = WARMUP_TIME;
      EnableHookChain(g_hookSpawn);
      EnableHookChain(g_hookKilled);
      DisableHookChain(g_hookRoundRestart);
      enable_event(g_hookEventCurWeapon);
    
      server_cmd("sv_gravity 350");
      if(task_exists(TASK)) remove_task(TASK);
      set_task(1.0, "DisableRR", TASK, .flags = "a", .repeat = WARMUP_TIME);
   }
}

public CBasePlayer_Spawn_Post(const this)
{
   if(is_user_connected(this))
   {
      set_entvar(this, var_health, 65.0);
   }
}

public CBasePlayer_Killed_Post(const this)
{
   set_task(1.0, "respawn_player", this);
}

public switchweapon(id)
{
   engclient_cmd(id, "weapon_knife");
}

public respawn_player(id)
{
   if(is_user_connected(id) && !is_user_alive(id) && TEAM_TERRORIST <= get_member(id, m_iTeam) <= TEAM_CT)
   {
      rg_round_respawn(id);
   }
}

public DisableRR()
{
   if(--gCount > 0)
      client_print(0, print_center, "The battle will begin in: %d sec", gCount);
   else   client_print(0, print_center, "Warm up is over!");

   switch(gCount)
   {
      case 1: client_cmd(0, "spk sound/%s", g_szSound);
      case 0:
      {
         DisableHookChain(g_hookSpawn);
         DisableHookChain(g_hookKilled);
         disable_event(g_hookEventCurWeapon);
    
         set_cvar_num("sv_restart", 2);
         server_cmd("sv_gravity 850");
      }
   }
}

И вставить в этот плагин + если есть возможность сделать чтоб в конце разминки проигрывался не один звук а один из 3 ;)

Код:
/* ===============================================================================
* Knife warmup 0.1 [28.03.2016]
* Благодарности:
* - Sanlerus: реализация отлова выбора класса
* - s1lent: реализация и возможность использования 'Regamedll_CS', 'RoundControl'
* - Safety1st: способы реализации некоторых функций из 'Uncommon Knife Warmup'
* ============================================================================ */

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <hamsandwich>
//#include <roundcontrol> // раскомментируйте эту строку, если на сервере не используется Regamedll_CS

#pragma semicolon 1

#define bit_set(%0,%1) (%1 |= (1<<%0))
#define bit_clear(%0,%1) (%1 &= ~(1<<%0))
#define bit_valid(%0,%1) (%1 & (1<<%0))
#define USE_PAUSE // раскомментируйте эту строку, если желаете, чтобы плагин прекратил работу после выполнения задачи

#if AMXX_VERSION_NUM < 183
const MAX_PLAYERS = 30; // максимальное кол-во игроков на сервере, заменить своим (по умолчанию 32)
#endif
const WARMUP_TIME = 70; // кол-во времени в секундах, отведённое на разминку (по умолчанию 90)
const Float:RESPAWN_DELAY = 0.75; // кол-во времени в секундах, отведённое на задержку перед респауном (по умолчанию 0.75)
const Float:SHOW_MSG_DELAY = 0.8; // кол-во времени в секундах, отведённое на задержку перед отправкой HUD-сообщения (по умолчанию 0.5)
const Float:WARMUP_HEALTH = 65.0; // кол-во ед. здоровья, устанавливаемое игроку при спауне во время разминки (по умолчанию 35.0)
const HW_CROSS_AMMO_WPNLIST = (1<<0);
const HW_TIMER = (1<<4);
const HW_MONEY = (1<<5);

new const KILL_SOUNDS[][] = {
    "misc/sheep.wav", "misc/killChicken.wav", "misc/cow.wav"
};

enum {
    WS_WAITING = 1,
    WS_BEGIN,
    WS_IN_PROGRESS,
    WS_ENDED
}

new HamHook:g_pHamSpawn, HamHook:g_pHamAddPlayerItem, HamHook:g_pHamGiveAmmo, HamHook:g_pHamUse, HamHook:g_pHamKilled;

#if defined _roundcontrol_included
new RoundControlHook:g_pCheckWinHook;
#else
new g_pRoundInfinite, g_szRoundInfinite[10];
#endif

new g_pRestartRound, g_pHideWeaponMsgId, g_pStatusIconMsgId, g_pHudSyncObj1, g_pHudSyncObj2, g_pThinkEnt, g_iConnectedBitsum, g_iAliveBitsum, g_iMessageBitsum, g_iFrags[MAX_PLAYERS + 1],
    g_iWarmupState = WS_WAITING, g_pHideWeapon, g_iTimerCount;

public plugin_precache() {
    for(new i; i < sizeof KILL_SOUNDS; i++) {
        precache_sound(KILL_SOUNDS[i]);
    }
}

public plugin_init() {
    register_plugin("Knife warmup", "0.1", "Subb98");
    register_clcmd("joinclass", "CmdJoinClass");
    const JOIN_CLASS_MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5;
    register_menucmd(register_menuid("Terrorist_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_menucmd(register_menuid("CT_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_event("HLTV", "EventHLTV", "a", "1=0", "2=0");
    register_logevent("EventGameCommencing", 2, "1=Game_Commencing");
    register_logevent("EventRoundStart", 2, "1=Round_Start");
    register_logevent("EventRoundEnd", 2, "1=Round_End");
    new const ENT_CLASSNAME[] = "player";
    DisableHamForward(g_pHamSpawn = RegisterHam(Ham_Spawn, ENT_CLASSNAME, "HamSpawnPlayerPost", 1));
    DisableHamForward(g_pHamAddPlayerItem = RegisterHam(Ham_AddPlayerItem, ENT_CLASSNAME, "HamAddPlayerItemPre"));
    DisableHamForward(g_pHamGiveAmmo = RegisterHam(Ham_GiveAmmo, ENT_CLASSNAME, "HamGiveAmmoPre"));
    DisableHamForward(g_pHamUse = RegisterHam(Ham_Use, "hostage_entity", "HamUseHostagePre"));
    DisableHamForward(g_pHamKilled = RegisterHam(Ham_Killed, ENT_CLASSNAME, "HamKilledPlayerPost", 1));
    #if !defined _roundcontrol_included
    g_pRoundInfinite = get_cvar_pointer("mp_round_infinite");
    #endif
    g_pRestartRound = get_cvar_pointer("sv_restartround");
    g_pHideWeaponMsgId = get_user_msgid("HideWeapon");
    g_pStatusIconMsgId = get_user_msgid("StatusIcon");
    g_pHudSyncObj1 = CreateHudSyncObj();
    g_pHudSyncObj2 = CreateHudSyncObj();
    CreateThinkEntity();
}

#if !defined _roundcontrol_included
public plugin_cfg() {
    if(g_pRoundInfinite) {
        get_pcvar_string(g_pRoundInfinite, g_szRoundInfinite, charsmax(g_szRoundInfinite));
    }
}
#endif

public client_putinserver(id) {
    ResetValues(id);
    if(!is_user_bot(id) && !is_user_hltv(id)) {
        bit_set(id, g_iConnectedBitsum);
    }
}

public client_disconnected(id) {
    ResetValues(id);
    remove_task(id);
}

public CmdJoinClass(const id) {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        set_task(RESPAWN_DELAY, "TaskRespawn", id);
    }
}

public EventHLTV() {
    switch(g_iWarmupState) {
        case WS_BEGIN: {
            g_iWarmupState = WS_IN_PROGRESS;
            g_iMessageBitsum = 0;
            EnableHamForward(g_pHamSpawn);
            EnableHamForward(g_pHamAddPlayerItem);
            EnableHamForward(g_pHamGiveAmmo);
            EnableHamForward(g_pHamUse);
            EnableHamForward(g_pHamKilled);
            g_pHideWeapon = register_message(g_pHideWeaponMsgId, "MessageHideWeapon");
            #if defined _roundcontrol_included
            g_pCheckWinHook = SetBlockControl(RC_CheckWinConditions);
            #else
            if(g_pRoundInfinite) {
                set_pcvar_num(g_pRoundInfinite, 1);
            }
            #endif
            set_msg_block(g_pStatusIconMsgId, BLOCK_SET);
        }
        case WS_ENDED: {
            entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + SHOW_MSG_DELAY);
        }
    }
}

public EventGameCommencing() {
    if(g_iWarmupState == WS_WAITING) {
        g_iWarmupState = WS_BEGIN;
    }
}

public EventRoundStart() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + 1.0);
    }
}

public EventRoundEnd() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        g_iWarmupState = WS_ENDED;
        DisableHamForward(g_pHamSpawn);
        DisableHamForward(g_pHamAddPlayerItem);
        DisableHamForward(g_pHamGiveAmmo);
        DisableHamForward(g_pHamUse);
        DisableHamForward(g_pHamKilled);
        unregister_message(g_pHideWeaponMsgId, g_pHideWeapon);
        #if defined _roundcontrol_included
        RemoveBlockControl(RC_CheckWinConditions, g_pCheckWinHook);
        #else
        if(g_pRoundInfinite) {
            set_pcvar_string(g_pRoundInfinite, g_szRoundInfinite);
        }
        #endif
        set_msg_block(g_pStatusIconMsgId, BLOCK_NOT);
        set_pcvar_float(g_pRestartRound, 1.0);
    }
}

public MessageHideWeapon() {
    const ARG_FLAGS = 1;
    set_msg_arg_int(ARG_FLAGS, ARG_BYTE, get_msg_arg_int(ARG_FLAGS) | HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
}

public HamSpawnPlayerPost(const id) {
    if(is_user_alive(id)) {
        bit_set(id, g_iAliveBitsum);
        if(!bit_valid(id, g_iMessageBitsum)) {
            set_task(SHOW_MSG_DELAY, "TaskWarmupStartMsg", id);
        }
        entity_set_float(id, EV_FL_health, WARMUP_HEALTH);
        engclient_cmd(id, "weapon_knife");
        message_begin(MSG_ONE, g_pHideWeaponMsgId, _, id);
        write_byte(HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
        message_end();
    }
}

public HamAddPlayerItemPre(const id, const pEnt) {
    if(cs_get_weapon_id(pEnt) != CSW_KNIFE) {
        entity_set_int(pEnt, EV_INT_flags, entity_get_int(pEnt, EV_INT_flags ) | FL_KILLME);
        SetHamReturnInteger(0);
        return HAM_SUPERCEDE;
    }
    return HAM_IGNORED;
}

public HamGiveAmmoPre() {
    const NO_AMMO_STOP_PROCESSING = -1;
    SetHamReturnInteger(NO_AMMO_STOP_PROCESSING);
    return HAM_SUPERCEDE;
}

public HamUseHostagePre() {
    return HAM_SUPERCEDE;
}

public HamKilledPlayerPost(const id, const pKiller) {
    bit_clear(id, g_iAliveBitsum);
    if(bit_valid(pKiller, g_iAliveBitsum)) {
        if(g_iFrags[pKiller] == sizeof KILL_SOUNDS) {
            g_iFrags[pKiller] = 0;
        }
        emit_sound(pKiller, CHAN_VOICE, KILL_SOUNDS[g_iFrags[pKiller]], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
        g_iFrags[pKiller]++;
    }
    set_task(RESPAWN_DELAY, "TaskRespawn", id);
}

public FwdThink(const pEnt) {
    switch(g_iWarmupState) {
        case WS_IN_PROGRESS: {
            static iDiff, iMin;
            iDiff = WARMUP_TIME - g_iTimerCount++, iMin = 0;
            GetMinutes(iDiff, iMin);
            set_hudmessage(255, 255, 255, _, 0.96, _, _, 1.0, 0.0, 0.01, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj1, "Iki warmup pabaigos: %d:%d", iMin, iDiff);
            if(iDiff || iMin) {
                entity_set_float(pEnt, EV_FL_nextthink, get_gametime() + 1.0);
            } else {
                EventRoundEnd();
            }
        }
        case WS_ENDED: {
            g_iWarmupState = WS_WAITING;
            g_iTimerCount = 0;
            set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj2, "Žaidimas prasideda!^nGL HF!");
            #if defined USE_PAUSE
            pause("d");
            #endif
        }
    }
}

public TaskRespawn(const id) {
    if(bit_valid(id, g_iConnectedBitsum) && !bit_valid(id, g_iAliveBitsum) && cs_get_user_team(id) != CS_TEAM_SPECTATOR) {
        ExecuteHamB(Ham_CS_RoundRespawn, id);
    }
}

public TaskWarmupStartMsg(const id) {
    if(bit_valid(id, g_iAliveBitsum)) {
        set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
        ShowSyncHudMsg(id, g_pHudSyncObj2, "Pasiruošk!^n[WARMUP] - Prasideda!");
        bit_set(id, g_iMessageBitsum);
    }
}

CreateThinkEntity() {
    new const ENT_CLASSNAME[] = "_warmup_think_ent";
    if((g_pThinkEnt = create_entity("info_target"))) {
        entity_set_string(g_pThinkEnt, EV_SZ_classname, ENT_CLASSNAME);
        register_think(ENT_CLASSNAME, "FwdThink");
    } else {
        set_fail_state("Failed to create think entity");
    }
}

ResetValues(const id) {
    bit_clear(id, g_iConnectedBitsum);
    bit_clear(id, g_iAliveBitsum);
    bit_clear(id, g_iMessageBitsum);
    g_iFrags[id] = 0;
}

GetMinutes(&iSec, &iMin) {
    const SECONDS_IN_MINUTE = 60;
    iMin = iSec / SECONDS_IN_MINUTE, iSec %= SECONDS_IN_MINUTE;
}
 

Вложения

To be or not to be

Пользователь
Регистрация
9 Июн 2017
Сообщения
1.215
Симпатии
304
Portugal, держи
Код:
/* ===============================================================================
* Knife warmup 0.1 [28.03.2016]
* Благодарности:
* - Sanlerus: реализация отлова выбора класса
* - s1lent: реализация и возможность использования 'Regamedll_CS', 'RoundControl'
* - Safety1st: способы реализации некоторых функций из 'Uncommon Knife Warmup'
* ============================================================================ */

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <hamsandwich>
//#include <roundcontrol> // раскомментируйте эту строку, если на сервере не используется Regamedll_CS

static const g_szSound[] = "wrsnz/wrsnz.wav";

#pragma semicolon 1

#define bit_set(%0,%1) (%1 |= (1<<%0))
#define bit_clear(%0,%1) (%1 &= ~(1<<%0))
#define bit_valid(%0,%1) (%1 & (1<<%0))
#define USE_PAUSE // раскомментируйте эту строку, если желаете, чтобы плагин прекратил работу после выполнения задачи

#if AMXX_VERSION_NUM < 183
const MAX_PLAYERS = 30; // максимальное кол-во игроков на сервере, заменить своим (по умолчанию 32)
#endif
const WARMUP_TIME = 70; // кол-во времени в секундах, отведённое на разминку (по умолчанию 90)
const Float:RESPAWN_DELAY = 0.75; // кол-во времени в секундах, отведённое на задержку перед респауном (по умолчанию 0.75)
const Float:SHOW_MSG_DELAY = 0.8; // кол-во времени в секундах, отведённое на задержку перед отправкой HUD-сообщения (по умолчанию 0.5)
const Float:WARMUP_HEALTH = 65.0; // кол-во ед. здоровья, устанавливаемое игроку при спауне во время разминки (по умолчанию 35.0)
const HW_CROSS_AMMO_WPNLIST = (1<<0);
const HW_TIMER = (1<<4);
const HW_MONEY = (1<<5);

new const KILL_SOUNDS[][] = {
    "misc/sheep.wav", "misc/killChicken.wav", "misc/cow.wav"
};

enum {
    WS_WAITING = 1,
    WS_BEGIN,
    WS_IN_PROGRESS,
    WS_ENDED
}

new HamHook:g_pHamSpawn, HamHook:g_pHamAddPlayerItem, HamHook:g_pHamGiveAmmo, HamHook:g_pHamUse, HamHook:g_pHamKilled;

#if defined _roundcontrol_included
new RoundControlHook:g_pCheckWinHook;
#else
new g_pRoundInfinite, g_szRoundInfinite[10];
#endif

new g_pRestartRound, g_pHideWeaponMsgId, g_pStatusIconMsgId, g_pHudSyncObj1, g_pHudSyncObj2, g_pThinkEnt, g_iConnectedBitsum, g_iAliveBitsum, g_iMessageBitsum, g_iFrags[MAX_PLAYERS + 1],
    g_iWarmupState = WS_WAITING, g_pHideWeapon, g_iTimerCount;

public plugin_precache() {
    for(new i; i < sizeof KILL_SOUNDS; i++) {
        precache_sound(KILL_SOUNDS[i]);
    }
    precache_sound(g_szSound);
}

public plugin_init() {
    register_plugin("Knife warmup", "0.1", "Subb98");
    register_clcmd("joinclass", "CmdJoinClass");
    const JOIN_CLASS_MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5;
    register_menucmd(register_menuid("Terrorist_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_menucmd(register_menuid("CT_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_event("HLTV", "EventHLTV", "a", "1=0", "2=0");
    register_logevent("EventGameCommencing", 2, "1=Game_Commencing");
    register_logevent("EventRoundStart", 2, "1=Round_Start");
    register_logevent("EventRoundEnd", 2, "1=Round_End");
    new const ENT_CLASSNAME[] = "player";
    DisableHamForward(g_pHamSpawn = RegisterHam(Ham_Spawn, ENT_CLASSNAME, "HamSpawnPlayerPost", 1));
    DisableHamForward(g_pHamAddPlayerItem = RegisterHam(Ham_AddPlayerItem, ENT_CLASSNAME, "HamAddPlayerItemPre"));
    DisableHamForward(g_pHamGiveAmmo = RegisterHam(Ham_GiveAmmo, ENT_CLASSNAME, "HamGiveAmmoPre"));
    DisableHamForward(g_pHamUse = RegisterHam(Ham_Use, "hostage_entity", "HamUseHostagePre"));
    DisableHamForward(g_pHamKilled = RegisterHam(Ham_Killed, ENT_CLASSNAME, "HamKilledPlayerPost", 1));
    #if !defined _roundcontrol_included
    g_pRoundInfinite = get_cvar_pointer("mp_round_infinite");
    #endif
    g_pRestartRound = get_cvar_pointer("sv_restartround");
    g_pHideWeaponMsgId = get_user_msgid("HideWeapon");
    g_pStatusIconMsgId = get_user_msgid("StatusIcon");
    g_pHudSyncObj1 = CreateHudSyncObj();
    g_pHudSyncObj2 = CreateHudSyncObj();
    CreateThinkEntity();
}

#if !defined _roundcontrol_included
public plugin_cfg() {
    if(g_pRoundInfinite) {
        get_pcvar_string(g_pRoundInfinite, g_szRoundInfinite, charsmax(g_szRoundInfinite));
    }
}
#endif

public client_putinserver(id) {
    ResetValues(id);
    if(!is_user_bot(id) && !is_user_hltv(id)) {
        bit_set(id, g_iConnectedBitsum);
    }
}

public client_disconnected(id) {
    ResetValues(id);
    remove_task(id);
}

public CmdJoinClass(const id) {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        set_task(RESPAWN_DELAY, "TaskRespawn", id);
    }
}

public EventHLTV() {
    switch(g_iWarmupState) {
        case WS_BEGIN: {
            g_iWarmupState = WS_IN_PROGRESS;
            g_iMessageBitsum = 0;
            EnableHamForward(g_pHamSpawn);
            EnableHamForward(g_pHamAddPlayerItem);
            EnableHamForward(g_pHamGiveAmmo);
            EnableHamForward(g_pHamUse);
            EnableHamForward(g_pHamKilled);
            server_cmd("sv_gravity 350");
            g_pHideWeapon = register_message(g_pHideWeaponMsgId, "MessageHideWeapon");
            #if defined _roundcontrol_included
            g_pCheckWinHook = SetBlockControl(RC_CheckWinConditions);
            #else
            if(g_pRoundInfinite) {
                set_pcvar_num(g_pRoundInfinite, 1);
            }
            #endif
            set_msg_block(g_pStatusIconMsgId, BLOCK_SET);
        }
        case WS_ENDED: {
            entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + SHOW_MSG_DELAY);
        }
    }
}

public EventGameCommencing() {
    if(g_iWarmupState == WS_WAITING) {
        g_iWarmupState = WS_BEGIN;
    }
}

public EventRoundStart() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + 1.0);
    }
}

public EventRoundEnd() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        g_iWarmupState = WS_ENDED;
        DisableHamForward(g_pHamSpawn);
        DisableHamForward(g_pHamAddPlayerItem);
        DisableHamForward(g_pHamGiveAmmo);
        DisableHamForward(g_pHamUse);
        DisableHamForward(g_pHamKilled);
        server_cmd("sv_gravity 850");
        client_cmd(0, "spk sound/%s", g_szSound);
        unregister_message(g_pHideWeaponMsgId, g_pHideWeapon);
        #if defined _roundcontrol_included
        RemoveBlockControl(RC_CheckWinConditions, g_pCheckWinHook);
        #else
        if(g_pRoundInfinite) {
            set_pcvar_string(g_pRoundInfinite, g_szRoundInfinite);
        }
        #endif
        set_msg_block(g_pStatusIconMsgId, BLOCK_NOT);
        set_pcvar_float(g_pRestartRound, 1.0);
    }
}

public MessageHideWeapon() {
    const ARG_FLAGS = 1;
    set_msg_arg_int(ARG_FLAGS, ARG_BYTE, get_msg_arg_int(ARG_FLAGS) | HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
}

public HamSpawnPlayerPost(const id) {
    if(is_user_alive(id)) {
        bit_set(id, g_iAliveBitsum);
        if(!bit_valid(id, g_iMessageBitsum)) {
            set_task(SHOW_MSG_DELAY, "TaskWarmupStartMsg", id);
        }
        entity_set_float(id, EV_FL_health, WARMUP_HEALTH);
        engclient_cmd(id, "weapon_knife");
        message_begin(MSG_ONE, g_pHideWeaponMsgId, _, id);
        write_byte(HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
        message_end();
    }
}

public HamAddPlayerItemPre(const id, const pEnt) {
    if(cs_get_weapon_id(pEnt) != CSW_KNIFE) {
        entity_set_int(pEnt, EV_INT_flags, entity_get_int(pEnt, EV_INT_flags ) | FL_KILLME);
        SetHamReturnInteger(0);
        return HAM_SUPERCEDE;
    }
    return HAM_IGNORED;
}

public HamGiveAmmoPre() {
    const NO_AMMO_STOP_PROCESSING = -1;
    SetHamReturnInteger(NO_AMMO_STOP_PROCESSING);
    return HAM_SUPERCEDE;
}

public HamUseHostagePre() {
    return HAM_SUPERCEDE;
}

public HamKilledPlayerPost(const id, const pKiller) {
    bit_clear(id, g_iAliveBitsum);
    if(bit_valid(pKiller, g_iAliveBitsum)) {
        if(g_iFrags[pKiller] == sizeof KILL_SOUNDS) {
            g_iFrags[pKiller] = 0;
        }
        emit_sound(pKiller, CHAN_VOICE, KILL_SOUNDS[g_iFrags[pKiller]], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
        g_iFrags[pKiller]++;
    }
    set_task(RESPAWN_DELAY, "TaskRespawn", id);
}

public FwdThink(const pEnt) {
    switch(g_iWarmupState) {
        case WS_IN_PROGRESS: {
            static iDiff, iMin;
            iDiff = WARMUP_TIME - g_iTimerCount++, iMin = 0;
            GetMinutes(iDiff, iMin);
            set_hudmessage(255, 255, 255, _, 0.96, _, _, 1.0, 0.0, 0.01, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj1, "Iki warmup pabaigos: %d:%d", iMin, iDiff);
            if(iDiff || iMin) {
                entity_set_float(pEnt, EV_FL_nextthink, get_gametime() + 1.0);
            } else {
                EventRoundEnd();
            }
        }
        case WS_ENDED: {
            g_iWarmupState = WS_WAITING;
            g_iTimerCount = 0;
            set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj2, "Žaidimas prasideda!^nGL HF!");
            #if defined USE_PAUSE
            pause("d");
            #endif
        }
    }
}

public TaskRespawn(const id) {
    if(bit_valid(id, g_iConnectedBitsum) && !bit_valid(id, g_iAliveBitsum) && cs_get_user_team(id) != CS_TEAM_SPECTATOR) {
        ExecuteHamB(Ham_CS_RoundRespawn, id);
    }
}

public TaskWarmupStartMsg(const id) {
    if(bit_valid(id, g_iAliveBitsum)) {
        set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
        ShowSyncHudMsg(id, g_pHudSyncObj2, "Pasiruošk!^n[WARMUP] - Prasideda!");
        bit_set(id, g_iMessageBitsum);
    }
}

CreateThinkEntity() {
    new const ENT_CLASSNAME[] = "_warmup_think_ent";
    if((g_pThinkEnt = create_entity("info_target"))) {
        entity_set_string(g_pThinkEnt, EV_SZ_classname, ENT_CLASSNAME);
        register_think(ENT_CLASSNAME, "FwdThink");
    } else {
        set_fail_state("Failed to create think entity");
    }
}

ResetValues(const id) {
    bit_clear(id, g_iConnectedBitsum);
    bit_clear(id, g_iAliveBitsum);
    bit_clear(id, g_iMessageBitsum);
    g_iFrags[id] = 0;
}

GetMinutes(&iSec, &iMin) {
    const SECONDS_IN_MINUTE = 60;
    iMin = iSec / SECONDS_IN_MINUTE, iSec %= SECONDS_IN_MINUTE;
}
Musamuhamed, читайте внимательнее, пожалуйста
 

Portugal

Пользователь
Регистрация
2 Мар 2018
Сообщения
257
Симпатии
5
Предупреждения
60
Пол
Мужской
Portugal, держи
Код:
/* ===============================================================================
* Knife warmup 0.1 [28.03.2016]
* Благодарности:
* - Sanlerus: реализация отлова выбора класса
* - s1lent: реализация и возможность использования 'Regamedll_CS', 'RoundControl'
* - Safety1st: способы реализации некоторых функций из 'Uncommon Knife Warmup'
* ============================================================================ */

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <hamsandwich>
//#include <roundcontrol> // раскомментируйте эту строку, если на сервере не используется Regamedll_CS

static const g_szSound[] = "wrsnz/wrsnz.wav";

#pragma semicolon 1

#define bit_set(%0,%1) (%1 |= (1<<%0))
#define bit_clear(%0,%1) (%1 &= ~(1<<%0))
#define bit_valid(%0,%1) (%1 & (1<<%0))
#define USE_PAUSE // раскомментируйте эту строку, если желаете, чтобы плагин прекратил работу после выполнения задачи

#if AMXX_VERSION_NUM < 183
const MAX_PLAYERS = 30; // максимальное кол-во игроков на сервере, заменить своим (по умолчанию 32)
#endif
const WARMUP_TIME = 70; // кол-во времени в секундах, отведённое на разминку (по умолчанию 90)
const Float:RESPAWN_DELAY = 0.75; // кол-во времени в секундах, отведённое на задержку перед респауном (по умолчанию 0.75)
const Float:SHOW_MSG_DELAY = 0.8; // кол-во времени в секундах, отведённое на задержку перед отправкой HUD-сообщения (по умолчанию 0.5)
const Float:WARMUP_HEALTH = 65.0; // кол-во ед. здоровья, устанавливаемое игроку при спауне во время разминки (по умолчанию 35.0)
const HW_CROSS_AMMO_WPNLIST = (1<<0);
const HW_TIMER = (1<<4);
const HW_MONEY = (1<<5);

new const KILL_SOUNDS[][] = {
    "misc/sheep.wav", "misc/killChicken.wav", "misc/cow.wav"
};

enum {
    WS_WAITING = 1,
    WS_BEGIN,
    WS_IN_PROGRESS,
    WS_ENDED
}

new HamHook:g_pHamSpawn, HamHook:g_pHamAddPlayerItem, HamHook:g_pHamGiveAmmo, HamHook:g_pHamUse, HamHook:g_pHamKilled;

#if defined _roundcontrol_included
new RoundControlHook:g_pCheckWinHook;
#else
new g_pRoundInfinite, g_szRoundInfinite[10];
#endif

new g_pRestartRound, g_pHideWeaponMsgId, g_pStatusIconMsgId, g_pHudSyncObj1, g_pHudSyncObj2, g_pThinkEnt, g_iConnectedBitsum, g_iAliveBitsum, g_iMessageBitsum, g_iFrags[MAX_PLAYERS + 1],
    g_iWarmupState = WS_WAITING, g_pHideWeapon, g_iTimerCount;

public plugin_precache() {
    for(new i; i < sizeof KILL_SOUNDS; i++) {
        precache_sound(KILL_SOUNDS[i]);
    }
    precache_sound(g_szSound);
}

public plugin_init() {
    register_plugin("Knife warmup", "0.1", "Subb98");
    register_clcmd("joinclass", "CmdJoinClass");
    const JOIN_CLASS_MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5;
    register_menucmd(register_menuid("Terrorist_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_menucmd(register_menuid("CT_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_event("HLTV", "EventHLTV", "a", "1=0", "2=0");
    register_logevent("EventGameCommencing", 2, "1=Game_Commencing");
    register_logevent("EventRoundStart", 2, "1=Round_Start");
    register_logevent("EventRoundEnd", 2, "1=Round_End");
    new const ENT_CLASSNAME[] = "player";
    DisableHamForward(g_pHamSpawn = RegisterHam(Ham_Spawn, ENT_CLASSNAME, "HamSpawnPlayerPost", 1));
    DisableHamForward(g_pHamAddPlayerItem = RegisterHam(Ham_AddPlayerItem, ENT_CLASSNAME, "HamAddPlayerItemPre"));
    DisableHamForward(g_pHamGiveAmmo = RegisterHam(Ham_GiveAmmo, ENT_CLASSNAME, "HamGiveAmmoPre"));
    DisableHamForward(g_pHamUse = RegisterHam(Ham_Use, "hostage_entity", "HamUseHostagePre"));
    DisableHamForward(g_pHamKilled = RegisterHam(Ham_Killed, ENT_CLASSNAME, "HamKilledPlayerPost", 1));
    #if !defined _roundcontrol_included
    g_pRoundInfinite = get_cvar_pointer("mp_round_infinite");
    #endif
    g_pRestartRound = get_cvar_pointer("sv_restartround");
    g_pHideWeaponMsgId = get_user_msgid("HideWeapon");
    g_pStatusIconMsgId = get_user_msgid("StatusIcon");
    g_pHudSyncObj1 = CreateHudSyncObj();
    g_pHudSyncObj2 = CreateHudSyncObj();
    CreateThinkEntity();
}

#if !defined _roundcontrol_included
public plugin_cfg() {
    if(g_pRoundInfinite) {
        get_pcvar_string(g_pRoundInfinite, g_szRoundInfinite, charsmax(g_szRoundInfinite));
    }
}
#endif

public client_putinserver(id) {
    ResetValues(id);
    if(!is_user_bot(id) && !is_user_hltv(id)) {
        bit_set(id, g_iConnectedBitsum);
    }
}

public client_disconnected(id) {
    ResetValues(id);
    remove_task(id);
}

public CmdJoinClass(const id) {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        set_task(RESPAWN_DELAY, "TaskRespawn", id);
    }
}

public EventHLTV() {
    switch(g_iWarmupState) {
        case WS_BEGIN: {
            g_iWarmupState = WS_IN_PROGRESS;
            g_iMessageBitsum = 0;
            EnableHamForward(g_pHamSpawn);
            EnableHamForward(g_pHamAddPlayerItem);
            EnableHamForward(g_pHamGiveAmmo);
            EnableHamForward(g_pHamUse);
            EnableHamForward(g_pHamKilled);
            server_cmd("sv_gravity 350");
            g_pHideWeapon = register_message(g_pHideWeaponMsgId, "MessageHideWeapon");
            #if defined _roundcontrol_included
            g_pCheckWinHook = SetBlockControl(RC_CheckWinConditions);
            #else
            if(g_pRoundInfinite) {
                set_pcvar_num(g_pRoundInfinite, 1);
            }
            #endif
            set_msg_block(g_pStatusIconMsgId, BLOCK_SET);
        }
        case WS_ENDED: {
            entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + SHOW_MSG_DELAY);
        }
    }
}

public EventGameCommencing() {
    if(g_iWarmupState == WS_WAITING) {
        g_iWarmupState = WS_BEGIN;
    }
}

public EventRoundStart() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + 1.0);
    }
}

public EventRoundEnd() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        g_iWarmupState = WS_ENDED;
        DisableHamForward(g_pHamSpawn);
        DisableHamForward(g_pHamAddPlayerItem);
        DisableHamForward(g_pHamGiveAmmo);
        DisableHamForward(g_pHamUse);
        DisableHamForward(g_pHamKilled);
        server_cmd("sv_gravity 850");
        client_cmd(0, "spk sound/%s", g_szSound);
        unregister_message(g_pHideWeaponMsgId, g_pHideWeapon);
        #if defined _roundcontrol_included
        RemoveBlockControl(RC_CheckWinConditions, g_pCheckWinHook);
        #else
        if(g_pRoundInfinite) {
            set_pcvar_string(g_pRoundInfinite, g_szRoundInfinite);
        }
        #endif
        set_msg_block(g_pStatusIconMsgId, BLOCK_NOT);
        set_pcvar_float(g_pRestartRound, 1.0);
    }
}

public MessageHideWeapon() {
    const ARG_FLAGS = 1;
    set_msg_arg_int(ARG_FLAGS, ARG_BYTE, get_msg_arg_int(ARG_FLAGS) | HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
}

public HamSpawnPlayerPost(const id) {
    if(is_user_alive(id)) {
        bit_set(id, g_iAliveBitsum);
        if(!bit_valid(id, g_iMessageBitsum)) {
            set_task(SHOW_MSG_DELAY, "TaskWarmupStartMsg", id);
        }
        entity_set_float(id, EV_FL_health, WARMUP_HEALTH);
        engclient_cmd(id, "weapon_knife");
        message_begin(MSG_ONE, g_pHideWeaponMsgId, _, id);
        write_byte(HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
        message_end();
    }
}

public HamAddPlayerItemPre(const id, const pEnt) {
    if(cs_get_weapon_id(pEnt) != CSW_KNIFE) {
        entity_set_int(pEnt, EV_INT_flags, entity_get_int(pEnt, EV_INT_flags ) | FL_KILLME);
        SetHamReturnInteger(0);
        return HAM_SUPERCEDE;
    }
    return HAM_IGNORED;
}

public HamGiveAmmoPre() {
    const NO_AMMO_STOP_PROCESSING = -1;
    SetHamReturnInteger(NO_AMMO_STOP_PROCESSING);
    return HAM_SUPERCEDE;
}

public HamUseHostagePre() {
    return HAM_SUPERCEDE;
}

public HamKilledPlayerPost(const id, const pKiller) {
    bit_clear(id, g_iAliveBitsum);
    if(bit_valid(pKiller, g_iAliveBitsum)) {
        if(g_iFrags[pKiller] == sizeof KILL_SOUNDS) {
            g_iFrags[pKiller] = 0;
        }
        emit_sound(pKiller, CHAN_VOICE, KILL_SOUNDS[g_iFrags[pKiller]], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
        g_iFrags[pKiller]++;
    }
    set_task(RESPAWN_DELAY, "TaskRespawn", id);
}

public FwdThink(const pEnt) {
    switch(g_iWarmupState) {
        case WS_IN_PROGRESS: {
            static iDiff, iMin;
            iDiff = WARMUP_TIME - g_iTimerCount++, iMin = 0;
            GetMinutes(iDiff, iMin);
            set_hudmessage(255, 255, 255, _, 0.96, _, _, 1.0, 0.0, 0.01, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj1, "Iki warmup pabaigos: %d:%d", iMin, iDiff);
            if(iDiff || iMin) {
                entity_set_float(pEnt, EV_FL_nextthink, get_gametime() + 1.0);
            } else {
                EventRoundEnd();
            }
        }
        case WS_ENDED: {
            g_iWarmupState = WS_WAITING;
            g_iTimerCount = 0;
            set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj2, "Žaidimas prasideda!^nGL HF!");
            #if defined USE_PAUSE
            pause("d");
            #endif
        }
    }
}

public TaskRespawn(const id) {
    if(bit_valid(id, g_iConnectedBitsum) && !bit_valid(id, g_iAliveBitsum) && cs_get_user_team(id) != CS_TEAM_SPECTATOR) {
        ExecuteHamB(Ham_CS_RoundRespawn, id);
    }
}

public TaskWarmupStartMsg(const id) {
    if(bit_valid(id, g_iAliveBitsum)) {
        set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
        ShowSyncHudMsg(id, g_pHudSyncObj2, "Pasiruošk!^n[WARMUP] - Prasideda!");
        bit_set(id, g_iMessageBitsum);
    }
}

CreateThinkEntity() {
    new const ENT_CLASSNAME[] = "_warmup_think_ent";
    if((g_pThinkEnt = create_entity("info_target"))) {
        entity_set_string(g_pThinkEnt, EV_SZ_classname, ENT_CLASSNAME);
        register_think(ENT_CLASSNAME, "FwdThink");
    } else {
        set_fail_state("Failed to create think entity");
    }
}

ResetValues(const id) {
    bit_clear(id, g_iConnectedBitsum);
    bit_clear(id, g_iAliveBitsum);
    bit_clear(id, g_iMessageBitsum);
    g_iFrags[id] = 0;
}

GetMinutes(&iSec, &iMin) {
    const SECONDS_IN_MINUTE = 60;
    iMin = iSec / SECONDS_IN_MINUTE, iSec %= SECONDS_IN_MINUTE;
}
Musamuhamed, читайте внимательнее, пожалуйста
Спасибо большое ;)
 

Portugal

Пользователь
Регистрация
2 Мар 2018
Сообщения
257
Симпатии
5
Предупреждения
60
Пол
Мужской
Portugal, держи
Код:
/* ===============================================================================
* Knife warmup 0.1 [28.03.2016]
* Благодарности:
* - Sanlerus: реализация отлова выбора класса
* - s1lent: реализация и возможность использования 'Regamedll_CS', 'RoundControl'
* - Safety1st: способы реализации некоторых функций из 'Uncommon Knife Warmup'
* ============================================================================ */

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <hamsandwich>
//#include <roundcontrol> // раскомментируйте эту строку, если на сервере не используется Regamedll_CS

static const g_szSound[] = "wrsnz/wrsnz.wav";

#pragma semicolon 1

#define bit_set(%0,%1) (%1 |= (1<<%0))
#define bit_clear(%0,%1) (%1 &= ~(1<<%0))
#define bit_valid(%0,%1) (%1 & (1<<%0))
#define USE_PAUSE // раскомментируйте эту строку, если желаете, чтобы плагин прекратил работу после выполнения задачи

#if AMXX_VERSION_NUM < 183
const MAX_PLAYERS = 30; // максимальное кол-во игроков на сервере, заменить своим (по умолчанию 32)
#endif
const WARMUP_TIME = 70; // кол-во времени в секундах, отведённое на разминку (по умолчанию 90)
const Float:RESPAWN_DELAY = 0.75; // кол-во времени в секундах, отведённое на задержку перед респауном (по умолчанию 0.75)
const Float:SHOW_MSG_DELAY = 0.8; // кол-во времени в секундах, отведённое на задержку перед отправкой HUD-сообщения (по умолчанию 0.5)
const Float:WARMUP_HEALTH = 65.0; // кол-во ед. здоровья, устанавливаемое игроку при спауне во время разминки (по умолчанию 35.0)
const HW_CROSS_AMMO_WPNLIST = (1<<0);
const HW_TIMER = (1<<4);
const HW_MONEY = (1<<5);

new const KILL_SOUNDS[][] = {
    "misc/sheep.wav", "misc/killChicken.wav", "misc/cow.wav"
};

enum {
    WS_WAITING = 1,
    WS_BEGIN,
    WS_IN_PROGRESS,
    WS_ENDED
}

new HamHook:g_pHamSpawn, HamHook:g_pHamAddPlayerItem, HamHook:g_pHamGiveAmmo, HamHook:g_pHamUse, HamHook:g_pHamKilled;

#if defined _roundcontrol_included
new RoundControlHook:g_pCheckWinHook;
#else
new g_pRoundInfinite, g_szRoundInfinite[10];
#endif

new g_pRestartRound, g_pHideWeaponMsgId, g_pStatusIconMsgId, g_pHudSyncObj1, g_pHudSyncObj2, g_pThinkEnt, g_iConnectedBitsum, g_iAliveBitsum, g_iMessageBitsum, g_iFrags[MAX_PLAYERS + 1],
    g_iWarmupState = WS_WAITING, g_pHideWeapon, g_iTimerCount;

public plugin_precache() {
    for(new i; i < sizeof KILL_SOUNDS; i++) {
        precache_sound(KILL_SOUNDS[i]);
    }
    precache_sound(g_szSound);
}

public plugin_init() {
    register_plugin("Knife warmup", "0.1", "Subb98");
    register_clcmd("joinclass", "CmdJoinClass");
    const JOIN_CLASS_MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5;
    register_menucmd(register_menuid("Terrorist_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_menucmd(register_menuid("CT_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_event("HLTV", "EventHLTV", "a", "1=0", "2=0");
    register_logevent("EventGameCommencing", 2, "1=Game_Commencing");
    register_logevent("EventRoundStart", 2, "1=Round_Start");
    register_logevent("EventRoundEnd", 2, "1=Round_End");
    new const ENT_CLASSNAME[] = "player";
    DisableHamForward(g_pHamSpawn = RegisterHam(Ham_Spawn, ENT_CLASSNAME, "HamSpawnPlayerPost", 1));
    DisableHamForward(g_pHamAddPlayerItem = RegisterHam(Ham_AddPlayerItem, ENT_CLASSNAME, "HamAddPlayerItemPre"));
    DisableHamForward(g_pHamGiveAmmo = RegisterHam(Ham_GiveAmmo, ENT_CLASSNAME, "HamGiveAmmoPre"));
    DisableHamForward(g_pHamUse = RegisterHam(Ham_Use, "hostage_entity", "HamUseHostagePre"));
    DisableHamForward(g_pHamKilled = RegisterHam(Ham_Killed, ENT_CLASSNAME, "HamKilledPlayerPost", 1));
    #if !defined _roundcontrol_included
    g_pRoundInfinite = get_cvar_pointer("mp_round_infinite");
    #endif
    g_pRestartRound = get_cvar_pointer("sv_restartround");
    g_pHideWeaponMsgId = get_user_msgid("HideWeapon");
    g_pStatusIconMsgId = get_user_msgid("StatusIcon");
    g_pHudSyncObj1 = CreateHudSyncObj();
    g_pHudSyncObj2 = CreateHudSyncObj();
    CreateThinkEntity();
}

#if !defined _roundcontrol_included
public plugin_cfg() {
    if(g_pRoundInfinite) {
        get_pcvar_string(g_pRoundInfinite, g_szRoundInfinite, charsmax(g_szRoundInfinite));
    }
}
#endif

public client_putinserver(id) {
    ResetValues(id);
    if(!is_user_bot(id) && !is_user_hltv(id)) {
        bit_set(id, g_iConnectedBitsum);
    }
}

public client_disconnected(id) {
    ResetValues(id);
    remove_task(id);
}

public CmdJoinClass(const id) {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        set_task(RESPAWN_DELAY, "TaskRespawn", id);
    }
}

public EventHLTV() {
    switch(g_iWarmupState) {
        case WS_BEGIN: {
            g_iWarmupState = WS_IN_PROGRESS;
            g_iMessageBitsum = 0;
            EnableHamForward(g_pHamSpawn);
            EnableHamForward(g_pHamAddPlayerItem);
            EnableHamForward(g_pHamGiveAmmo);
            EnableHamForward(g_pHamUse);
            EnableHamForward(g_pHamKilled);
            server_cmd("sv_gravity 350");
            g_pHideWeapon = register_message(g_pHideWeaponMsgId, "MessageHideWeapon");
            #if defined _roundcontrol_included
            g_pCheckWinHook = SetBlockControl(RC_CheckWinConditions);
            #else
            if(g_pRoundInfinite) {
                set_pcvar_num(g_pRoundInfinite, 1);
            }
            #endif
            set_msg_block(g_pStatusIconMsgId, BLOCK_SET);
        }
        case WS_ENDED: {
            entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + SHOW_MSG_DELAY);
        }
    }
}

public EventGameCommencing() {
    if(g_iWarmupState == WS_WAITING) {
        g_iWarmupState = WS_BEGIN;
    }
}

public EventRoundStart() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + 1.0);
    }
}

public EventRoundEnd() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        g_iWarmupState = WS_ENDED;
        DisableHamForward(g_pHamSpawn);
        DisableHamForward(g_pHamAddPlayerItem);
        DisableHamForward(g_pHamGiveAmmo);
        DisableHamForward(g_pHamUse);
        DisableHamForward(g_pHamKilled);
        server_cmd("sv_gravity 850");
        client_cmd(0, "spk sound/%s", g_szSound);
        unregister_message(g_pHideWeaponMsgId, g_pHideWeapon);
        #if defined _roundcontrol_included
        RemoveBlockControl(RC_CheckWinConditions, g_pCheckWinHook);
        #else
        if(g_pRoundInfinite) {
            set_pcvar_string(g_pRoundInfinite, g_szRoundInfinite);
        }
        #endif
        set_msg_block(g_pStatusIconMsgId, BLOCK_NOT);
        set_pcvar_float(g_pRestartRound, 1.0);
    }
}

public MessageHideWeapon() {
    const ARG_FLAGS = 1;
    set_msg_arg_int(ARG_FLAGS, ARG_BYTE, get_msg_arg_int(ARG_FLAGS) | HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
}

public HamSpawnPlayerPost(const id) {
    if(is_user_alive(id)) {
        bit_set(id, g_iAliveBitsum);
        if(!bit_valid(id, g_iMessageBitsum)) {
            set_task(SHOW_MSG_DELAY, "TaskWarmupStartMsg", id);
        }
        entity_set_float(id, EV_FL_health, WARMUP_HEALTH);
        engclient_cmd(id, "weapon_knife");
        message_begin(MSG_ONE, g_pHideWeaponMsgId, _, id);
        write_byte(HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
        message_end();
    }
}

public HamAddPlayerItemPre(const id, const pEnt) {
    if(cs_get_weapon_id(pEnt) != CSW_KNIFE) {
        entity_set_int(pEnt, EV_INT_flags, entity_get_int(pEnt, EV_INT_flags ) | FL_KILLME);
        SetHamReturnInteger(0);
        return HAM_SUPERCEDE;
    }
    return HAM_IGNORED;
}

public HamGiveAmmoPre() {
    const NO_AMMO_STOP_PROCESSING = -1;
    SetHamReturnInteger(NO_AMMO_STOP_PROCESSING);
    return HAM_SUPERCEDE;
}

public HamUseHostagePre() {
    return HAM_SUPERCEDE;
}

public HamKilledPlayerPost(const id, const pKiller) {
    bit_clear(id, g_iAliveBitsum);
    if(bit_valid(pKiller, g_iAliveBitsum)) {
        if(g_iFrags[pKiller] == sizeof KILL_SOUNDS) {
            g_iFrags[pKiller] = 0;
        }
        emit_sound(pKiller, CHAN_VOICE, KILL_SOUNDS[g_iFrags[pKiller]], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
        g_iFrags[pKiller]++;
    }
    set_task(RESPAWN_DELAY, "TaskRespawn", id);
}

public FwdThink(const pEnt) {
    switch(g_iWarmupState) {
        case WS_IN_PROGRESS: {
            static iDiff, iMin;
            iDiff = WARMUP_TIME - g_iTimerCount++, iMin = 0;
            GetMinutes(iDiff, iMin);
            set_hudmessage(255, 255, 255, _, 0.96, _, _, 1.0, 0.0, 0.01, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj1, "Iki warmup pabaigos: %d:%d", iMin, iDiff);
            if(iDiff || iMin) {
                entity_set_float(pEnt, EV_FL_nextthink, get_gametime() + 1.0);
            } else {
                EventRoundEnd();
            }
        }
        case WS_ENDED: {
            g_iWarmupState = WS_WAITING;
            g_iTimerCount = 0;
            set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj2, "Žaidimas prasideda!^nGL HF!");
            #if defined USE_PAUSE
            pause("d");
            #endif
        }
    }
}

public TaskRespawn(const id) {
    if(bit_valid(id, g_iConnectedBitsum) && !bit_valid(id, g_iAliveBitsum) && cs_get_user_team(id) != CS_TEAM_SPECTATOR) {
        ExecuteHamB(Ham_CS_RoundRespawn, id);
    }
}

public TaskWarmupStartMsg(const id) {
    if(bit_valid(id, g_iAliveBitsum)) {
        set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
        ShowSyncHudMsg(id, g_pHudSyncObj2, "Pasiruošk!^n[WARMUP] - Prasideda!");
        bit_set(id, g_iMessageBitsum);
    }
}

CreateThinkEntity() {
    new const ENT_CLASSNAME[] = "_warmup_think_ent";
    if((g_pThinkEnt = create_entity("info_target"))) {
        entity_set_string(g_pThinkEnt, EV_SZ_classname, ENT_CLASSNAME);
        register_think(ENT_CLASSNAME, "FwdThink");
    } else {
        set_fail_state("Failed to create think entity");
    }
}

ResetValues(const id) {
    bit_clear(id, g_iConnectedBitsum);
    bit_clear(id, g_iAliveBitsum);
    bit_clear(id, g_iMessageBitsum);
    g_iFrags[id] = 0;
}

GetMinutes(&iSec, &iMin) {
    const SECONDS_IN_MINUTE = 60;
    iMin = iSec / SECONDS_IN_MINUTE, iSec %= SECONDS_IN_MINUTE;
}
Musamuhamed, читайте внимательнее, пожалуйста
Проверил работает гравити и звук слушай чекни почему тока один звук звучит а не один из 3 ;)


Код:
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <hamsandwich>
//#include <roundcontrol> // раскомментируйте эту строку, если на сервере не используется Regamedll_CS

static const g_szSound[] = "wrsnz/wrmzs1.wav";

#pragma semicolon 1

#define bit_set(%0,%1) (%1 |= (1<<%0))
#define bit_clear(%0,%1) (%1 &= ~(1<<%0))
#define bit_valid(%0,%1) (%1 & (1<<%0))
#define USE_PAUSE // раскомментируйте эту строку, если желаете, чтобы плагин прекратил работу после выполнения задачи

#if AMXX_VERSION_NUM < 183
const MAX_PLAYERS = 30; // максимальное кол-во игроков на сервере, заменить своим (по умолчанию 32)
#endif
const WARMUP_TIME = 70; // кол-во времени в секундах, отведённое на разминку (по умолчанию 90)
const Float:RESPAWN_DELAY = 0.75; // кол-во времени в секундах, отведённое на задержку перед респауном (по умолчанию 0.75)
const Float:SHOW_MSG_DELAY = 0.8; // кол-во времени в секундах, отведённое на задержку перед отправкой HUD-сообщения (по умолчанию 0.5)
const Float:WARMUP_HEALTH = 65.0; // кол-во ед. здоровья, устанавливаемое игроку при спауне во время разминки (по умолчанию 35.0)
const HW_CROSS_AMMO_WPNLIST = (1<<0);
const HW_TIMER = (1<<4);
const HW_MONEY = (1<<5);

new const KILL_SOUNDS[][] = {
    "wrsnz/wrmzs1.wav", "wrsnz/wrmzs2.wav", "wrsnz/wrmzs3.wav"
};

enum {
    WS_WAITING = 1,
    WS_BEGIN,
    WS_IN_PROGRESS,
    WS_ENDED
}

new HamHook:g_pHamSpawn, HamHook:g_pHamAddPlayerItem, HamHook:g_pHamGiveAmmo, HamHook:g_pHamUse, HamHook:g_pHamKilled;

#if defined _roundcontrol_included
new RoundControlHook:g_pCheckWinHook;
#else
new g_pRoundInfinite, g_szRoundInfinite[10];
#endif

new g_pRestartRound, g_pHideWeaponMsgId, g_pStatusIconMsgId, g_pHudSyncObj1, g_pHudSyncObj2, g_pThinkEnt, g_iConnectedBitsum, g_iAliveBitsum, g_iMessageBitsum, g_iFrags[MAX_PLAYERS + 1],
    g_iWarmupState = WS_WAITING, g_pHideWeapon, g_iTimerCount;

public plugin_precache() {
    for(new i; i < sizeof KILL_SOUNDS; i++) {
        precache_sound(KILL_SOUNDS[i]);
    }
    precache_sound(g_szSound);
}

public plugin_init() {
    register_plugin("Knife warmup", "0.1", "Subb98");
    register_clcmd("joinclass", "CmdJoinClass");
    const JOIN_CLASS_MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5;
    register_menucmd(register_menuid("Terrorist_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_menucmd(register_menuid("CT_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_event("HLTV", "EventHLTV", "a", "1=0", "2=0");
    register_logevent("EventGameCommencing", 2, "1=Game_Commencing");
    register_logevent("EventRoundStart", 2, "1=Round_Start");
    register_logevent("EventRoundEnd", 2, "1=Round_End");
    new const ENT_CLASSNAME[] = "player";
    DisableHamForward(g_pHamSpawn = RegisterHam(Ham_Spawn, ENT_CLASSNAME, "HamSpawnPlayerPost", 1));
    DisableHamForward(g_pHamAddPlayerItem = RegisterHam(Ham_AddPlayerItem, ENT_CLASSNAME, "HamAddPlayerItemPre"));
    DisableHamForward(g_pHamGiveAmmo = RegisterHam(Ham_GiveAmmo, ENT_CLASSNAME, "HamGiveAmmoPre"));
    DisableHamForward(g_pHamUse = RegisterHam(Ham_Use, "hostage_entity", "HamUseHostagePre"));
    DisableHamForward(g_pHamKilled = RegisterHam(Ham_Killed, ENT_CLASSNAME, "HamKilledPlayerPost", 1));
    #if !defined _roundcontrol_included
    g_pRoundInfinite = get_cvar_pointer("mp_round_infinite");
    #endif
    g_pRestartRound = get_cvar_pointer("sv_restartround");
    g_pHideWeaponMsgId = get_user_msgid("HideWeapon");
    g_pStatusIconMsgId = get_user_msgid("StatusIcon");
    g_pHudSyncObj1 = CreateHudSyncObj();
    g_pHudSyncObj2 = CreateHudSyncObj();
    CreateThinkEntity();
}

#if !defined _roundcontrol_included
public plugin_cfg() {
    if(g_pRoundInfinite) {
        get_pcvar_string(g_pRoundInfinite, g_szRoundInfinite, charsmax(g_szRoundInfinite));
    }
}
#endif

public client_putinserver(id) {
    ResetValues(id);
    if(!is_user_bot(id) && !is_user_hltv(id)) {
        bit_set(id, g_iConnectedBitsum);
    }
}

public client_disconnected(id) {
    ResetValues(id);
    remove_task(id);
}

public CmdJoinClass(const id) {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        set_task(RESPAWN_DELAY, "TaskRespawn", id);
    }
}

public EventHLTV() {
    switch(g_iWarmupState) {
        case WS_BEGIN: {
            g_iWarmupState = WS_IN_PROGRESS;
            g_iMessageBitsum = 0;
            EnableHamForward(g_pHamSpawn);
            EnableHamForward(g_pHamAddPlayerItem);
            EnableHamForward(g_pHamGiveAmmo);
            EnableHamForward(g_pHamUse);
            EnableHamForward(g_pHamKilled);
            server_cmd("sv_gravity 350");
            g_pHideWeapon = register_message(g_pHideWeaponMsgId, "MessageHideWeapon");
            #if defined _roundcontrol_included
            g_pCheckWinHook = SetBlockControl(RC_CheckWinConditions);
            #else
            if(g_pRoundInfinite) {
                set_pcvar_num(g_pRoundInfinite, 1);
            }
            #endif
            set_msg_block(g_pStatusIconMsgId, BLOCK_SET);
        }
        case WS_ENDED: {
            entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + SHOW_MSG_DELAY);
        }
    }
}

public EventGameCommencing() {
    if(g_iWarmupState == WS_WAITING) {
        g_iWarmupState = WS_BEGIN;
    }
}

public EventRoundStart() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + 1.0);
    }
}

public EventRoundEnd() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        g_iWarmupState = WS_ENDED;
        DisableHamForward(g_pHamSpawn);
        DisableHamForward(g_pHamAddPlayerItem);
        DisableHamForward(g_pHamGiveAmmo);
        DisableHamForward(g_pHamUse);
        DisableHamForward(g_pHamKilled);
        server_cmd("sv_gravity 850");
        client_cmd(0, "spk sound/%s", g_szSound);
        unregister_message(g_pHideWeaponMsgId, g_pHideWeapon);
        #if defined _roundcontrol_included
        RemoveBlockControl(RC_CheckWinConditions, g_pCheckWinHook);
        #else
        if(g_pRoundInfinite) {
            set_pcvar_string(g_pRoundInfinite, g_szRoundInfinite);
        }
        #endif
        set_msg_block(g_pStatusIconMsgId, BLOCK_NOT);
        set_pcvar_float(g_pRestartRound, 1.0);
    }
}

public MessageHideWeapon() {
    const ARG_FLAGS = 1;
    set_msg_arg_int(ARG_FLAGS, ARG_BYTE, get_msg_arg_int(ARG_FLAGS) | HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
}

public HamSpawnPlayerPost(const id) {
    if(is_user_alive(id)) {
        bit_set(id, g_iAliveBitsum);
        if(!bit_valid(id, g_iMessageBitsum)) {
            set_task(SHOW_MSG_DELAY, "TaskWarmupStartMsg", id);
        }
        entity_set_float(id, EV_FL_health, WARMUP_HEALTH);
        engclient_cmd(id, "weapon_knife");
        message_begin(MSG_ONE, g_pHideWeaponMsgId, _, id);
        write_byte(HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
        message_end();
    }
}

public HamAddPlayerItemPre(const id, const pEnt) {
    if(cs_get_weapon_id(pEnt) != CSW_KNIFE) {
        entity_set_int(pEnt, EV_INT_flags, entity_get_int(pEnt, EV_INT_flags ) | FL_KILLME);
        SetHamReturnInteger(0);
        return HAM_SUPERCEDE;
    }
    return HAM_IGNORED;
}

public HamGiveAmmoPre() {
    const NO_AMMO_STOP_PROCESSING = -1;
    SetHamReturnInteger(NO_AMMO_STOP_PROCESSING);
    return HAM_SUPERCEDE;
}

public HamUseHostagePre() {
    return HAM_SUPERCEDE;
}

public HamKilledPlayerPost(const id, const pKiller) {
    bit_clear(id, g_iAliveBitsum);
    if(bit_valid(pKiller, g_iAliveBitsum)) {
        if(g_iFrags[pKiller] == sizeof KILL_SOUNDS) {
            g_iFrags[pKiller] = 0;
        }
        emit_sound(pKiller, CHAN_VOICE, KILL_SOUNDS[g_iFrags[pKiller]], VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
        g_iFrags[pKiller]++;
    }
    set_task(RESPAWN_DELAY, "TaskRespawn", id);
}

public FwdThink(const pEnt) {
    switch(g_iWarmupState) {
        case WS_IN_PROGRESS: {
            static iDiff, iMin;
            iDiff = WARMUP_TIME - g_iTimerCount++, iMin = 0;
            GetMinutes(iDiff, iMin);
            set_hudmessage(255, 255, 255, _, 0.96, _, _, 1.0, 0.0, 0.01, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj1, "Iki warmup pabaigos: %d:%d", iMin, iDiff);
            if(iDiff || iMin) {
                entity_set_float(pEnt, EV_FL_nextthink, get_gametime() + 1.0);
            } else {
                EventRoundEnd();
            }
        }
        case WS_ENDED: {
            g_iWarmupState = WS_WAITING;
            g_iTimerCount = 0;
            set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj2, "Žaidimas prasideda!^nGL HF!");
            #if defined USE_PAUSE
            pause("d");
            #endif
        }
    }
}

public TaskRespawn(const id) {
    if(bit_valid(id, g_iConnectedBitsum) && !bit_valid(id, g_iAliveBitsum) && cs_get_user_team(id) != CS_TEAM_SPECTATOR) {
        ExecuteHamB(Ham_CS_RoundRespawn, id);
    }
}

public TaskWarmupStartMsg(const id) {
    if(bit_valid(id, g_iAliveBitsum)) {
        set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
        ShowSyncHudMsg(id, g_pHudSyncObj2, "Pasiruošk!^n[WARMUP] - Prasideda!");
        bit_set(id, g_iMessageBitsum);
    }
}

CreateThinkEntity() {
    new const ENT_CLASSNAME[] = "_warmup_think_ent";
    if((g_pThinkEnt = create_entity("info_target"))) {
        entity_set_string(g_pThinkEnt, EV_SZ_classname, ENT_CLASSNAME);
        register_think(ENT_CLASSNAME, "FwdThink");
    } else {
        set_fail_state("Failed to create think entity");
    }
}

ResetValues(const id) {
    bit_clear(id, g_iConnectedBitsum);
    bit_clear(id, g_iAliveBitsum);
    bit_clear(id, g_iMessageBitsum);
    g_iFrags[id] = 0;
}

GetMinutes(&iSec, &iMin) {
    const SECONDS_IN_MINUTE = 60;
    iMin = iSec / SECONDS_IN_MINUTE, iSec %= SECONDS_IN_MINUTE;
}
 

To be or not to be

Пользователь
Регистрация
9 Июн 2017
Сообщения
1.215
Симпатии
304
Portugal, у вас звук должен быть из const KILL_SOUNDS ? (то есть, те звуки, которые при убийстве воспроизводятся)
 

Portugal

Пользователь
Регистрация
2 Мар 2018
Сообщения
257
Симпатии
5
Предупреждения
60
Пол
Мужской
"[DOUBLEPOST=1527014963][/DOUBLEPOST]
Portugal, у вас звук должен быть из const KILL_SOUNDS ? (то есть, те звуки, которые при убийстве воспроизводятся)
Не друг мне при убийстве не нужно )) мне нужно чтоб в конце разминки то есть warmup прозвучал звук один из тех 3 то есть рандомно ) а сейчяс только один звучик вот этот "wrsnz/wrmzs1.wav" :)
 

To be or not to be

Пользователь
Регистрация
9 Июн 2017
Сообщения
1.215
Симпатии
304
Portugal, держи
Код:
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <hamsandwich>
//#include <roundcontrol> // раскомментируйте эту строку, если на сервере не используется Regamedll_CS

#pragma semicolon 1

#define bit_set(%0,%1) (%1 |= (1<<%0))
#define bit_clear(%0,%1) (%1 &= ~(1<<%0))
#define bit_valid(%0,%1) (%1 & (1<<%0))
#define USE_PAUSE // раскомментируйте эту строку, если желаете, чтобы плагин прекратил работу после выполнения задачи

#if AMXX_VERSION_NUM < 183
const MAX_PLAYERS = 30; // максимальное кол-во игроков на сервере, заменить своим (по умолчанию 32)
#endif
const WARMUP_TIME = 70; // кол-во времени в секундах, отведённое на разминку (по умолчанию 90)
const Float:RESPAWN_DELAY = 0.75; // кол-во времени в секундах, отведённое на задержку перед респауном (по умолчанию 0.75)
const Float:SHOW_MSG_DELAY = 0.8; // кол-во времени в секундах, отведённое на задержку перед отправкой HUD-сообщения (по умолчанию 0.5)
const Float:WARMUP_HEALTH = 65.0; // кол-во ед. здоровья, устанавливаемое игроку при спауне во время разминки (по умолчанию 35.0)
const HW_CROSS_AMMO_WPNLIST = (1<<0);
const HW_TIMER = (1<<4);
const HW_MONEY = (1<<5);

new const szSound[][] = {
    "wrsnz/wrmzs1.wav", "wrsnz/wrmzs2.wav", "wrsnz/wrmzs3.wav"
};

enum {
    WS_WAITING = 1,
    WS_BEGIN,
    WS_IN_PROGRESS,
    WS_ENDED
}

new HamHook:g_pHamSpawn, HamHook:g_pHamAddPlayerItem, HamHook:g_pHamGiveAmmo, HamHook:g_pHamUse, HamHook:g_pHamKilled;

#if defined _roundcontrol_included
new RoundControlHook:g_pCheckWinHook;
#else
new g_pRoundInfinite, g_szRoundInfinite[10];
#endif

new g_pRestartRound, g_pHideWeaponMsgId, g_pStatusIconMsgId, g_pHudSyncObj1, g_pHudSyncObj2, g_pThinkEnt, g_iConnectedBitsum, g_iAliveBitsum, g_iMessageBitsum, g_iFrags[MAX_PLAYERS + 1],
    g_iWarmupState = WS_WAITING, g_pHideWeapon, g_iTimerCount;

public plugin_precache() {
    for(new i; i < sizeof szSound; i++) {
        precache_sound(szSound[i]);
    }
}

public plugin_init() {
    register_plugin("Knife warmup", "0.1", "Subb98");
    register_clcmd("joinclass", "CmdJoinClass");
    const JOIN_CLASS_MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5;
    register_menucmd(register_menuid("Terrorist_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_menucmd(register_menuid("CT_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_event("HLTV", "EventHLTV", "a", "1=0", "2=0");
    register_logevent("EventGameCommencing", 2, "1=Game_Commencing");
    register_logevent("EventRoundStart", 2, "1=Round_Start");
    register_logevent("EventRoundEnd", 2, "1=Round_End");
    new const ENT_CLASSNAME[] = "player";
    DisableHamForward(g_pHamSpawn = RegisterHam(Ham_Spawn, ENT_CLASSNAME, "HamSpawnPlayerPost", 1));
    DisableHamForward(g_pHamAddPlayerItem = RegisterHam(Ham_AddPlayerItem, ENT_CLASSNAME, "HamAddPlayerItemPre"));
    DisableHamForward(g_pHamGiveAmmo = RegisterHam(Ham_GiveAmmo, ENT_CLASSNAME, "HamGiveAmmoPre"));
    DisableHamForward(g_pHamUse = RegisterHam(Ham_Use, "hostage_entity", "HamUseHostagePre"));
    DisableHamForward(g_pHamKilled = RegisterHam(Ham_Killed, ENT_CLASSNAME, "HamKilledPlayerPost", 1));
    #if !defined _roundcontrol_included
    g_pRoundInfinite = get_cvar_pointer("mp_round_infinite");
    #endif
    g_pRestartRound = get_cvar_pointer("sv_restartround");
    g_pHideWeaponMsgId = get_user_msgid("HideWeapon");
    g_pStatusIconMsgId = get_user_msgid("StatusIcon");
    g_pHudSyncObj1 = CreateHudSyncObj();
    g_pHudSyncObj2 = CreateHudSyncObj();
    CreateThinkEntity();
}

#if !defined _roundcontrol_included
public plugin_cfg() {
    if(g_pRoundInfinite) {
        get_pcvar_string(g_pRoundInfinite, g_szRoundInfinite, charsmax(g_szRoundInfinite));
    }
}
#endif

public client_putinserver(id) {
    ResetValues(id);
    if(!is_user_bot(id) && !is_user_hltv(id)) {
        bit_set(id, g_iConnectedBitsum);
    }
}

public client_disconnected(id) {
    ResetValues(id);
    remove_task(id);
}

public CmdJoinClass(const id) {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        set_task(RESPAWN_DELAY, "TaskRespawn", id);
    }
}

public EventHLTV() {
    switch(g_iWarmupState) {
        case WS_BEGIN: {
            g_iWarmupState = WS_IN_PROGRESS;
            g_iMessageBitsum = 0;
            EnableHamForward(g_pHamSpawn);
            EnableHamForward(g_pHamAddPlayerItem);
            EnableHamForward(g_pHamGiveAmmo);
            EnableHamForward(g_pHamUse);
            EnableHamForward(g_pHamKilled);
            server_cmd("sv_gravity 350");
            g_pHideWeapon = register_message(g_pHideWeaponMsgId, "MessageHideWeapon");
            #if defined _roundcontrol_included
            g_pCheckWinHook = SetBlockControl(RC_CheckWinConditions);
            #else
            if(g_pRoundInfinite) {
                set_pcvar_num(g_pRoundInfinite, 1);
            }
            #endif
            set_msg_block(g_pStatusIconMsgId, BLOCK_SET);
        }
        case WS_ENDED: {
            entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + SHOW_MSG_DELAY);
        }
    }
}

public EventGameCommencing() {
    if(g_iWarmupState == WS_WAITING) {
        g_iWarmupState = WS_BEGIN;
    }
}

public EventRoundStart() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + 1.0);
    }
}

public EventRoundEnd() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        g_iWarmupState = WS_ENDED;
        DisableHamForward(g_pHamSpawn);
        DisableHamForward(g_pHamAddPlayerItem);
        DisableHamForward(g_pHamGiveAmmo);
        DisableHamForward(g_pHamUse);
        DisableHamForward(g_pHamKilled);
        server_cmd("sv_gravity 850");
        client_cmd(0, "spk sound/%s", szSound[random_num(0, sizeof szSound)]);
        unregister_message(g_pHideWeaponMsgId, g_pHideWeapon);
        #if defined _roundcontrol_included
        RemoveBlockControl(RC_CheckWinConditions, g_pCheckWinHook);
        #else
        if(g_pRoundInfinite) {
            set_pcvar_string(g_pRoundInfinite, g_szRoundInfinite);
        }
        #endif
        set_msg_block(g_pStatusIconMsgId, BLOCK_NOT);
        set_pcvar_float(g_pRestartRound, 1.0);
    }
}

public MessageHideWeapon() {
    const ARG_FLAGS = 1;
    set_msg_arg_int(ARG_FLAGS, ARG_BYTE, get_msg_arg_int(ARG_FLAGS) | HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
}

public HamSpawnPlayerPost(const id) {
    if(is_user_alive(id)) {
        bit_set(id, g_iAliveBitsum);
        if(!bit_valid(id, g_iMessageBitsum)) {
            set_task(SHOW_MSG_DELAY, "TaskWarmupStartMsg", id);
        }
        entity_set_float(id, EV_FL_health, WARMUP_HEALTH);
        engclient_cmd(id, "weapon_knife");
        message_begin(MSG_ONE, g_pHideWeaponMsgId, _, id);
        write_byte(HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
        message_end();
    }
}

public HamAddPlayerItemPre(const id, const pEnt) {
    if(cs_get_weapon_id(pEnt) != CSW_KNIFE) {
        entity_set_int(pEnt, EV_INT_flags, entity_get_int(pEnt, EV_INT_flags ) | FL_KILLME);
        SetHamReturnInteger(0);
        return HAM_SUPERCEDE;
    }
    return HAM_IGNORED;
}

public HamGiveAmmoPre() {
    const NO_AMMO_STOP_PROCESSING = -1;
    SetHamReturnInteger(NO_AMMO_STOP_PROCESSING);
    return HAM_SUPERCEDE;
}

public HamUseHostagePre() {
    return HAM_SUPERCEDE;
}

public HamKilledPlayerPost(const id, const pKiller) {
    bit_clear(id, g_iAliveBitsum);
    set_task(RESPAWN_DELAY, "TaskRespawn", id);
}

public FwdThink(const pEnt) {
    switch(g_iWarmupState) {
        case WS_IN_PROGRESS: {
            static iDiff, iMin;
            iDiff = WARMUP_TIME - g_iTimerCount++, iMin = 0;
            GetMinutes(iDiff, iMin);
            set_hudmessage(255, 255, 255, _, 0.96, _, _, 1.0, 0.0, 0.01, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj1, "Iki warmup pabaigos: %d:%d", iMin, iDiff);
            if(iDiff || iMin) {
                entity_set_float(pEnt, EV_FL_nextthink, get_gametime() + 1.0);
            } else {
                EventRoundEnd();
            }
        }
        case WS_ENDED: {
            g_iWarmupState = WS_WAITING;
            g_iTimerCount = 0;
            set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj2, "Žaidimas prasideda!^nGL HF!");
            #if defined USE_PAUSE
            pause("d");
            #endif
        }
    }
}

public TaskRespawn(const id) {
    if(bit_valid(id, g_iConnectedBitsum) && !bit_valid(id, g_iAliveBitsum) && cs_get_user_team(id) != CS_TEAM_SPECTATOR) {
        ExecuteHamB(Ham_CS_RoundRespawn, id);
    }
}

public TaskWarmupStartMsg(const id) {
    if(bit_valid(id, g_iAliveBitsum)) {
        set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
        ShowSyncHudMsg(id, g_pHudSyncObj2, "Pasiruošk!^n[WARMUP] - Prasideda!");
        bit_set(id, g_iMessageBitsum);
    }
}

CreateThinkEntity() {
    new const ENT_CLASSNAME[] = "_warmup_think_ent";
    if((g_pThinkEnt = create_entity("info_target"))) {
        entity_set_string(g_pThinkEnt, EV_SZ_classname, ENT_CLASSNAME);
        register_think(ENT_CLASSNAME, "FwdThink");
    } else {
        set_fail_state("Failed to create think entity");
    }
}

ResetValues(const id) {
    bit_clear(id, g_iConnectedBitsum);
    bit_clear(id, g_iAliveBitsum);
    bit_clear(id, g_iMessageBitsum);
    g_iFrags[id] = 0;
}

GetMinutes(&iSec, &iMin) {
    const SECONDS_IN_MINUTE = 60;
    iMin = iSec / SECONDS_IN_MINUTE, iSec %= SECONDS_IN_MINUTE;
}
 

Portugal

Пользователь
Регистрация
2 Мар 2018
Сообщения
257
Симпатии
5
Предупреждения
60
Пол
Мужской
Portugal, держи
Код:
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <hamsandwich>
//#include <roundcontrol> // раскомментируйте эту строку, если на сервере не используется Regamedll_CS

#pragma semicolon 1

#define bit_set(%0,%1) (%1 |= (1<<%0))
#define bit_clear(%0,%1) (%1 &= ~(1<<%0))
#define bit_valid(%0,%1) (%1 & (1<<%0))
#define USE_PAUSE // раскомментируйте эту строку, если желаете, чтобы плагин прекратил работу после выполнения задачи

#if AMXX_VERSION_NUM < 183
const MAX_PLAYERS = 30; // максимальное кол-во игроков на сервере, заменить своим (по умолчанию 32)
#endif
const WARMUP_TIME = 70; // кол-во времени в секундах, отведённое на разминку (по умолчанию 90)
const Float:RESPAWN_DELAY = 0.75; // кол-во времени в секундах, отведённое на задержку перед респауном (по умолчанию 0.75)
const Float:SHOW_MSG_DELAY = 0.8; // кол-во времени в секундах, отведённое на задержку перед отправкой HUD-сообщения (по умолчанию 0.5)
const Float:WARMUP_HEALTH = 65.0; // кол-во ед. здоровья, устанавливаемое игроку при спауне во время разминки (по умолчанию 35.0)
const HW_CROSS_AMMO_WPNLIST = (1<<0);
const HW_TIMER = (1<<4);
const HW_MONEY = (1<<5);

new const szSound[][] = {
    "wrsnz/wrmzs1.wav", "wrsnz/wrmzs2.wav", "wrsnz/wrmzs3.wav"
};

enum {
    WS_WAITING = 1,
    WS_BEGIN,
    WS_IN_PROGRESS,
    WS_ENDED
}

new HamHook:g_pHamSpawn, HamHook:g_pHamAddPlayerItem, HamHook:g_pHamGiveAmmo, HamHook:g_pHamUse, HamHook:g_pHamKilled;

#if defined _roundcontrol_included
new RoundControlHook:g_pCheckWinHook;
#else
new g_pRoundInfinite, g_szRoundInfinite[10];
#endif

new g_pRestartRound, g_pHideWeaponMsgId, g_pStatusIconMsgId, g_pHudSyncObj1, g_pHudSyncObj2, g_pThinkEnt, g_iConnectedBitsum, g_iAliveBitsum, g_iMessageBitsum, g_iFrags[MAX_PLAYERS + 1],
    g_iWarmupState = WS_WAITING, g_pHideWeapon, g_iTimerCount;

public plugin_precache() {
    for(new i; i < sizeof szSound; i++) {
        precache_sound(szSound[i]);
    }
}

public plugin_init() {
    register_plugin("Knife warmup", "0.1", "Subb98");
    register_clcmd("joinclass", "CmdJoinClass");
    const JOIN_CLASS_MENU_KEYS = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5;
    register_menucmd(register_menuid("Terrorist_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_menucmd(register_menuid("CT_Select"), JOIN_CLASS_MENU_KEYS, "CmdJoinClass");
    register_event("HLTV", "EventHLTV", "a", "1=0", "2=0");
    register_logevent("EventGameCommencing", 2, "1=Game_Commencing");
    register_logevent("EventRoundStart", 2, "1=Round_Start");
    register_logevent("EventRoundEnd", 2, "1=Round_End");
    new const ENT_CLASSNAME[] = "player";
    DisableHamForward(g_pHamSpawn = RegisterHam(Ham_Spawn, ENT_CLASSNAME, "HamSpawnPlayerPost", 1));
    DisableHamForward(g_pHamAddPlayerItem = RegisterHam(Ham_AddPlayerItem, ENT_CLASSNAME, "HamAddPlayerItemPre"));
    DisableHamForward(g_pHamGiveAmmo = RegisterHam(Ham_GiveAmmo, ENT_CLASSNAME, "HamGiveAmmoPre"));
    DisableHamForward(g_pHamUse = RegisterHam(Ham_Use, "hostage_entity", "HamUseHostagePre"));
    DisableHamForward(g_pHamKilled = RegisterHam(Ham_Killed, ENT_CLASSNAME, "HamKilledPlayerPost", 1));
    #if !defined _roundcontrol_included
    g_pRoundInfinite = get_cvar_pointer("mp_round_infinite");
    #endif
    g_pRestartRound = get_cvar_pointer("sv_restartround");
    g_pHideWeaponMsgId = get_user_msgid("HideWeapon");
    g_pStatusIconMsgId = get_user_msgid("StatusIcon");
    g_pHudSyncObj1 = CreateHudSyncObj();
    g_pHudSyncObj2 = CreateHudSyncObj();
    CreateThinkEntity();
}

#if !defined _roundcontrol_included
public plugin_cfg() {
    if(g_pRoundInfinite) {
        get_pcvar_string(g_pRoundInfinite, g_szRoundInfinite, charsmax(g_szRoundInfinite));
    }
}
#endif

public client_putinserver(id) {
    ResetValues(id);
    if(!is_user_bot(id) && !is_user_hltv(id)) {
        bit_set(id, g_iConnectedBitsum);
    }
}

public client_disconnected(id) {
    ResetValues(id);
    remove_task(id);
}

public CmdJoinClass(const id) {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        set_task(RESPAWN_DELAY, "TaskRespawn", id);
    }
}

public EventHLTV() {
    switch(g_iWarmupState) {
        case WS_BEGIN: {
            g_iWarmupState = WS_IN_PROGRESS;
            g_iMessageBitsum = 0;
            EnableHamForward(g_pHamSpawn);
            EnableHamForward(g_pHamAddPlayerItem);
            EnableHamForward(g_pHamGiveAmmo);
            EnableHamForward(g_pHamUse);
            EnableHamForward(g_pHamKilled);
            server_cmd("sv_gravity 350");
            g_pHideWeapon = register_message(g_pHideWeaponMsgId, "MessageHideWeapon");
            #if defined _roundcontrol_included
            g_pCheckWinHook = SetBlockControl(RC_CheckWinConditions);
            #else
            if(g_pRoundInfinite) {
                set_pcvar_num(g_pRoundInfinite, 1);
            }
            #endif
            set_msg_block(g_pStatusIconMsgId, BLOCK_SET);
        }
        case WS_ENDED: {
            entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + SHOW_MSG_DELAY);
        }
    }
}

public EventGameCommencing() {
    if(g_iWarmupState == WS_WAITING) {
        g_iWarmupState = WS_BEGIN;
    }
}

public EventRoundStart() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        entity_set_float(g_pThinkEnt, EV_FL_nextthink, get_gametime() + 1.0);
    }
}

public EventRoundEnd() {
    if(g_iWarmupState == WS_IN_PROGRESS) {
        g_iWarmupState = WS_ENDED;
        DisableHamForward(g_pHamSpawn);
        DisableHamForward(g_pHamAddPlayerItem);
        DisableHamForward(g_pHamGiveAmmo);
        DisableHamForward(g_pHamUse);
        DisableHamForward(g_pHamKilled);
        server_cmd("sv_gravity 850");
        client_cmd(0, "spk sound/%s", szSound[random_num(0, sizeof szSound)]);
        unregister_message(g_pHideWeaponMsgId, g_pHideWeapon);
        #if defined _roundcontrol_included
        RemoveBlockControl(RC_CheckWinConditions, g_pCheckWinHook);
        #else
        if(g_pRoundInfinite) {
            set_pcvar_string(g_pRoundInfinite, g_szRoundInfinite);
        }
        #endif
        set_msg_block(g_pStatusIconMsgId, BLOCK_NOT);
        set_pcvar_float(g_pRestartRound, 1.0);
    }
}

public MessageHideWeapon() {
    const ARG_FLAGS = 1;
    set_msg_arg_int(ARG_FLAGS, ARG_BYTE, get_msg_arg_int(ARG_FLAGS) | HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
}

public HamSpawnPlayerPost(const id) {
    if(is_user_alive(id)) {
        bit_set(id, g_iAliveBitsum);
        if(!bit_valid(id, g_iMessageBitsum)) {
            set_task(SHOW_MSG_DELAY, "TaskWarmupStartMsg", id);
        }
        entity_set_float(id, EV_FL_health, WARMUP_HEALTH);
        engclient_cmd(id, "weapon_knife");
        message_begin(MSG_ONE, g_pHideWeaponMsgId, _, id);
        write_byte(HW_CROSS_AMMO_WPNLIST | HW_TIMER | HW_MONEY);
        message_end();
    }
}

public HamAddPlayerItemPre(const id, const pEnt) {
    if(cs_get_weapon_id(pEnt) != CSW_KNIFE) {
        entity_set_int(pEnt, EV_INT_flags, entity_get_int(pEnt, EV_INT_flags ) | FL_KILLME);
        SetHamReturnInteger(0);
        return HAM_SUPERCEDE;
    }
    return HAM_IGNORED;
}

public HamGiveAmmoPre() {
    const NO_AMMO_STOP_PROCESSING = -1;
    SetHamReturnInteger(NO_AMMO_STOP_PROCESSING);
    return HAM_SUPERCEDE;
}

public HamUseHostagePre() {
    return HAM_SUPERCEDE;
}

public HamKilledPlayerPost(const id, const pKiller) {
    bit_clear(id, g_iAliveBitsum);
    set_task(RESPAWN_DELAY, "TaskRespawn", id);
}

public FwdThink(const pEnt) {
    switch(g_iWarmupState) {
        case WS_IN_PROGRESS: {
            static iDiff, iMin;
            iDiff = WARMUP_TIME - g_iTimerCount++, iMin = 0;
            GetMinutes(iDiff, iMin);
            set_hudmessage(255, 255, 255, _, 0.96, _, _, 1.0, 0.0, 0.01, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj1, "Iki warmup pabaigos: %d:%d", iMin, iDiff);
            if(iDiff || iMin) {
                entity_set_float(pEnt, EV_FL_nextthink, get_gametime() + 1.0);
            } else {
                EventRoundEnd();
            }
        }
        case WS_ENDED: {
            g_iWarmupState = WS_WAITING;
            g_iTimerCount = 0;
            set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
            ShowSyncHudMsg(0, g_pHudSyncObj2, "Žaidimas prasideda!^nGL HF!");
            #if defined USE_PAUSE
            pause("d");
            #endif
        }
    }
}

public TaskRespawn(const id) {
    if(bit_valid(id, g_iConnectedBitsum) && !bit_valid(id, g_iAliveBitsum) && cs_get_user_team(id) != CS_TEAM_SPECTATOR) {
        ExecuteHamB(Ham_CS_RoundRespawn, id);
    }
}

public TaskWarmupStartMsg(const id) {
    if(bit_valid(id, g_iAliveBitsum)) {
        set_hudmessage(255, 255, 255, _, 0.25, _, _, 5.0, _, _, -1);
        ShowSyncHudMsg(id, g_pHudSyncObj2, "Pasiruošk!^n[WARMUP] - Prasideda!");
        bit_set(id, g_iMessageBitsum);
    }
}

CreateThinkEntity() {
    new const ENT_CLASSNAME[] = "_warmup_think_ent";
    if((g_pThinkEnt = create_entity("info_target"))) {
        entity_set_string(g_pThinkEnt, EV_SZ_classname, ENT_CLASSNAME);
        register_think(ENT_CLASSNAME, "FwdThink");
    } else {
        set_fail_state("Failed to create think entity");
    }
}

ResetValues(const id) {
    bit_clear(id, g_iConnectedBitsum);
    bit_clear(id, g_iAliveBitsum);
    bit_clear(id, g_iMessageBitsum);
    g_iFrags[id] = 0;
}

GetMinutes(&iSec, &iMin) {
    const SECONDS_IN_MINUTE = 60;
    iMin = iSec / SECONDS_IN_MINUTE, iSec %= SECONDS_IN_MINUTE;
}
Работает спасибо за то что всё сделал за меня :)))
 

Portugal

Пользователь
Регистрация
2 Мар 2018
Сообщения
257
Симпатии
5
Предупреждения
60
Пол
Мужской
Работает спасибо за то что всё сделал за меня :)))
Слушай что нужно вписать чтобы этот плагин не работал на разминке :)?


Код:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Dead Messages"
#define VERSION "2.0"
#define AUTHOR "maFFyoZZyk"

#define m_bitsDamageType 76

#define DMG_GRENADE (1<<24)

new const g_szSounds[][] =
{
    "ghzwtf/msfkzsuic",
    "ghzwtf/msfkknfz",
    "ghzwtf/msfkgrndz"
};

public plugin_precache()
{
    new sPathSound[128];
    
    for(new i = 0; i < sizeof(g_szSounds); i++)
    {
        format(sPathSound, charsmax(sPathSound), "%s.wav", g_szSounds[i]);
        precache_sound(sPathSound);
    }
}

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);
    
    RegisterHam(Ham_Killed, "player", "fw_KilledPlayerPost", true);
    
    new sMapName[32], sMapPrefix[][] = {"1hp", "35hp", "aim", "awp", "he_"};
    get_mapname(sMapName, charsmax(sMapName));
    
    for(new i; i < sizeof sMapPrefix; i++)
    {
        if(containi(sMapName, sMapPrefix[i]) != -1)
            pause("ad");
    }
}

public fw_KilledPlayerPost(iVictim, iAttacker, iCorpse)
{
    if(!is_user_connected(iVictim) || !is_user_connected(iAttacker))
        return;
    
    new iRed = random_num(0, 255);
    new iGreen = random_num(0, 255);
    new iBlue = random_num(0, 255);
    
    if(iVictim == iAttacker)
    {
        set_hudmessage(iRed, iGreen, iBlue, -1.0, 0.85, 0, 0.1, 5.0, 0.1, 0.1, -1);
        show_hudmessage(0, "А вот и новый суицидник подъехал");

        client_cmd(0,"spk %s", g_szSounds[0]);
        
        return;
    }
    
    if(get_user_weapon(iAttacker) == CSW_KNIFE && pev(iVictim, pev_dmg_inflictor) == iAttacker)
    {
        set_hudmessage(iRed, iGreen, iBlue, -1.0, 0.85, 0, 0.1, 5.0, 0.1, 0.1, -1);
        show_hudmessage(0, "Ну вот, достойная смерть для свиньи.");

        client_cmd(0,"spk %s", g_szSounds[1]);
        
        return;
    }
    
    if(get_pdata_int(iVictim, m_bitsDamageType) & DMG_GRENADE)
    {
        set_hudmessage(iRed, iGreen, iBlue, -1.0, 0.85, 0, 0.1, 5.0, 0.1, 0.1, -1);
        show_hudmessage(0, "Ну вот, достойная смерть для дебила.");

        client_cmd(0,"spk %s", g_szSounds[2]);   
    }
}
 
Сверху Снизу