Skip to content

Commit

Permalink
v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
WessTorn committed Nov 27, 2023
1 parent 3061beb commit cf930b6
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 72 deletions.
14 changes: 14 additions & 0 deletions configs/hns_mode.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; hns_deathmatch 0 ; Дезматч мод 1 Включить / 0 Отключить​ (раскомментировать если отключен плагин hns_lash_grenade)
hns_respawn 3 ; Кол-во секунд возрождения игроков в режиме ДМ​
hns_he 0 ; Кол-во HE гранат у команды ТТ​
hns_flash 2 ; Кол-во Flash гранат у команды ТТ​
hns_smoke 1 ; Кол-во Smoke гранат у команды ТТ​
hns_last_he ; Кол-во HE гранат у команды ТТ​ (Когда ТТ остается последним)
hns_last_flash ; Кол-во Flash гранат у команды ТТ​ (Когда ТТ остается последним)
hns_last_smoke ; Кол-во Smoke гранат у команды ТТ​ (Когда ТТ остается последним)
hns_swap_team 2 ; Кол-во выигранных раундов подряд команды ТТ после которого поменять команды местами​
hns_swist 1 ; Свист (+USE) у команды ТТ 1 Включить / 0 Отключить​
hns_prefix HNS ; Префикс сообщений в чате​
hns_ownage_delay 5.0 ; Через сколько секунд засчитывать ownage
hns_start_night 23 ; Во сколько включать ночной дезматч
hns_end_night 9 ; Во сколько отключить ночной дезматч
6 changes: 6 additions & 0 deletions data/lang/hidenseek.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ KNIFE_HIDE = Hide knife
KNIFE_CT = Hide for \yCT \r%s
KNIFE_TT = Hide for \yTT \r%s

NIGHT_START = [^3%s^1] The night deathmatch has been activated.
NIGHT_STOP = [^3%s^1] The night deathmatch has been stopped.

ROUNDINFO_ON = [^3%s^1] Round info is now ^3enabled.
ROUNDINFO_OFF = [^3%s^1] Round info is now ^3disabled.

Expand Down Expand Up @@ -48,6 +51,9 @@ KNIFE_HIDE = Спрятать нож
KNIFE_CT = Спрятать у \yКТ \r%s
KNIFE_TT = Спрятать у \yТТ \r%s

NIGHT_START = [^3%s^1] Активирован ночной дезматч.
NIGHT_STOP = [^3%s^1] Ночной дезматч остановлен.

ROUNDINFO_ON = [^3%s^1] Информация о раунде ^3включена.
ROUNDINFO_OFF = [^3%s^1] Информация о раунде ^3выключена.

Expand Down
8 changes: 3 additions & 5 deletions hns_hideknife.sma
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#include <amxmodx>
#include <hamsandwich>
#include <reapi>
#include <hns_mode_main>

new bool: g_playerHideKnife[MAX_PLAYERS + 1][TeamName];

public plugin_init() {
register_plugin("HNS: Hideknife", "1.0.0", "OpenHNS"); // ufame (https://github.com/ufame/brohns/blob/master/server/src/scripts/hns/hns_hideknife.sma)
register_plugin("HNS: Hideknife", "1.0.0", "ufame, OpenHNS"); // ufame (https://github.com/ufame/brohns/blob/master/server/src/scripts/hns/hns_hideknife.sma)

register_clcmd("say /hideknife", "commandHideKnife");
register_clcmd("say_team /hideknife", "commandHideKnife");
register_clcmd("say /knife", "commandHideKnife");
register_clcmd("say_team /knife", "commandHideKnife");
RegisterSayCmd("hideknife", "knife", "commandHideKnife", 0, "Show knife");

RegisterHam(Ham_Item_Deploy, "weapon_knife", "knifeDeploy", 1);

Expand Down
16 changes: 13 additions & 3 deletions hns_lash_grenade.sma
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
#include <reapi>
#include <hns_mode_main>

#define rg_get_user_team(%0) get_member(%0, m_iTeam)
enum HNS_CVAR {
c_iLastHe,
c_iLastFlash,
c_iLastSmoke,
};

new g_pCvar[HNS_CVAR];

new bool:g_bLastFlash;

Expand All @@ -11,6 +17,10 @@ new g_szPrefix[24];
public plugin_init() {
register_plugin("HNS Last grenade", "1.0.0", "OpenHNS");

bind_pcvar_num(register_cvar("hns_last_he", "0"), g_pCvar[c_iLastHe]);
bind_pcvar_num(register_cvar("hns_last_flash", "1"), g_pCvar[c_iLastFlash]);
bind_pcvar_num(register_cvar("hns_last_smoke", "1"), g_pCvar[c_iLastSmoke]);

RegisterHookChain(RG_CSGameRules_RestartRound, "rgRoundStart", true);
RegisterHookChain(RG_CBasePlayer_Killed, "rgPlayerKilled", true);

Expand All @@ -26,7 +36,7 @@ public rgRoundStart() {
}

public rgPlayerKilled(victim, attacker) {
if (is_deathmatch() || rg_get_user_team(victim) != TEAM_TERRORIST || g_bLastFlash)
if (hns_get_mode() != MODE_PUBLIC || rg_get_user_team(victim) != TEAM_TERRORIST || g_bLastFlash)
return HC_CONTINUE;

new iPlayers[MAX_PLAYERS], iNum;
Expand Down Expand Up @@ -76,7 +86,7 @@ public NadesHandler(id, hMenu, item) {
rg_give_item(id, "weapon_smokegrenade");
}

client_print_color(0, print_team_blue, "%L", 0, "LAST_SET", g_szPrefix, id);
client_print_color(0, print_team_blue, "%L", LANG_PLAYER, "LAST_SET", g_szPrefix, id);
}

g_bLastFlash = false;
Expand Down
101 changes: 60 additions & 41 deletions hns_main.sma
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

#define rg_get_user_team(%0) get_member(%0, m_iTeam)

new bool:g_isDeathMatch;
enum _:HNS_MODES {
MODE_PUBLIC = 0,
MODE_DEATHMATCH
}

new g_iCurrentMode;

enum HNS_CVAR {
c_iDeathMatch,
Expand Down Expand Up @@ -46,7 +51,7 @@ enum _: Forwards_s {
new g_hForwards[Forwards_s];

public plugin_init() {
register_plugin("HNS Mode Main", "1.0.3", "OpenHNS");
register_plugin("HNS Mode Main", "1.0.4", "OpenHNS");

register_clcmd("chooseteam", "BlockCmd");
register_clcmd("jointeam", "BlockCmd");
Expand Down Expand Up @@ -91,6 +96,13 @@ public plugin_init() {
register_dictionary("hidenseek.txt");
}

public plugin_cfg() {
new szPath[PLATFORM_MAX_PATH];
get_localinfo("amxx_configsdir", szPath, charsmax(szPath));
format(szPath, charsmax(szPath), "%s/%s", szPath, "hns_mode.cfg");
server_cmd("exec %s", szPath);
}

public plugin_precache() {
engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "func_buyzone"));

Expand All @@ -108,7 +120,7 @@ public plugin_precache() {
public plugin_natives() {
register_native("hns_get_prefix", "native_get_prefix");

register_native("is_deathmatch", "native_is_deathmatch");
register_native("hns_get_mode", "native_get_mode");
register_native("hns_set_mode", "native_set_mode");
}

Expand All @@ -119,27 +131,31 @@ public native_get_prefix(amxx, params) {
set_string(arg_prefix, g_pCvar[c_szPrefix], get_param(arg_len));
}

public native_is_deathmatch(amxx, params) {
return g_isDeathMatch;
public native_get_mode(amxx, params) {
return g_iCurrentMode;
}

public native_set_mode(amxx, params) {
enum { bool:isDM = false };

hns_set_mode(isDM);
enum { argMode = 1 };
hns_set_mode(get_param(argMode));
}

public delayed_mode() {
set_cvar_string("mp_auto_join_team", "1");
set_cvar_string("mp_forcechasecam", "0");
set_cvar_string("mp_forcecamera", "0");
set_cvar_string("mp_autoteambalance", "2");
set_cvar_string("sv_alltalk", "1");
set_cvar_num("mp_auto_join_team", 1);
set_cvar_num("mp_forcechasecam", 0);
set_cvar_num("mp_forcecamera", 0);
set_cvar_num("mp_autoteambalance", 2);
set_cvar_num("sv_alltalk", 1);
set_cvar_num("mp_buytime", 0);
set_cvar_num("mp_roundover", 2);
set_cvar_num("mp_give_player_c4", 0);
set_cvar_string("mp_t_default_weapons_secondary", "");
set_cvar_string("mp_ct_default_weapons_secondary", "");

if (g_pCvar[c_iDeathMatch]) {
hns_set_mode(true);
hns_set_mode(MODE_DEATHMATCH);
} else {
hns_set_mode(false);
hns_set_mode(MODE_PUBLIC);
}
}

Expand Down Expand Up @@ -170,7 +186,7 @@ public rgPlayerResetMaxSpeed(id) {
public rgPlayerSpawn(id) {
setUserRole(id);

if (g_isDeathMatch)
if (g_iCurrentMode == MODE_DEATHMATCH)
checkBalanceTeams();
}

Expand All @@ -187,31 +203,31 @@ public checkBalanceTeams() {
if (iPlayer) {
rg_set_user_team(iPlayer, TEAM_TERRORIST);
setUserRole(iPlayer);
client_print_color(0, print_team_blue, "%L", 0, "MAIN_TRANSFER_CT", g_pCvar[c_szPrefix], iPlayer);
client_print_color(0, print_team_blue, "%L", LANG_PLAYER, "MAIN_TRANSFER_CT", g_pCvar[c_szPrefix], iPlayer);
}
} else {
new iPlayer = getRandomAlivePlayer(TEAM_TERRORIST);
if (iPlayer) {
rg_set_user_team(iPlayer, TEAM_CT);
setUserRole(iPlayer);

client_print_color(0, print_team_blue, "%L", 0, "MAIN_TRANSFER_TT", g_pCvar[c_szPrefix], iPlayer);
client_print_color(0, print_team_blue, "%L", LANG_PLAYER, "MAIN_TRANSFER_TT", g_pCvar[c_szPrefix], iPlayer);
}
}

return PLUGIN_HANDLED;
}

public rgPlayerKilled(victim, attacker) {
if (!g_isDeathMatch)
if (g_iCurrentMode != MODE_DEATHMATCH)
return HC_CONTINUE;

if (attacker == 0 || !is_user_connected(attacker)) {
if (rg_get_user_team(victim) == TEAM_TERRORIST) {
new iLucky = getRandomAlivePlayer(TEAM_CT);
if (iLucky) {
rg_set_user_team(iLucky, TEAM_TERRORIST);
client_print_color(0, print_team_blue, "%L", 0, "MAIN_TRANSFER_TT", g_pCvar[c_szPrefix], iLucky)
client_print_color(0, print_team_blue, "%L", LANG_PLAYER, "MAIN_TRANSFER_TT", g_pCvar[c_szPrefix], iLucky)
rg_set_user_team(victim, TEAM_CT);
setUserRole(iLucky);
}
Expand Down Expand Up @@ -292,7 +308,7 @@ public rgRoundEnd(WinStatus: status, ScenarioEventEndRound: event, Float:tmDelay

if (g_pCvar[c_iSwapTeams]) {
if (iWinsTT >= g_pCvar[c_iSwapTeams]) {
client_print_color(0, print_team_blue, "%L", 0, "MAIN_SWAP", g_pCvar[c_szPrefix], g_pCvar[c_iSwapTeams]);
client_print_color(0, print_team_blue, "%L", LANG_PLAYER, "MAIN_SWAP", g_pCvar[c_szPrefix], g_pCvar[c_iSwapTeams]);
rg_swap_all_players();
ExecuteForward(g_hForwards[hns_team_swap]);
iWinsTT = 0;
Expand Down Expand Up @@ -336,7 +352,7 @@ public fwdEmitSound(id, iChannel, szSample[], Float:volume, Float:attenuation, f
emit_sound(id, iChannel, g_szUseSound, volume, attenuation, fFlags, pitch);
} else {
emit_sound(id, iChannel, g_szUseSwist, volume, attenuation, fFlags, pitch);
client_print_color(0, print_team_blue, "%L", 0, "MAIN_SWIST", g_pCvar[c_szPrefix], id);
client_print_color(0, print_team_blue, "%L", LANG_PLAYER, "MAIN_SWIST", g_pCvar[c_szPrefix], id);
flNextTime[id] = get_gametime() + 20.0;
}

Expand All @@ -347,14 +363,14 @@ public fwdEmitSound(id, iChannel, szSample[], Float:volume, Float:attenuation, f
}

public fwdClientKill(id) {
if (g_isDeathMatch) {
if (g_iCurrentMode == MODE_DEATHMATCH) {
client_print_color(id, print_team_blue, "%L", id, "MAIN_KILL_NOT", g_pCvar[c_szPrefix]);
return FMRES_SUPERCEDE;
} else if (rg_get_remaining_time() > 60.0) {
client_print_color(id, print_team_blue, "%L", id, "MAIN_KILL_WAIT", g_pCvar[c_szPrefix]);
return FMRES_SUPERCEDE;
} else {
client_print_color(0, print_team_blue, "%L", 0, "MAIN_KILL", g_pCvar[c_szPrefix], id);
client_print_color(0, print_team_blue, "%L", LANG_PLAYER, "MAIN_KILL", g_pCvar[c_szPrefix], id);
}
return FMRES_IGNORED;
}
Expand Down Expand Up @@ -413,27 +429,30 @@ stock Float:rg_get_remaining_time() {
return (float(get_member_game(m_iRoundTimeSecs)) - get_gametime() + Float:get_member_game(m_fRoundStartTimeReal));
}

public hns_set_mode(isDM) {
g_isDeathMatch = isDM ? true : false;
public hns_set_mode(iCurrentMode) {
g_iCurrentMode = iCurrentMode;

switch (g_iCurrentMode) {
case MODE_DEATHMATCH: {
set_cvar_num("mp_freezetime", 0);
set_cvar_num("mp_roundtime", 0);
set_cvar_num("mp_roundrespawn_time", -1);
set_cvar_num("mp_round_infinite", 1);

set_cvar_num("hns_deathmatch", 1); // Переделать
}
case MODE_PUBLIC: {
set_cvar_num("mp_freezetime", 5);
set_cvar_float("mp_roundtime", 2.5);
set_cvar_num("mp_roundrespawn_time", 20);
set_cvar_num("mp_round_infinite", 0);

if (isDM) {
set_cvar_string("mp_freezetime", "0");
set_cvar_string("mp_roundtime", "0");
set_cvar_string("mp_roundrespawn_time", "-1");
set_cvar_string("mp_round_infinite", "1");

set_cvar_string("hns_deathmatch", "1"); // Переделать
} else {
set_cvar_string("mp_freezetime", "5");
set_cvar_string("mp_roundtime", "2.5");
set_cvar_string("mp_roundrespawn_time", "20");
set_cvar_string("mp_round_infinite", "0");


set_cvar_string("hns_deathmatch", "0"); // Переделать
set_cvar_num("hns_deathmatch", 0); // Переделать
}
}

set_cvar_string("sv_restart", "1");
set_cvar_num("sv_restart", 1);
}

stock getRandomAlivePlayer(TeamName:iTeam) {
Expand Down
55 changes: 55 additions & 0 deletions hns_night_mode.sma
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include <amxmodx>
#include <hns_mode_main>

new g_szPrefix[24];

enum HNS_CVAR {
c_iStartNight,
c_iEndNight
};

new g_pCvar[HNS_CVAR];

new bool:g_bNight;

public plugin_init()
{
register_plugin("HNS: Night deathmatch", "1.0", "OpenHNS");

bind_pcvar_num(register_cvar("hns_start_night", "23"), g_pCvar[c_iStartNight]);
bind_pcvar_num(register_cvar("hns_end_night", "9"), g_pCvar[c_iEndNight]);
}

public plugin_cfg() {
if (isNight()) {
set_cvar_num("hns_deathmatch", 1);
g_bNight = true;
} else {
set_cvar_num("hns_deathmatch", 0);
g_bNight = false;
}

hns_get_prefix(g_szPrefix, charsmax(g_szPrefix));
}

public hns_round_start() {
if (isNight() && !g_bNight) {
hns_set_mode(MODE_DEATHMATCH);
client_print_color(0, print_team_blue, "%L", LANG_PLAYER, "NIGHT_START", g_szPrefix);
g_bNight = true;
} else if (!isNight() && g_bNight) {
hns_set_mode(MODE_PUBLIC);
client_print_color(0, print_team_blue, "%L", LANG_PLAYER, "NIGHT_STOP", g_szPrefix);
g_bNight = false;
}
}

public bool:isNight() {
static iNumChas; time(iNumChas);

if (g_pCvar[c_iStartNight] > g_pCvar[c_iEndNight]) {
return (iNumChas >= g_pCvar[c_iStartNight] || iNumChas < g_pCvar[c_iEndNight]) ? true : false;
} else {
return (g_pCvar[c_iStartNight] <= iNumChas < g_pCvar[c_iEndNight]) ? true : false;
}
}
5 changes: 2 additions & 3 deletions hns_ownage.sma
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include <amxmodx>
#include <engine>
#include <reapi>

#define rg_get_user_team(%0) get_member(%0, m_iTeam)
#include <hns_mode_main>

new Float:g_pCvarDelay;

Expand All @@ -16,7 +15,7 @@ new const g_szSound[][] = {
};

public plugin_init() {
register_plugin("HNS Ownage", "1.0", "OpenHNS");
register_plugin("HNS: Ownage", "1.0", "OpenHNS");

bind_pcvar_float(register_cvar("hns_ownage_delay", "5.0"), g_pCvarDelay);

Expand Down
Loading

0 comments on commit cf930b6

Please sign in to comment.