#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#define JOIN_PLAYERS // Впускать в игру людей, которые зашли позже
new g_iWarmUP;
new HamHook:Ham_SpawnWarmup, HamHook:Ham_KilledWarmup, HamHook:Ham_TouchWeap;
public plugin_natives() register_native("is_round_warmup", "return_wp_value");
public return_wp_value() return g_iWarmUP;
public plugin_init()
{
register_plugin("WarmUP Knife Round", "1.7", "neygomon");
#if defined JOIN_PLAYERS
register_clcmd("menuselect", "JoinClassHook");
register_clcmd("joinclass", "JoinClassHook");
#endif
register_event("HLTV", "eRoundStart", "a", "1=0", "2=0");
register_event("TextMsg", "eGameCommencing", "a", "2=#Game_Commencing");
}
#if defined JOIN_PLAYERS
public JoinClassHook(id)
{
if(!g_iWarmUP) return;
#define OFF_JOINEDSTATE 121
#define OFF_MENU 205
#define OFF_MENU_CHOOSEAPPEARANCE 3
#define OFF_STATE_PICKINGCLASS 4
if(get_pdata_int(id, OFF_MENU) == OFF_MENU_CHOOSEAPPEARANCE && get_pdata_int(id, OFF_JOINEDSTATE) == OFF_STATE_PICKINGCLASS)
set_task(2.0, "FirstSpawn", id);
}
public FirstSpawn(id) if(!is_user_alive(id)) ExecuteHamB(Ham_Spawn, id);
#endif
public eGameCommencing()
{
g_iWarmUP = 1;
if(!Ham_SpawnWarmup)
{
Ham_SpawnWarmup = RegisterHam(Ham_Spawn, "player", "fwdPlayerSpawnPost", true);
Ham_KilledWarmup= RegisterHam(Ham_Killed, "player", "fwdPlayerKilledPost", true);
Ham_TouchWeap = RegisterHam(Ham_Touch, "weaponbox", "fwdTouchWeaponPre", false);
}
else
{
EnableHamForward(Ham_SpawnWarmup);
EnableHamForward(Ham_KilledWarmup);
EnableHamForward(Ham_TouchWeap);
}
}
public eRoundStart()
{
switch(g_iWarmUP)
{
case 1:
{
ShowHUD();
set_task(5.0, "ShowHUD", 786467, _, _, "b");
g_iWarmUP = 2;
}
case 2:
{
server_cmd("sv_restart 1");
remove_task(786467);
g_iWarmUP = 0;
DisableHamForward(Ham_SpawnWarmup);
DisableHamForward(Ham_KilledWarmup);
DisableHamForward(Ham_TouchWeap);
}
}
}
public fwdPlayerSpawnPost(pClient)
{
if(!is_user_alive(pClient)) return;
switch(get_user_team(pClient))
{
case 1: fm_strip_user_gun(pClient, "weapon_glock18");
case 2: fm_strip_user_gun(pClient, "weapon_usp");
}
set_pev(pClient, pev_health, 35.0);
set_pdata_int(pClient, 115, 0);
HideMoney(pClient);
}
public fwdPlayerKilledPost(pVictim)
set_task(2.0, "SpawnUser", pVictim);
public fwdTouchWeaponPre(id, ent)
return HAM_SUPERCEDE;
public SpawnUser(pClient)
{
if(!is_user_connected(pClient)) return;
switch(get_user_team(pClient))
{
case 1, 2: ExecuteHamB(Ham_CS_RoundRespawn, pClient);
}
}
public ShowHUD()
{
static SyncHUD; if(!SyncHUD) SyncHUD = CreateHudSyncObj();
set_hudmessage(random(255), random(255), random(255), -1.0, 0.12, 0, 0.0, 5.0, 0.0, 0.0, -1);
ShowSyncHudMsg(0, SyncHUD, "Внимание, разминочный раунд!^nРежим: Knife DeathMatch");
}
HideMoney(id)
{
static mHideWeapon; if(!mHideWeapon) mHideWeapon = get_user_msgid("HideWeapon");
message_begin(MSG_ONE, mHideWeapon, .player = id);
write_byte((1<<5));
message_end();
}
stock fm_strip_user_gun(index, const wname[])
{
new ent = -1;
while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", wname)) && pev(ent, pev_owner) != index) {}
if(!ent) return 0;
engclient_cmd(index, "drop", wname);
new ent_box = pev(ent, pev_owner);
if(!ent_box || ent_box == index) return 0;
dllfunc(DLLFunc_Think, ent_box);
return 1;
}