Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Add allow_reset_score setting for misc (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyShorokhov authored Aug 16, 2021
1 parent 654f14a commit 9e83cff
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 4 deletions.
3 changes: 3 additions & 0 deletions cstrike/addons/amxmodx/configs/csdm/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ refill_clip_weapons = 1
; t - timer
hide_hud_flags = "ft"

; Allow reset score for players by chat cmd '/rs'.
allow_reset_score = 1

[protection]
; Number of seconds someone is respawned for.
; 0 = disable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ refill_clip_weapons = 1
; t - timer
hide_hud_flags = "ft"

; Allow reset score for players by chat cmd '/rs'.
allow_reset_score = 1

[protection]
; Number of seconds someone is respawned for.
; 0 = disable
protection_time = 2.0


; Colors of glow shell, leave this in quotes
; The digits are "R G B"
; random value "random"
Expand Down Expand Up @@ -78,7 +80,7 @@ exclude_bomb = 0
; 1 - equip menu ([secondary] & [primary] + [autoitems])
; 2 - randomly weapons ([secondary] & [primary] + [autoitems])
; 3 - free buy (only buying)
equip_mode = 3
equip_mode = 1

; Free buy time in seconds (weapon buy flood protect!)
; 0 - no time limit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ refill_clip_weapons = 1
; t - timer
hide_hud_flags = "ft"

; Allow reset score for players by chat cmd '/rs'.
allow_reset_score = 1

[protection]
; Number of seconds someone is respawned for.
; 0 = disable
Expand Down Expand Up @@ -77,7 +80,7 @@ exclude_bomb = 0
; 1 - equip menu ([secondary] & [primary] + [autoitems])
; 2 - randomly weapons ([secondary] & [primary] + [autoitems])
; 3 - free buy (only buying)
equip_mode = 3
equip_mode = 1

; Free buy time in seconds (weapon buy flood protect!)
; 0 - no time limit
Expand Down
2 changes: 2 additions & 0 deletions cstrike/addons/amxmodx/data/lang/csdm_reapi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PRIMARY_WEAPONS = Primary weapon
CHAT_HELP_GUNS = ^3say ^1guns ^3to re-enable the gun menu.
MENU_WILL_BE_OPENED = ^3Gun menu will be re-enabled next spawn.
FREEBUYTIME_PASSED = %0.f seconds have passed. ^rYou can't buy anything now!
CHAT_RESETSCORE = Your score has been reset!

[ru]
EQUIP_MENU = Меню вооружения
Expand All @@ -23,3 +24,4 @@ PRIMARY_WEAPONS = Основное оружие
CHAT_HELP_GUNS = ^3напишите ^1guns ^3, чтобы открыть меню оружия.
MENU_WILL_BE_OPENED = ^3Меню вооружения будет открыто при следующем возрождении.
FREEBUYTIME_PASSED = %0.f секунд прошло. ^rВы не можете больше покупать!
CHAT_RESETSCORE = Ваш счёт был сброшен!
49 changes: 48 additions & 1 deletion cstrike/addons/amxmodx/scripting/CSDM_ReAPI/csdm_misc.sma
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,23 @@ new HamHook:g_hSecondaryAttack[sizeof(g_szWeaponList)], HamHook:g_hAddToPlayer[s

new g_bWeaponState[MAX_CLIENTS + 1][CSW_P90 + 1]

new bool:g_bWeaponStateRemember = true, g_bitHideHudFlags, g_iRefillClip = 1
new bool:g_bWeaponStateRemember = true, g_bitHideHudFlags, g_iRefillClip = 1, bool:g_bAllowResetScore = true

#define register_trigger_clcmd(%0,%1) \
for (new iter = 0; iter < sizeof(BASE_CHAT_TRIGGERS); iter++) \
{ \
register_clcmd(fmt("say %s%s", BASE_CHAT_TRIGGERS[iter], %0), %1); \
register_clcmd(fmt("say_team %s%s", BASE_CHAT_TRIGGERS[iter], %0), %1); \
}

new stock const BASE_CHAT_TRIGGERS[][] = { "/", "\", "!", "." };

enum forwardlist_e
{
iFwdPlayerResetScore
}

new g_eCustomForwards[forwardlist_e]

public plugin_init()
{
Expand All @@ -31,6 +46,13 @@ public plugin_init()
DisableHamForward(g_hAddToPlayer[i] = RegisterHam(Ham_Item_AddToPlayer, g_szWeaponList[i], "CBasePlayerItem_AddToPlayer", .Post = true))
DisableHamForward(g_hSecondaryAttack[i] = RegisterHam(Ham_Weapon_SecondaryAttack, g_szWeaponList[i], "CBasePlayerItem_SecAttack", .Post = true))
}

new const CMDS_ResetScore[][] = { "rs", "resetscore" };
for(new i; i < sizeof(CMDS_ResetScore); i++) {
register_trigger_clcmd(CMDS_ResetScore[i], "hCMD_ResetScore")
}

g_eCustomForwards[iFwdPlayerResetScore] = CreateMultiForward("CSDM_PlayerResetScore", ET_IGNORE, FP_CELL)
}

public plugin_cfg()
Expand Down Expand Up @@ -132,6 +154,10 @@ public ReadCfg(const szLineData[], const iSectionID)
if(ContainFlag(szValue, "t"))
g_bitHideHudFlags |= HIDEHUD_TIMER
}
else if(equali(szKey, "allow_reset_score"))
{
g_bAllowResetScore = true;
}
}

CheckForwards()
Expand Down Expand Up @@ -165,3 +191,24 @@ CheckForwards()
iMsgHookHideWeapon = 0
}
}

public hCMD_ResetScore(const pPlayer) {
if(!g_bAllowResetScore)
return PLUGIN_CONTINUE

if(is_nullent(pPlayer))
return PLUGIN_CONTINUE

new ret;
ExecuteForward(g_eCustomForwards[iFwdPlayerResetScore], ret, pPlayer)

if(ret == PLUGIN_HANDLED)
return PLUGIN_CONTINUE

set_entvar(pPlayer, var_frags, 0.0)
set_member(pPlayer, m_iDeaths, 0)

client_print_color(pPlayer, print_team_grey, "^4[CSDM] %L", pPlayer, "CHAT_RESETSCORE")

return PLUGIN_HANDLED
}
8 changes: 8 additions & 0 deletions cstrike/addons/amxmodx/scripting/include/csdm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ forward CSDM_PlayerSpawned(const pPlayer, const bool:bIsBot, const iNumSpawns)
*/
forward CSDM_PlayerKilled(const pVictim, const pKiller, const HitBoxGroup:iLastHitGroup)

/** Player reset score.
*
* @param pPlayer Player id
*
* @note return PLUGIN_HANDLED will block change
*/
forward CSDM_PlayerResetScore(const pPlayer)


//■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ NATIVES ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

Expand Down

0 comments on commit 9e83cff

Please sign in to comment.