1010#endif
1111
1212# define PLUGIN " Deathrun: Informer"
13- # define VERSION " 0.4 "
13+ # define VERSION " 0.5 "
1414# define AUTHOR " Mistrick"
1515
1616#pragma semicolon 1
1717
1818# define UPDATE_INTERVAL 1 .0
19+ // #define DONT_SHOW_FOR_ALIVE
1920
2021new const PREFIX[] = " [DRI]" ;
2122
2223new g_szCurMode[32 ], g_iConnectedCount, g_iMaxPlayers, g_iHudInformer, g_iHudSpecList, g_iHudSpeed;
23- new bool: g_bAlive[33 ], bool: g_bInformer[33 ], bool: g_bSpeed[33 ], bool: g_bSpecList[33 ];
24+ new bool: g_bConnected[ 33 ], bool: g_bAlive[33 ], bool: g_bInformer[33 ], bool: g_bSpeed[33 ], bool: g_bSpecList[33 ];
2425new g_iHealth[33 ], g_iMoney[33 ], g_iFrames[33 ], g_iPlayerFps[33 ];
2526
2627public plugin_init ()
@@ -51,13 +52,15 @@ public plugin_init()
5152}
5253public client_putinserver (id)
5354{
55+ g_bConnected[id] = true ;
5456 g_bInformer[id] = true ;
5557 g_bSpecList[id] = true ;
5658 g_bSpeed[id] = true ;
5759 g_iConnectedCount++ ;
5860}
5961public client_disconnect (id)
6062{
63+ g_bConnected[id] = false ;
6164 g_bAlive[id] = false ;
6265 g_iConnectedCount-- ;
6366}
@@ -128,36 +131,32 @@ public Task_ShowInfo()
128131 iLen += formatex (szInformer[iLen], charsmax (szInformer) - iLen, " All Players: %d /%d " , g_iConnectedCount, g_iMaxPlayers);
129132
130133 static szSpecInfo[1152 ];
131- new iAllPlayers[32 ], iAllNum; get_players (iAllPlayers, iAllNum, " ch" );
132- for (new id, i; i < iAllNum; i++ )
134+ for (new id = 1 ; id <= g_iMaxPlayers; id++ )
133135 {
134- id = iAllPlayers[i] ;
136+ if ( ! g_bConnected[id]) continue ;
135137
136- if (g_iHealth[id] >= 255 )
137- {
138- set_dhudmessage (55 , 245 , 55 , 0 .02 , 0 .90 , 0 , _, UPDATE_INTERVAL - 0 .05 , _, _, false );
139- show_dhudmessage (id, " Health: %d " , g_iHealth[id]);
140- }
141138 if (g_bInformer[id])
142139 {
143140 set_hudmessage (55 , 245 , 55 , 0 .02 , 0 .18 , 0 , _, UPDATE_INTERVAL, _, _, 3 );
144141 ShowSyncHudMsg (id, g_iHudInformer, szInformer);
145142 }
146-
147143
148144 if (! g_bAlive[id]) continue ;
149145
150- new iDeadPlayers[32 ], iDeadNum; get_players (iDeadPlayers, iDeadNum, " bch" );
151-
152- if (iDeadNum == 0 ) continue ;
146+ if (g_iHealth[id] >= 255 )
147+ {
148+ set_dhudmessage (55 , 245 , 55 , 0 .02 , 0 .90 , 0 , _, UPDATE_INTERVAL - 0 .05 , _, _, false );
149+ show_dhudmessage (id, " Health: %d " , g_iHealth[id]);
150+ }
153151
154152 new bool: bShowInfo[33 ];
155153 get_user_name (id, szName, charsmax (szName));
156154 iLen = formatex (szSpecInfo, charsmax (szSpecInfo), " Player: %s ^nHealth: %d HP, Money: $%d , FPS: %d ^n" , szName, g_iHealth[id], g_iMoney[id], g_iPlayerFps[id]);
157155
158- for (new dead, j; j < iDeadNum; j ++ )
156+ for (new dead = 1 ; dead <= g_iMaxPlayers; dead ++ )
159157 {
160- dead = iDeadPlayers[j];
158+ if (! g_bConnected[dead] || g_bAlive[dead]) continue ;
159+
161160 if (pev (dead, pev_iuser2) == id)
162161 {
163162 get_user_name (dead, szName, charsmax (szName));
@@ -169,9 +168,11 @@ public Task_ShowInfo()
169168 }
170169 if (bShowInfo[id])
171170 {
172- for (new player, j; j < iAllNum; j++ )
171+ #if defined DONT_SHOW_FOR_ALIVE
172+ bShowInfo[id] = false ;
173+ #endif
174+ for (new player = 1 ; player < g_iMaxPlayers; player++ )
173175 {
174- player = iAllPlayers[j];
175176 if (g_bSpecList[player] && bShowInfo[player])
176177 {
177178 set_hudmessage (245 , 245 , 245 , 0 .70 , 0 .15 , 0 , _, UPDATE_INTERVAL, _, _, 3 );
@@ -185,10 +186,8 @@ public Task_ShowInfo()
185186public Task_ShowSpeed ()
186187{
187188 new Float: fSpeed, Float: fVelocity[3 ], iSpecmode;
188- new players[32 ], pnum; get_players (players, pnum, " ch" );
189- for (new id, i, target; id < pnum; i++ )
189+ for (new id = 1 , target; id <= g_iMaxPlayers; id++ )
190190 {
191- id = players[i];
192191 if (! g_bSpeed[id]) continue ;
193192
194193 iSpecmode = pev (id, pev_iuser1);
@@ -208,7 +207,13 @@ public dr_selected_mode(id, mode)
208207}
209208stock get_ct (& alive, & count)
210209{
211- new players[32 ];
212- get_players (players, count, " ceh" , " CT" );
213- get_players (players, alive, " aceh" , " CT" );
210+ count = 0 ; alive = 0 ;
211+ for (new id = 1 ; id <= g_iMaxPlayers; id++ )
212+ {
213+ if (g_bConnected[id])
214+ {
215+ count++ ;
216+ if (g_bAlive[id]) alive++ ;
217+ }
218+ }
214219}
0 commit comments