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

Commit 9e83cff

Browse files
authored
Add allow_reset_score setting for misc (#31)
1 parent 654f14a commit 9e83cff

File tree

6 files changed

+69
-4
lines changed

6 files changed

+69
-4
lines changed

cstrike/addons/amxmodx/configs/csdm/config.ini

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ refill_clip_weapons = 1
4040
; t - timer
4141
hide_hud_flags = "ft"
4242

43+
; Allow reset score for players by chat cmd '/rs'.
44+
allow_reset_score = 1
45+
4346
[protection]
4447
; Number of seconds someone is respawned for.
4548
; 0 = disable

cstrike/addons/amxmodx/configs/csdm/extraconfigs/_de_dust2.ini

+4-2
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ refill_clip_weapons = 1
4040
; t - timer
4141
hide_hud_flags = "ft"
4242

43+
; Allow reset score for players by chat cmd '/rs'.
44+
allow_reset_score = 1
45+
4346
[protection]
4447
; Number of seconds someone is respawned for.
4548
; 0 = disable
4649
protection_time = 2.0
4750

48-
4951
; Colors of glow shell, leave this in quotes
5052
; The digits are "R G B"
5153
; random value "random"
@@ -78,7 +80,7 @@ exclude_bomb = 0
7880
; 1 - equip menu ([secondary] & [primary] + [autoitems])
7981
; 2 - randomly weapons ([secondary] & [primary] + [autoitems])
8082
; 3 - free buy (only buying)
81-
equip_mode = 3
83+
equip_mode = 1
8284

8385
; Free buy time in seconds (weapon buy flood protect!)
8486
; 0 - no time limit

cstrike/addons/amxmodx/configs/csdm/extraconfigs/_prefix_de.ini

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ refill_clip_weapons = 1
4040
; t - timer
4141
hide_hud_flags = "ft"
4242

43+
; Allow reset score for players by chat cmd '/rs'.
44+
allow_reset_score = 1
45+
4346
[protection]
4447
; Number of seconds someone is respawned for.
4548
; 0 = disable
@@ -77,7 +80,7 @@ exclude_bomb = 0
7780
; 1 - equip menu ([secondary] & [primary] + [autoitems])
7881
; 2 - randomly weapons ([secondary] & [primary] + [autoitems])
7982
; 3 - free buy (only buying)
80-
equip_mode = 3
83+
equip_mode = 1
8184

8285
; Free buy time in seconds (weapon buy flood protect!)
8386
; 0 - no time limit

cstrike/addons/amxmodx/data/lang/csdm_reapi.txt

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ PRIMARY_WEAPONS = Primary weapon
1010
CHAT_HELP_GUNS = ^3say ^1guns ^3to re-enable the gun menu.
1111
MENU_WILL_BE_OPENED = ^3Gun menu will be re-enabled next spawn.
1212
FREEBUYTIME_PASSED = %0.f seconds have passed. ^rYou can't buy anything now!
13+
CHAT_RESETSCORE = Your score has been reset!
1314

1415
[ru]
1516
EQUIP_MENU = Меню вооружения
@@ -23,3 +24,4 @@ PRIMARY_WEAPONS = Основное оружие
2324
CHAT_HELP_GUNS = ^3напишите ^1guns ^3, чтобы открыть меню оружия.
2425
MENU_WILL_BE_OPENED = ^3Меню вооружения будет открыто при следующем возрождении.
2526
FREEBUYTIME_PASSED = %0.f секунд прошло. ^rВы не можете больше покупать!
27+
CHAT_RESETSCORE = Ваш счёт был сброшен!

cstrike/addons/amxmodx/scripting/CSDM_ReAPI/csdm_misc.sma

+48-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,23 @@ new HamHook:g_hSecondaryAttack[sizeof(g_szWeaponList)], HamHook:g_hAddToPlayer[s
1919

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

22-
new bool:g_bWeaponStateRemember = true, g_bitHideHudFlags, g_iRefillClip = 1
22+
new bool:g_bWeaponStateRemember = true, g_bitHideHudFlags, g_iRefillClip = 1, bool:g_bAllowResetScore = true
2323

24+
#define register_trigger_clcmd(%0,%1) \
25+
for (new iter = 0; iter < sizeof(BASE_CHAT_TRIGGERS); iter++) \
26+
{ \
27+
register_clcmd(fmt("say %s%s", BASE_CHAT_TRIGGERS[iter], %0), %1); \
28+
register_clcmd(fmt("say_team %s%s", BASE_CHAT_TRIGGERS[iter], %0), %1); \
29+
}
30+
31+
new stock const BASE_CHAT_TRIGGERS[][] = { "/", "\", "!", "." };
32+
33+
enum forwardlist_e
34+
{
35+
iFwdPlayerResetScore
36+
}
37+
38+
new g_eCustomForwards[forwardlist_e]
2439

2540
public plugin_init()
2641
{
@@ -31,6 +46,13 @@ public plugin_init()
3146
DisableHamForward(g_hAddToPlayer[i] = RegisterHam(Ham_Item_AddToPlayer, g_szWeaponList[i], "CBasePlayerItem_AddToPlayer", .Post = true))
3247
DisableHamForward(g_hSecondaryAttack[i] = RegisterHam(Ham_Weapon_SecondaryAttack, g_szWeaponList[i], "CBasePlayerItem_SecAttack", .Post = true))
3348
}
49+
50+
new const CMDS_ResetScore[][] = { "rs", "resetscore" };
51+
for(new i; i < sizeof(CMDS_ResetScore); i++) {
52+
register_trigger_clcmd(CMDS_ResetScore[i], "hCMD_ResetScore")
53+
}
54+
55+
g_eCustomForwards[iFwdPlayerResetScore] = CreateMultiForward("CSDM_PlayerResetScore", ET_IGNORE, FP_CELL)
3456
}
3557

3658
public plugin_cfg()
@@ -132,6 +154,10 @@ public ReadCfg(const szLineData[], const iSectionID)
132154
if(ContainFlag(szValue, "t"))
133155
g_bitHideHudFlags |= HIDEHUD_TIMER
134156
}
157+
else if(equali(szKey, "allow_reset_score"))
158+
{
159+
g_bAllowResetScore = true;
160+
}
135161
}
136162

137163
CheckForwards()
@@ -165,3 +191,24 @@ CheckForwards()
165191
iMsgHookHideWeapon = 0
166192
}
167193
}
194+
195+
public hCMD_ResetScore(const pPlayer) {
196+
if(!g_bAllowResetScore)
197+
return PLUGIN_CONTINUE
198+
199+
if(is_nullent(pPlayer))
200+
return PLUGIN_CONTINUE
201+
202+
new ret;
203+
ExecuteForward(g_eCustomForwards[iFwdPlayerResetScore], ret, pPlayer)
204+
205+
if(ret == PLUGIN_HANDLED)
206+
return PLUGIN_CONTINUE
207+
208+
set_entvar(pPlayer, var_frags, 0.0)
209+
set_member(pPlayer, m_iDeaths, 0)
210+
211+
client_print_color(pPlayer, print_team_grey, "^4[CSDM] %L", pPlayer, "CHAT_RESETSCORE")
212+
213+
return PLUGIN_HANDLED
214+
}

cstrike/addons/amxmodx/scripting/include/csdm.inc

+8
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ forward CSDM_PlayerSpawned(const pPlayer, const bool:bIsBot, const iNumSpawns)
132132
*/
133133
forward CSDM_PlayerKilled(const pVictim, const pKiller, const HitBoxGroup:iLastHitGroup)
134134

135+
/** Player reset score.
136+
*
137+
* @param pPlayer Player id
138+
*
139+
* @note return PLUGIN_HANDLED will block change
140+
*/
141+
forward CSDM_PlayerResetScore(const pPlayer)
142+
135143

136144
//■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ NATIVES ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
137145

0 commit comments

Comments
 (0)