Advertisement
Shepard62700FR

Half-Life C++, detect Christmas

Mar 30th, 2015
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. // Half-Life C++ - Server side Christmas detection (cross-platform)
  2. // All the code is on the "enginecallback.h" file
  3. // Add the "#include <ctime>" line above or below it's friend (#include "event_flags.h")
  4. // Add the "IsChristmas" function at the end just before the "#endif"
  5.  
  6. #include <ctime>
  7.  
  8. inline bool IsChristmas()
  9. {
  10.     // Get the time now
  11.     time_t tTime = time( 0 );
  12.     struct tm *stTimeNow = localtime( &tTime );
  13.  
  14.     // [DEBUG] Tell the date
  15.     //ALERT( at_console, "%i-%i-%i\n", (stTimeNow->tm_year + 1900), (stTimeNow->tm_mon + 1), stTimeNow->tm_mday );
  16.  
  17.     // It's Christmas ?
  18.     if ( ((stTimeNow->tm_mon + 1) == 12) && (stTimeNow->tm_mday == 25) )
  19.         return true;
  20.     else
  21.         return false;
  22. }
  23.  
  24. // Usage example : Use a special christmas MDL (model) for Barney
  25. // barney.cpp - Precache
  26.  
  27. PRECACHE_MODEL( IsChristmas() ? "models/barney_christmas.mdl" : "models/barney.mdl" );
  28.  
  29. // barney.cpp - Spawn
  30.  
  31. SET_MODEL( ENT( pev ), IsChristmas() ? "models/barney_christmas.mdl" : "models/barney.mdl" );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement