2
2
#include < csdm>
3
3
4
4
5
- # define IsPlayer (%1 ) (1 <= (%1 ) <= g_iMaxPlayers)
6
- # define PlayerTask (%1 ) (%1 + PROTECTION_TASK_ID)
7
- # define GetPlayerByTaskID (%1 ) (%1 - PROTECTION_TASK_ID)
8
-
9
- const PROTECTION_TASK_ID = 216897
10
-
11
- enum color_e { Float: R, Float: G, Float: B }
12
-
13
- enum
14
- {
15
- STATUSICON_HIDE,
16
- STATUSICON_SHOW,
17
- STATUSICON_FLASH
18
- }
19
-
20
- new bool: g_bIsProtected[MAX_CLIENTS + 1 ]
21
- new g_iMaxPlayers
22
-
23
- new g_szSpriteName[18 ] = " suithelmet_full" // max lenght = 16
24
- new Float: g_flRenderAlpha = 10 .0 , bool: g_bBlockDamage = true , Float: g_fImmunityTime;
25
- new Float: g_flTeamColors[TeamName][color_e] =
26
- {
5
+ new Float: g_fImmunityTime
6
+ new Float: g_flRenderAlpha = 10 .0
7
+ new Float: g_flTeamColors[TeamName][3 ] = {
27
8
{0 .0 , 0 .0 , 0 .0 },
28
9
{235 .0 , 0 .0 , 0 .0 }, // TEAM_TERRORIST
29
10
{0 .0 , 0 .0 , 235 .0 }, // TEAM_CT
@@ -39,16 +20,8 @@ public plugin_init()
39
20
{
40
21
register_plugin (" CSDM Protection" , CSDM_VERSION, " wopox1337" )
41
22
42
- if (g_fImmunityTime > 0 .0 ) {
43
- if (g_bBlockDamage)
44
- RegisterHookChain (RG_CSGameRules_FPlayerCanTakeDamage, " CSGameRules_FPlayerCanTakeDmg" , .post = false )
45
-
46
- RegisterHookChain (RG_CBasePlayer_SetSpawnProtection, " CBasePlayer_SetSpawnProtection" , .post = true )
47
- RegisterHookChain (RG_CBasePlayer_RemoveSpawnProtection, " CBasePlayer_RemoveSpawnProtection" , .post = true )
48
-
49
- }
50
-
51
- g_iMaxPlayers = get_maxplayers ()
23
+ RegisterHookChain (RG_CBasePlayer_SetSpawnProtection, " CBasePlayer_SetSpawnProtection" , .post = true )
24
+ RegisterHookChain (RG_CBasePlayer_RemoveSpawnProtection, " CBasePlayer_RemoveSpawnProtection" , .post = true )
52
25
}
53
26
54
27
public CSDM_Initialized (const szVersion[])
@@ -64,28 +37,14 @@ public CSDM_ConfigurationLoad(const ReadTypes:iReadAction)
64
37
65
38
public CBasePlayer_SetSpawnProtection (const pPlayer, Float: time)
66
39
{
67
- SetEffects (pPlayer, time )
40
+ SetEffects (pPlayer)
68
41
}
69
42
70
43
public CBasePlayer_RemoveSpawnProtection (const pPlayer)
71
44
{
72
45
RemoveEffects (pPlayer)
73
46
}
74
47
75
- public CSGameRules_FPlayerCanTakeDmg (const pPlayer, const pAttacker)
76
- {
77
- if (pPlayer == pAttacker || ! IsPlayer (pAttacker))
78
- return HC_CONTINUE
79
-
80
- if (g_bIsProtected[pAttacker]) // protected attacker can't take damage
81
- {
82
- SetHookChainReturn (ATYPE_INTEGER, false )
83
- return HC_SUPERCEDE
84
- }
85
-
86
- return HC_CONTINUE
87
- }
88
-
89
48
public ReadCfg (const szLineData[], const iSectionID)
90
49
{
91
50
new szKey[MAX_KEY_LEN], szValue[MAX_VALUE_LEN], szSign[2 ]
@@ -96,15 +55,6 @@ public ReadCfg(const szLineData[], const iSectionID)
96
55
{
97
56
g_fImmunityTime = str_to_float (szValue)
98
57
}
99
- else if (equali (szKey, " block_damage" ))
100
- {
101
- g_bBlockDamage = bool: (str_to_num (szValue))
102
- }
103
- else if (equali (szKey, " sprite_name" ))
104
- {
105
- copy (g_szSpriteName, charsmax (g_szSpriteName), szValue)
106
- strtolower (g_szSpriteName)
107
- }
108
58
else if (equali (szKey, " render_color_" , 13 ))
109
59
{
110
60
new szRed[4 ], szGreen[4 ], szBlue[4 ]
@@ -113,13 +63,13 @@ public ReadCfg(const szLineData[], const iSectionID)
113
63
114
64
if (parse (szValue, szRed, charsmax (szRed), szGreen, charsmax (szGreen), szBlue, charsmax (szBlue)) == 3 )
115
65
{
116
- g_flTeamColors[iTeam][R ] = floatclamp (str_to_float (szRed), 1 .0 , 255 .0 )
117
- g_flTeamColors[iTeam][G ] = floatclamp (str_to_float (szGreen), 1 .0 , 255 .0 )
118
- g_flTeamColors[iTeam][B ] = floatclamp (str_to_float (szBlue), 1 .0 , 255 .0 )
66
+ g_flTeamColors[iTeam][0 ] = floatclamp (str_to_float (szRed), 1 .0 , 255 .0 )
67
+ g_flTeamColors[iTeam][1 ] = floatclamp (str_to_float (szGreen), 1 .0 , 255 .0 )
68
+ g_flTeamColors[iTeam][2 ] = floatclamp (str_to_float (szBlue), 1 .0 , 255 .0 )
119
69
}
120
70
else if (equali (szValue, " random" ))
121
71
{
122
- g_flTeamColors[iTeam][R ] = g_flTeamColors[iTeam][G ] = g_flTeamColors[iTeam][B ] = 0 .0
72
+ g_flTeamColors[iTeam][0 ] = g_flTeamColors[iTeam][1 ] = g_flTeamColors[iTeam][2 ] = 0 .0
123
73
}
124
74
}
125
75
else if (equali (szKey, " render_alpha" ))
@@ -128,51 +78,23 @@ public ReadCfg(const szLineData[], const iSectionID)
128
78
}
129
79
}
130
80
131
- SetEffects (const pPlayer, Float: time )
81
+ SetEffects (const pPlayer)
132
82
{
133
83
// https://github.com/s1lentq/ReGameDLL_CS/blob/bc2c3176e46e2c32ebc0110e7df879ea7ddbfafa/regamedll/dlls/player.cpp#L9532
134
84
set_entvar (pPlayer, var_rendermode, kRenderFxNone)
135
85
136
86
new TeamName: iTeam = get_member (pPlayer, m_iTeam)
137
- if (! g_flTeamColors[iTeam][R] && ! g_flTeamColors[iTeam][G] && ! g_flTeamColors[iTeam][B])
138
- {
139
- new Float: flColor[color_e]
140
- flColor[R] = random_float (1 .0 , 255 .0 )
141
- flColor[G] = random_float (1 .0 , 255 .0 )
142
- flColor[B] = random_float (1 .0 , 255 .0 )
87
+ new bool: isRandomColor = (! g_flTeamColors[iTeam][0 ] && ! g_flTeamColors[iTeam][1 ] && ! g_flTeamColors[iTeam][2 ])
88
+ if (! isRandomColor) {
89
+ rg_set_rendering (pPlayer, kRenderFxGlowShell, g_flTeamColors[iTeam], g_flRenderAlpha)
143
90
144
- rg_set_rendering (pPlayer, kRenderFxGlowShell, flColor, g_flRenderAlpha)
145
- }
146
- else rg_set_rendering (pPlayer, kRenderFxGlowShell, g_flTeamColors[iTeam], g_flRenderAlpha)
147
-
148
- if (g_szSpriteName[0 ] && time >= 1 .5 ) {
149
- SendStatusIcon (pPlayer, STATUSICON_FLASH)
91
+ return
150
92
}
151
- }
152
93
153
- RemoveEffects (const pPlayer)
154
- {
155
- if (is_user_connected (pPlayer))
156
- {
157
- rg_set_rendering (pPlayer)
94
+ new Float: flColor[3 ]
95
+ flColor[0 ] = random_float (1 .0 , 255 .0 )
96
+ flColor[1 ] = random_float (1 .0 , 255 .0 )
97
+ flColor[2 ] = random_float (1 .0 , 255 .0 )
158
98
159
- if (g_szSpriteName[0 ]) {
160
- SendStatusIcon (pPlayer)
161
- }
162
- }
163
- }
164
-
165
- stock SendStatusIcon (const pPlayer, iStatus = STATUSICON_HIDE, red = 0 , green = 160 , blue = 0 )
166
- {
167
- static iMsgIdStatusIcon
168
- if (iMsgIdStatusIcon || (iMsgIdStatusIcon = get_user_msgid (" StatusIcon" )))
169
- {
170
- message_begin (MSG_ONE_UNRELIABLE, iMsgIdStatusIcon, .player = pPlayer)
171
- write_byte (iStatus) // status: 0 - off, 1 - on, 2 - flash
172
- write_string (g_szSpriteName)
173
- write_byte (red)
174
- write_byte (green)
175
- write_byte (blue)
176
- message_end ()
177
- }
99
+ rg_set_rendering (pPlayer, kRenderFxGlowShell, flColor, g_flRenderAlpha)
178
100
}
0 commit comments