Участник
Пользователь
- Сообщения
- 30
- Реакции
- 6
- Помог
- 1 раз(а)
Доброго времени суток! Я не могу понять как сделать чисто ножевой. Почитал посты, но все же не уверен в себе.. правильно ли я сделал?
#include <amxmodx>
#include <reapi>
#define TIME_RR 60 // Время разминки
#define NUM_RR 1 // Кол-во рестартов
#define LATENCY 1.5 // Задержка между рестартами
#define PROTECTED 2 // Сколько секунд действует защита после возрождения, 0 - отключить (актуально для DM_MODE)
// отключаемо //
#define SOUND // Музыка под час разминки
#define STOP_PLUGS // Отключать плагины на время разминки
#define DM_MODE // Бесконечный респавн на время разминки
#define OFF_RR // Отключать этот плагин на указанных картах
#define BLOCK // Запрет поднятия оружия с земли [по умолчанию выкл.]
//#define STOP_STATS // Отключать запись статистики на время разминки (Работает только с измененным CSStatsX SQL by serfreeman1337) [по умолчанию выкл.]
#if defined SOUND
new const soundRR[] = "sound/rr/RoundStart.mp3"; // Указывать путь и название файла, например sound/serv/music.mp3
#endif
#if defined STOP_STATS
native stats_set_enabled(params_num)
#endif
#if defined STOP_PLUGS
new g_arPlugins[][] = // Указывать название плагинов, например test.amxx
{
"vip_rbs.amxx",
"test2.amxx"
}
#endif
new g_iHudSync;
new g_szWeapon[32];
new g_iWp;
new HookChain:fwd_NewRound,
HookChain:fwd_Spawn,
HookChain:fwd_GiveC4,
#if defined BLOCK
HookChain:fwd_BlockEntity,
#endif
#if defined DM_MODE
HookChain:fwd_Killed;
#endif
const TASK_PROTECTION_ID = 33464;
public plugin_init()
{
register_plugin("[ReAPI] Random Weapons WarmUP", "2.4.4", "neugomon");
RegisterHookChain(RG_RoundEnd, "fwdRoundEnd", true);
DisableHookChain(fwd_NewRound = RegisterHookChain(RG_CSGameRules_CheckMapConditions, "fwdRoundStart", true));
DisableHookChain(fwd_Spawn = RegisterHookChain(RG_CBasePlayer_Spawn, "fwdPlayerSpawnPost", true));
DisableHookChain(fwd_GiveC4 = RegisterHookChain(RG_CSGameRules_GiveC4, "fwdGiveC4", false));
#if defined BLOCK
DisableHookChain(fwd_BlockEntity = RegisterHookChain(RG_CBasePlayer_HasRestrictItem, "fwdHasRestrictItemPre", false));
register_clcmd("drop", "ClCmd_Drop");
#endif
#if defined DM_MODE
DisableHookChain(fwd_Killed = RegisterHookChain(RG_CBasePlayer_Killed, "fwdPlayerKilledPost", true));
g_iHudSync = CreateHudSyncObj();
register_clcmd("joinclass", "clCmdJoinClass");
register_clcmd("menuselect","clCmdJoinClass");
#endif
state warmupOff;
#if defined OFF_RR
new sPref[][] = { "awp_", "aim_", "fy_", "$", "cs_", "35hp" }; // Указывать префиксы карт
new map[32]; get_mapname(map, charsmax(map));
for(new i; i < sizeof sPref; i++)
{
if(containi(map, sPref) != -1)
{
pause("ad");
return;
}
}
#endif
}
#if defined BLOCK
public fwdHasRestrictItemPre() {
SetHookChainReturn(ATYPE_INTEGER, true);
return HC_SUPERCEDE;
}
public ClCmd_Drop() <warmupOff>
return PLUGIN_CONTINUE;
public ClCmd_Drop() <warmupOn>
return PLUGIN_HANDLED;
#endif
public client_putinserver(id)
{
remove_task(id + TASK_PROTECTION_ID)
}
#if defined SOUND
public plugin_precache()
{
precache_generic(soundRR);
}
#endif
public fwdRoundEnd(WinStatus:status, ScenarioEventEndRound:event, Float:tmDelay)
if(event == ROUND_GAME_COMMENCE)
EnableHookChain(fwd_NewRound);
public fwdRoundStart()
{
state warmupOn;
#if defined SOUND
client_cmd(0, "mp3 play ^"%s^"", soundRR);
#endif
DisableHookChain(fwd_NewRound);
EnableHookChain(fwd_Spawn);
EnableHookChain(fwd_GiveC4);
#if defined STOP_STATS
stats_set_enabled(0);
#endif
set_cvar_string("mp_round_infinite", "1");
#if defined BLOCK
EnableHookChain(fwd_BlockEntity);
#endif
#if defined DM_MODE
EnableHookChain(fwd_Killed);
#endif
#if defined STOP_PLUGS
PluginController(1);
#endif
switch((g_iWp = random(1)))
{
case 0: formatex(g_szWeapon, charsmax(g_szWeapon), "Knife");
}
set_task(1.0, "ShowTimer", .flags = "a", .repeat = TIME_RR);
}
#if defined DM_MODE
public clCmdJoinClass(id) <warmupOff>
return;
public clCmdJoinClass(id) <warmupOn>
if(get_member(id, m_iMenu) == Menu_ChooseAppearance)
set_task(0.5, "SpawnPlayer", id);
#endif
public fwdPlayerSpawnPost(const id)
{
if(!is_user_alive(id))
return;
BuyZone_ToogleSolid(SOLID_NOT);
SetProtection(id)
rg_remove_all_items(id);
set_member_game(m_bMapHasBuyZone, true);
switch(g_iWp)
{
case 0:
{
rg_give_item(id, "weapon_knife");
}
}
}
#if defined DM_MODE
public fwdPlayerKilledPost(pVictim)
set_task(1.0, "SpawnPlayer", pVictim);
#endif
public fwdGiveC4()
{
return HC_SUPERCEDE
}
public ShowTimer()
{
static timer = -1;
if(timer == -1) timer = TIME_RR;
switch(--timer)
{
case 0:
{
state warmupOff;
BuyZone_ToogleSolid(SOLID_TRIGGER);
DisableHookChain(fwd_Spawn);
DisableHookChain(fwd_GiveC4);
#if defined STOP_STATS
stats_set_enabled(1);
#endif
set_cvar_string("mp_round_infinite", "0");
#if defined BLOCK
DisableHookChain(fwd_BlockEntity);
#endif
#if defined DM_MODE
DisableHookChain(fwd_Killed);
#endif
#if defined STOP_PLUGS
PluginController(0);
#endif
#if NUM_RR > 1
set_task(LATENCY, "SV_Restart", .flags = "a", .repeat = NUM_RR);
#else
SV_Restart();
#endif
timer = -1;
}
default:
{
#if defined STOP_STATS
set_hudmessage(255, 0, 0, .x = -1.0, .y = 0.05, .holdtime = 0.9, .channel = -1);
show_hudmessage(0, "[Статистика Отключена]");
#endif
set_hudmessage(135, 206, 235, .x = -1.0, .y = 0.08, .holdtime = 0.9, .channel = -1);
ShowSyncHudMsg(0, g_iHudSync, "Разминка на %s!^nРестарт через %d сек", g_szWeapon, timer);
}
}
}
public SV_Restart()
{
set_cvar_num("sv_restart", 1);
set_task(2.0, "End_RR");
}
public End_RR()
{
#if defined STOP_STATS
set_hudmessage(255, 0, 0, .x = -1.0, .y = 0.05, .holdtime = 5.0, .channel = -1);
show_hudmessage(0, "[Статистика Включена]");
#endif
set_hudmessage(135, 206, 235, .x = -1.0, .y = 0.08, .holdtime = 5.0, .channel = -1);
show_hudmessage(0, "Разминка окончена!");
}
#if defined DM_MODE
public SpawnPlayer(id)
{
if(!is_user_connected(id))
return;
if(is_user_alive(id))
return;
switch(get_member(id, m_iTeam))
{
case 1, 2: rg_round_respawn(id);
}
}
#endif
public SetProtection(id)
{
set_entvar(id, var_takedamage, DAMAGE_NO)
switch(get_member(id, m_iTeam))
{
case TEAM_TERRORIST: rg_set_rendering(id, kRenderFxGlowShell, 255, 0, 0, 10);
case TEAM_CT: rg_set_rendering(id, kRenderFxGlowShell, 0, 0, 255, 10);
}
remove_task(TASK_PROTECTION_ID + id)
set_task( PROTECTED.0, "EndProtection", TASK_PROTECTION_ID + id)
}
public EndProtection(TaskID)
{
new id = TaskID - TASK_PROTECTION_ID
if(!is_user_connected(id))
return
set_entvar(id, var_takedamage, DAMAGE_AIM)
rg_set_rendering(id)
}
stock rg_set_rendering(index, fx = kRenderFxNone, r=255, g=255, b=255, amount=16)
{
new Float:RenderColor[3]
RenderColor[0] = float(r)
RenderColor[1] = float(g)
RenderColor[2] = float(b)
set_entvar(index, var_renderfx, fx)
set_entvar(index, var_rendercolor, RenderColor)
set_entvar(index, var_renderamt, float(amount))
}
stock PluginController(stop)
{
for(new i; i < sizeof g_arPlugins; i++)
{
if(stop)pause ("ac", g_arPlugins);
else unpause("ac", g_arPlugins);
}
}
stock BuyZone_ToogleSolid(const solid)
{
new entityIndex = 0;
while ((entityIndex = rg_find_ent_by_class(entityIndex, "func_buyzone")))
set_entvar(entityIndex, var_solid, solid);
}
#include <reapi>
#define TIME_RR 60 // Время разминки
#define NUM_RR 1 // Кол-во рестартов
#define LATENCY 1.5 // Задержка между рестартами
#define PROTECTED 2 // Сколько секунд действует защита после возрождения, 0 - отключить (актуально для DM_MODE)
// отключаемо //
#define SOUND // Музыка под час разминки
#define STOP_PLUGS // Отключать плагины на время разминки
#define DM_MODE // Бесконечный респавн на время разминки
#define OFF_RR // Отключать этот плагин на указанных картах
#define BLOCK // Запрет поднятия оружия с земли [по умолчанию выкл.]
//#define STOP_STATS // Отключать запись статистики на время разминки (Работает только с измененным CSStatsX SQL by serfreeman1337) [по умолчанию выкл.]
#if defined SOUND
new const soundRR[] = "sound/rr/RoundStart.mp3"; // Указывать путь и название файла, например sound/serv/music.mp3
#endif
#if defined STOP_STATS
native stats_set_enabled(params_num)
#endif
#if defined STOP_PLUGS
new g_arPlugins[][] = // Указывать название плагинов, например test.amxx
{
"vip_rbs.amxx",
"test2.amxx"
}
#endif
new g_iHudSync;
new g_szWeapon[32];
new g_iWp;
new HookChain:fwd_NewRound,
HookChain:fwd_Spawn,
HookChain:fwd_GiveC4,
#if defined BLOCK
HookChain:fwd_BlockEntity,
#endif
#if defined DM_MODE
HookChain:fwd_Killed;
#endif
const TASK_PROTECTION_ID = 33464;
public plugin_init()
{
register_plugin("[ReAPI] Random Weapons WarmUP", "2.4.4", "neugomon");
RegisterHookChain(RG_RoundEnd, "fwdRoundEnd", true);
DisableHookChain(fwd_NewRound = RegisterHookChain(RG_CSGameRules_CheckMapConditions, "fwdRoundStart", true));
DisableHookChain(fwd_Spawn = RegisterHookChain(RG_CBasePlayer_Spawn, "fwdPlayerSpawnPost", true));
DisableHookChain(fwd_GiveC4 = RegisterHookChain(RG_CSGameRules_GiveC4, "fwdGiveC4", false));
#if defined BLOCK
DisableHookChain(fwd_BlockEntity = RegisterHookChain(RG_CBasePlayer_HasRestrictItem, "fwdHasRestrictItemPre", false));
register_clcmd("drop", "ClCmd_Drop");
#endif
#if defined DM_MODE
DisableHookChain(fwd_Killed = RegisterHookChain(RG_CBasePlayer_Killed, "fwdPlayerKilledPost", true));
g_iHudSync = CreateHudSyncObj();
register_clcmd("joinclass", "clCmdJoinClass");
register_clcmd("menuselect","clCmdJoinClass");
#endif
state warmupOff;
#if defined OFF_RR
new sPref[][] = { "awp_", "aim_", "fy_", "$", "cs_", "35hp" }; // Указывать префиксы карт
new map[32]; get_mapname(map, charsmax(map));
for(new i; i < sizeof sPref; i++)
{
if(containi(map, sPref) != -1)
{
pause("ad");
return;
}
}
#endif
}
#if defined BLOCK
public fwdHasRestrictItemPre() {
SetHookChainReturn(ATYPE_INTEGER, true);
return HC_SUPERCEDE;
}
public ClCmd_Drop() <warmupOff>
return PLUGIN_CONTINUE;
public ClCmd_Drop() <warmupOn>
return PLUGIN_HANDLED;
#endif
public client_putinserver(id)
{
remove_task(id + TASK_PROTECTION_ID)
}
#if defined SOUND
public plugin_precache()
{
precache_generic(soundRR);
}
#endif
public fwdRoundEnd(WinStatus:status, ScenarioEventEndRound:event, Float:tmDelay)
if(event == ROUND_GAME_COMMENCE)
EnableHookChain(fwd_NewRound);
public fwdRoundStart()
{
state warmupOn;
#if defined SOUND
client_cmd(0, "mp3 play ^"%s^"", soundRR);
#endif
DisableHookChain(fwd_NewRound);
EnableHookChain(fwd_Spawn);
EnableHookChain(fwd_GiveC4);
#if defined STOP_STATS
stats_set_enabled(0);
#endif
set_cvar_string("mp_round_infinite", "1");
#if defined BLOCK
EnableHookChain(fwd_BlockEntity);
#endif
#if defined DM_MODE
EnableHookChain(fwd_Killed);
#endif
#if defined STOP_PLUGS
PluginController(1);
#endif
switch((g_iWp = random(1)))
{
case 0: formatex(g_szWeapon, charsmax(g_szWeapon), "Knife");
}
set_task(1.0, "ShowTimer", .flags = "a", .repeat = TIME_RR);
}
#if defined DM_MODE
public clCmdJoinClass(id) <warmupOff>
return;
public clCmdJoinClass(id) <warmupOn>
if(get_member(id, m_iMenu) == Menu_ChooseAppearance)
set_task(0.5, "SpawnPlayer", id);
#endif
public fwdPlayerSpawnPost(const id)
{
if(!is_user_alive(id))
return;
BuyZone_ToogleSolid(SOLID_NOT);
SetProtection(id)
rg_remove_all_items(id);
set_member_game(m_bMapHasBuyZone, true);
switch(g_iWp)
{
case 0:
{
rg_give_item(id, "weapon_knife");
}
}
}
#if defined DM_MODE
public fwdPlayerKilledPost(pVictim)
set_task(1.0, "SpawnPlayer", pVictim);
#endif
public fwdGiveC4()
{
return HC_SUPERCEDE
}
public ShowTimer()
{
static timer = -1;
if(timer == -1) timer = TIME_RR;
switch(--timer)
{
case 0:
{
state warmupOff;
BuyZone_ToogleSolid(SOLID_TRIGGER);
DisableHookChain(fwd_Spawn);
DisableHookChain(fwd_GiveC4);
#if defined STOP_STATS
stats_set_enabled(1);
#endif
set_cvar_string("mp_round_infinite", "0");
#if defined BLOCK
DisableHookChain(fwd_BlockEntity);
#endif
#if defined DM_MODE
DisableHookChain(fwd_Killed);
#endif
#if defined STOP_PLUGS
PluginController(0);
#endif
#if NUM_RR > 1
set_task(LATENCY, "SV_Restart", .flags = "a", .repeat = NUM_RR);
#else
SV_Restart();
#endif
timer = -1;
}
default:
{
#if defined STOP_STATS
set_hudmessage(255, 0, 0, .x = -1.0, .y = 0.05, .holdtime = 0.9, .channel = -1);
show_hudmessage(0, "[Статистика Отключена]");
#endif
set_hudmessage(135, 206, 235, .x = -1.0, .y = 0.08, .holdtime = 0.9, .channel = -1);
ShowSyncHudMsg(0, g_iHudSync, "Разминка на %s!^nРестарт через %d сек", g_szWeapon, timer);
}
}
}
public SV_Restart()
{
set_cvar_num("sv_restart", 1);
set_task(2.0, "End_RR");
}
public End_RR()
{
#if defined STOP_STATS
set_hudmessage(255, 0, 0, .x = -1.0, .y = 0.05, .holdtime = 5.0, .channel = -1);
show_hudmessage(0, "[Статистика Включена]");
#endif
set_hudmessage(135, 206, 235, .x = -1.0, .y = 0.08, .holdtime = 5.0, .channel = -1);
show_hudmessage(0, "Разминка окончена!");
}
#if defined DM_MODE
public SpawnPlayer(id)
{
if(!is_user_connected(id))
return;
if(is_user_alive(id))
return;
switch(get_member(id, m_iTeam))
{
case 1, 2: rg_round_respawn(id);
}
}
#endif
public SetProtection(id)
{
set_entvar(id, var_takedamage, DAMAGE_NO)
switch(get_member(id, m_iTeam))
{
case TEAM_TERRORIST: rg_set_rendering(id, kRenderFxGlowShell, 255, 0, 0, 10);
case TEAM_CT: rg_set_rendering(id, kRenderFxGlowShell, 0, 0, 255, 10);
}
remove_task(TASK_PROTECTION_ID + id)
set_task( PROTECTED.0, "EndProtection", TASK_PROTECTION_ID + id)
}
public EndProtection(TaskID)
{
new id = TaskID - TASK_PROTECTION_ID
if(!is_user_connected(id))
return
set_entvar(id, var_takedamage, DAMAGE_AIM)
rg_set_rendering(id)
}
stock rg_set_rendering(index, fx = kRenderFxNone, r=255, g=255, b=255, amount=16)
{
new Float:RenderColor[3]
RenderColor[0] = float(r)
RenderColor[1] = float(g)
RenderColor[2] = float(b)
set_entvar(index, var_renderfx, fx)
set_entvar(index, var_rendercolor, RenderColor)
set_entvar(index, var_renderamt, float(amount))
}
stock PluginController(stop)
{
for(new i; i < sizeof g_arPlugins; i++)
{
if(stop)pause ("ac", g_arPlugins);
else unpause("ac", g_arPlugins);
}
}
stock BuyZone_ToogleSolid(const solid)
{
new entityIndex = 0;
while ((entityIndex = rg_find_ent_by_class(entityIndex, "func_buyzone")))
set_entvar(entityIndex, var_solid, solid);
}