AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [HowTo] Alternative method for game_start/game_end for CS:S (https://forums.alliedmods.net/showthread.php?t=55107)

teame06 05-13-2007 20:19

[HowTo] Alternative method for game_start/game_end for CS:S
 
Since game_start and game_end doesn't fire off in CS:S. I had to make alternative method to catch when game start and game_ended. So if wanted to know if there was a player on each team. To give bonuses only when for objectives only when there are players on each team.

Code:
#include <sourcemod> #define TEAM_T               2 #define TEAM_CT              3 new CTcount; new Tcount; new bool:GameCommenced; public OnPluginStart() {     HookEvent("round_end", _RoundEnd);     HookEvent("player_team", _PlayerTeam); } public _RoundEnd(Handle:event, const String:name[], bool:dontBroadcast) {     /* Game Commenced reason */     if(GetEventInt(event, "reason") == 16)     {         GameCommenced = true;     } } public _PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) {     switch(GetEventInt(event, "oldteam"))     {         case TEAM_T:         {             Tcount--;         }         case TEAM_CT:         {             CTcount--;         }     }     /* Player disconnected and didn't join a new team */     if(!GetEventBool(event, "disconnect"))     {         switch(GetEventInt(event, "team"))         {             case TEAM_T:             {                 Tcount++;             }             case TEAM_CT:             {                 CTcount++;             }         }     }     /* If one of the counts goes to 0 that means game is not commenced any more */     if(!CTcount || !Tcount)     {         GameCommenced = false;     } }

Now with this all you can use bool:GameCommenced.


All times are GMT -4. The time now is 19:48.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.