@@ -76,23 +76,23 @@ public plugin_init()
7676 g_iEventSpawn = CreateMultiForward (" PugPlayerSpawned" ,ET_IGNORE,FP_CELL);
7777 g_iEventKilled = CreateMultiForward (" PugPlayerKilled" ,ET_IGNORE,FP_CELL);
7878
79- register_event (" SendAudio" ," CS_WonTR " ," a" ," 2=% !MRAD_terwin" );
80- register_event (" SendAudio" ," CS_WonCT " ," a" ," 2=% !MRAD_ctwin" );
81- register_event (" SendAudio" ," CS_RoundDraw " ," a" ," 2=% !MRAD_rounddraw" );
79+ register_event (" SendAudio" ," fnWonTR " ," a" ," 2=% !MRAD_terwin" );
80+ register_event (" SendAudio" ," fnWonCT " ," a" ," 2=% !MRAD_ctwin" );
81+ register_event (" SendAudio" ," fnRoundDraw " ," a" ," 2=% !MRAD_rounddraw" );
8282
83- register_logevent (" CS_RoundStart " ,2 ," 1=Round_Start" );
84- register_logevent (" CS_RoundEnd " ,2 ," 1=Round_End" );
83+ register_logevent (" fnRoundStart " ,2 ," 1=Round_Start" );
84+ register_logevent (" fnRoundEnd " ,2 ," 1=Round_End" );
8585
86- register_clcmd (" jointeam" ," CS_JoinTeam " );
86+ register_clcmd (" jointeam" ," fnJoinTeam " );
8787
88- register_menucmd (- 2 ,MENU_KEY_1| MENU_KEY_2| MENU_KEY_5| MENU_KEY_6," CS_TeamSelect " );
89- register_menucmd (register_menuid (" Team_Select" ,1 ),MENU_KEY_1| MENU_KEY_2| MENU_KEY_5| MENU_KEY_6," CS_TeamSelect " );
88+ register_menucmd (- 2 ,MENU_KEY_1| MENU_KEY_2| MENU_KEY_5| MENU_KEY_6," fnTeamSelect " );
89+ register_menucmd (register_menuid (" Team_Select" ,1 ),MENU_KEY_1| MENU_KEY_2| MENU_KEY_5| MENU_KEY_6," fnTeamSelect " );
9090
91- RegisterHamPlayer (Ham_Spawn," CS_SpawnPost " ,true );
92- RegisterHamPlayer (Ham_Killed," CS_KilledPost " ,true );
91+ RegisterHamPlayer (Ham_Spawn," fnSpawnPost " ,true );
92+ RegisterHamPlayer (Ham_Killed," fnKilledPost " ,true );
9393
94- register_clcmd (" joinclass" ," CS_JoinedClass " );
95- register_clcmd (" menuselect" ," CS_JoinedClass " );
94+ register_clcmd (" joinclass" ," fnJoinedClass " );
95+ register_clcmd (" menuselect" ," fnJoinedClass " );
9696}
9797
9898public plugin_cfg ()
@@ -105,34 +105,34 @@ public plugin_natives()
105105{
106106 register_library (" PugCS" );
107107
108- register_native (" PugGetClientTeam" ," CS_GetClientTeam " );
109- register_native (" PugSetClientTeam" ," CS_SetClientTeam " );
108+ register_native (" PugGetClientTeam" ," fnGetClientTeam " );
109+ register_native (" PugSetClientTeam" ," fnSetClientTeam " );
110110
111- register_native (" PugGetPlayers" ," CS_GetPlayers " );
111+ register_native (" PugGetPlayers" ," fnGetPlayers " );
112112
113- register_native (" PugIsTeam" ," CS_IsTeam " );
114- register_native (" PugRespawn" ," CS_Respawn " );
115- register_native (" PugSetGodMode" ," CS_SetGodMode " );
116- register_native (" PugSetMoney" ," CS_SetMoney " );
117- register_native (" PugMapObjectives" ," CS_MapObjectives " );
118- register_native (" PugSetScore" ," CS_SetScore " );
113+ register_native (" PugIsTeam" ," fnIsTeam " );
114+ register_native (" PugRespawn" ," fnRespawn " );
115+ register_native (" PugSetGodMode" ," fnSetGodMode " );
116+ register_native (" PugSetMoney" ," fnSetMoney " );
117+ register_native (" PugMapObjectives" ," fnMapObjectives " );
118+ register_native (" PugSetScore" ," fnSetScore " );
119119
120- register_native (" PugTeamsRandomize" ," CS_TeamsRandomize " );
121- register_native (" PugTeamsBalance" ," CS_TeamsBalance " );
122- register_native (" PugTeamsOptmize" ," CS_TeamsOptmize " );
120+ register_native (" PugTeamsRandomize" ," fnTeamsRandomize " );
121+ register_native (" PugTeamsBalance" ," fnTeamsBalance " );
122+ register_native (" PugTeamsOptmize" ," fnTeamsOptmize " );
123123}
124124
125- public CS_GetClientTeam ()
125+ public fnGetClientTeam ()
126126{
127127 return _: cs_get_user_team (get_param (1 ));
128128}
129129
130- public CS_SetClientTeam ()
130+ public fnSetClientTeam ()
131131{
132132 cs_set_user_team (get_param (1 ),_: get_param (2 ));
133133}
134134
135- public CS_GetPlayers ()
135+ public fnGetPlayers ()
136136{
137137 new iPlayers[32 ],iNum,iCount = 0 ;
138138 get_players (iPlayers,iNum,get_param (1 ) ? " h" : " ch" );
@@ -148,7 +148,7 @@ public CS_GetPlayers()
148148 return iCount;
149149}
150150
151- public CS_IsTeam ()
151+ public fnIsTeam ()
152152{
153153 if (isTeam (get_param (1 )))
154154 {
@@ -158,22 +158,22 @@ public CS_IsTeam()
158158 return false ;
159159}
160160
161- public CS_Respawn ()
161+ public fnRespawn ()
162162{
163163 ExecuteHamB (Ham_CS_RoundRespawn,get_param (1 ));
164164}
165165
166- public CS_SetGodMode ()
166+ public fnSetGodMode ()
167167{
168168 set_pev (get_param (1 ),pev_takedamage,get_param (2 ) ? DAMAGE_NO : DAMAGE_AIM);
169169}
170170
171- public CS_SetMoney ()
171+ public fnSetMoney ()
172172{
173173 cs_set_user_money (get_param (1 ),get_param (2 ),get_param (3 ));
174174}
175175
176- public CS_MapObjectives (id,iParams)
176+ public fnMapObjectives (id,iParams)
177177{
178178 new iEnt = - 1 ;
179179 new iRemove = get_param (1 );
@@ -187,7 +187,7 @@ public CS_MapObjectives(id,iParams)
187187 }
188188}
189189
190- public CS_SetScore (id,iParams)
190+ public fnSetScore (id,iParams)
191191{
192192 new iPlayer = get_param (1 );
193193
@@ -197,9 +197,9 @@ public CS_SetScore(id,iParams)
197197 ExecuteHam (Ham_AddPoints,iPlayer,0 ,true );
198198}
199199
200- public CS_TeamsRandomize ()
200+ public fnTeamsRandomize ()
201201{
202- new iPlayers[32 ],iNum;
202+ new iPlayers[MAX_PLAYERS ],iNum;
203203 get_players (iPlayers,iNum);
204204
205205 for (new i;i < iNum;i++ )
@@ -228,9 +228,9 @@ public CS_TeamsRandomize()
228228 }
229229}
230230
231- public CS_TeamsBalance ()
231+ public fnTeamsBalance ()
232232{
233- new iPlayers[32 ],iNum,iPlayer;
233+ new iPlayers[MAX_PLAYERS ],iNum,iPlayer;
234234 get_players (iPlayers,iNum," h" );
235235
236236 new a,b,aPlayer,bPlayer;
@@ -282,21 +282,26 @@ public CS_TeamsBalance()
282282 }
283283}
284284
285- public CS_TeamsOptmize ()
285+ public fnTeamsOptmize ()
286286{
287- new iSkills[MAX_PLAYERS+ 1 ],iSorted[MAX_PLAYERS+ 1 ];
287+ new iSkills[MAX_PLAYERS],iSorted[MAX_PLAYERS];
288+
288289 new iPlayers[MAX_PLAYERS],iNum,iPlayer;
290+ get_players (iPlayers,iNum," h" );
291+
292+ new iFrags;
289293
290294 for (new i;i < iNum;i++ )
291295 {
292296 iPlayer = iPlayers[i];
293297
294- iSorted[iPlayer] = iSkills[iPlayer] = (get_user_time (iPlayer,1 ) / get_user_frags (iPlayer));
298+ iFrags = get_user_frags (iPlayer);
299+ iSorted[iPlayer] = iSkills[iPlayer] = (get_user_time (iPlayer,1 ) / ((iFrags > 1 ) ? iFrags : 1 ));
295300 }
296301
297302 SortIntegers (iSorted,sizeof (iSorted),Sort_Descending);
298303
299- new iCheck = 1 ,iTeams = PugNumTeams () ;
304+ new CsTeams: iCheck = CS_TEAM_T ;
300305
301306 for (new i;i < sizeof (iSorted);i++ )
302307 {
@@ -306,56 +311,56 @@ public CS_TeamsOptmize()
306311
307312 if (iSkills[iPlayer] == iSorted[i])
308313 {
309- PugSetClientTeam (iPlayer,iCheck);
314+ cs_set_user_team (iPlayer,iCheck);
310315
311316 iCheck++ ;
312317
313- if (iCheck > iTeams )
318+ if (iCheck > CS_TEAM_CT )
314319 {
315- iCheck = 1 ;
320+ iCheck = CS_TEAM_T ;
316321 }
317322 }
318323 }
319324 }
320325}
321326
322- public CS_RoundStart ()
327+ public fnRoundStart ()
323328{
324329 PugRoundStart ();
325330}
326331
327- public CS_RoundEnd ()
332+ public fnRoundEnd ()
328333{
329334 PugRoundEnd ();
330335}
331336
332- public CS_WonTR ()
337+ public fnWonTR ()
333338{
334339 PugRoundWinner (_: CS_TEAM_T);
335340}
336341
337- public CS_WonCT ()
342+ public fnWonCT ()
338343{
339344 PugRoundWinner (_: CS_TEAM_CT);
340345}
341346
342- public CS_RoundDraw ()
347+ public fnRoundDraw ()
343348{
344349 PugRoundWinner (0 );
345350}
346351
347352public PugEventHalfTime ()
348353{
349- set_task (get_pcvar_float (g_pSwitchDelay)," CS_SwitchTeams " );
354+ set_task (get_pcvar_float (g_pSwitchDelay)," fnSwitchTeams " );
350355}
351356
352- public CS_SwitchTeams ()
357+ public fnSwitchTeams ()
353358{
354359 new iScore = PugGetTeamScore (1 );
355360 PugSetTeamScore (1 ,PugGetTeamScore (2 ));
356361 PugSetTeamScore (2 ,iScore);
357362
358- new iPlayers[32 ],iNum,iPlayer;
363+ new iPlayers[MAX_PLAYERS ],iNum,iPlayer;
359364 get_players (iPlayers,iNum," h" );
360365
361366 for (new i;i < iNum;i++ )
@@ -381,20 +386,20 @@ public CS_SwitchTeams()
381386 }
382387}
383388
384- public CS_JoinTeam (id)
389+ public fnJoinTeam (id)
385390{
386391 new sArg[3 ];
387392 read_argv (1 ,sArg,charsmax (sArg));
388393
389- return CS_CheckTeam (id,CsTeams: str_to_num (sArg));
394+ return fnCheckTeam (id,CsTeams: str_to_num (sArg));
390395}
391396
392- public CS_TeamSelect (id,iKey)
397+ public fnTeamSelect (id,iKey)
393398{
394- return CS_CheckTeam (id,CsTeams: (iKey + 1 ));
399+ return fnCheckTeam (id,CsTeams: (iKey + 1 ));
395400}
396401
397- public CS_CheckTeam (id,CsTeams: iTeamNew)
402+ fnCheckTeam (id,CsTeams: iTeamNew)
398403{
399404 new CsTeams: iTeamOld = cs_get_user_team (id);
400405
@@ -522,7 +527,7 @@ public CS_CheckTeam(id,CsTeams:iTeamNew)
522527 return PLUGIN_CONTINUE;
523528}
524529
525- public CS_SpawnPost (id)
530+ public fnSpawnPost (id)
526531{
527532 ExecuteForward (g_iEventSpawn,g_iEventReturn,id);
528533}
@@ -535,17 +540,17 @@ public PugPlayerSpawned(id)
535540 {
536541 if (is_user_alive (id) && isTeam (id) && get_pcvar_num (g_pTeamMoney) && (cs_get_user_money (id) != get_pcvar_num (g_pMpStartMoney)))
537542 {
538- set_task (0 .1 ," CS_MoneyTeam " ,id);
543+ set_task (0 .1 ," fnMoneyTeam " ,id);
539544 }
540545 }
541546}
542547
543- public CS_KilledPost (id)
548+ public fnKilledPost (id)
544549{
545550 ExecuteForward (g_iEventKilled,g_iEventReturn,id);
546551}
547552
548- public CS_MoneyTeam (id)
553+ public fnMoneyTeam (id)
549554{
550555 new sTeam[13 ];
551556 get_user_team (id,sTeam,charsmax (sTeam));
@@ -582,32 +587,27 @@ public CS_MoneyTeam(id)
582587
583588public CS_OnBuy (id,iWeapon)
584589{
585- switch ( iWeapon)
590+ if (( iWeapon == CSI_FLASHBANG) || (iWeapon == CSI_HEGRENADE) || (iWeapon == CSI_SMOKEGRENADE) )
586591 {
587- case CSI_FLASHBANG,CSI_HEGRENADE,CSI_SMOKEGRENADE:
592+ new iStage = GET_PUG_STAGE ();
593+
594+ if ((iStage == STAGE_WARMUP) || (iStage == STAGE_HALFTIME))
588595 {
589- new iStage = GET_PUG_STAGE ();
590-
591- if ((iStage == STAGE_FIRSTHALF) || (iStage == STAGE_SECONDHALF) || (iStage == STAGE_OVERTIME))
592- {
593- return PLUGIN_CONTINUE;
594- }
595-
596596 return get_pcvar_num (g_pBlockGrenades) ? PLUGIN_HANDLED : PLUGIN_CONTINUE;
597597 }
598- case CSI_SHIELD:
599- {
600- return get_pcvar_num (g_pBlockShield) ? PLUGIN_HANDLED : PLUGIN_CONTINUE;
601- }
602598 }
603-
599+ else if (iWeapon == CSI_SHIELD)
600+ {
601+ return get_pcvar_num (g_pBlockShield) ? PLUGIN_HANDLED : PLUGIN_CONTINUE;
602+ }
603+
604604 return PLUGIN_CONTINUE;
605605}
606606
607- public CS_JoinedClass (id)
607+ public fnJoinedClass (id)
608608{
609609 if (get_ent_data (id," CBasePlayer" ," m_iMenu" ) == CS_Menu_ChooseAppearance)
610610 {
611611 ExecuteForward (g_iEventJoinedTeam,g_iEventReturn,id,cs_get_user_team (id));
612612 }
613- }
613+ }
0 commit comments