sourcemod/extensions/cstrike/timeleft.cpp
David Anderson 0f45f8b5ee - added timeleft functionality to cstrike extension
- finalized timeleft api once again (i hope)
- added weapon slot definitions to cstrike.inc
- bumped timer API

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401465
2007-09-23 19:33:19 +00:00

44 lines
969 B
C++

#include "extension.h"
#include "timeleft.h"
TimeLeftEvents g_TimeLeftEvents;
bool get_new_timeleft_offset = false;
bool round_end_found = false;
bool TimeLeftEvents::LevelInit(char const *pMapName,
char const *pMapEntities,
char const *pOldLevel,
char const *pLandmarkName,
bool loadGame,
bool background)
{
round_end_found = true;
get_new_timeleft_offset = false;
return true;
}
void TimeLeftEvents::FireGameEvent(IGameEvent *event)
{
const char *name = event->GetName();
if (strcmp(name, "round_start") == 0)
{
if (get_new_timeleft_offset || !round_end_found)
{
get_new_timeleft_offset = false;
timersys->NotifyOfGameStart();
timersys->MapTimeLeftChanged();
}
round_end_found = false;
}
else if (strcmp(name, "round_end") == 0)
{
if (event->GetInt("reason") == 16)
{
get_new_timeleft_offset = true;
}
round_end_found = true;
}
}