Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. //FireEvent Stuff
  2. if ( !strcmp( pEvent->GetName( ), "round_prestart" ) ) {
  3. EventInfo.flBuytimeEnd = I::Globals->curtime + 35.f;
  4. EventInfo.BuyInfo.clear( );
  5. }
  6.  
  7. if ( !strcmp( pEvent->GetName( ), "round_end" ) )
  8. EventInfo.BuyInfo.clear( );
  9.  
  10. if ( !strcmp( pEvent->GetName( ), "item_purchase" ) )
  11. LogItemsEvent( pEvent );
  12.  
  13. //Structs
  14. struct BuyInfo_t
  15. {
  16. int iEntityIndex = 0;
  17. std::string szName = "";
  18. std::vector< std::string > szWeaponsBought{ };
  19. };
  20.  
  21. struct EventInfo_t
  22. {
  23. float flHitmarkerAlpha = 0.f;
  24. float flBuytimeEnd = 0.f;
  25. std::vector< BuyInfo_t > BuyInfo{ };
  26. };
  27.  
  28. class CGameEvents
  29. {
  30. public:
  31. EventInfo& GetEventInfo(){
  32. return EventInfo;
  33. }
  34. private:
  35. EventInfo_t EventInfo;
  36. BuyInfo_t BuyInfo;
  37. }
  38.  
  39. void CGameEvents::LogItemsEvent( IGameEvent* pEvent )
  40. {
  41. CBaseEntity* pLocal = I::ClientEntList->GetClientEntity( I::Engine->GetLocalPlayer( ) );
  42. CBaseEntity* pEntity = I::ClientEntList->GetClientEntity( I::Engine->GetPlayerForUserID( pEvent->GetInt( "userid" ) ) );
  43. player_info_t pInfo;
  44.  
  45. if ( pLocal && pEntity )
  46. {
  47. if ( pEntity->Team( ) != pLocal->Team( ) )
  48. {
  49. I::Engine->GetPlayerInfo( pEntity->Index( ), &pInfo );
  50. BuyInfo.iEntityIndex = pEntity->Index( );
  51. BuyInfo.szName = pInfo.name;
  52. for ( auto& it : EventInfo.BuyInfo )
  53. {
  54. if ( it.iEntityIndex == BuyInfo.iEntityIndex )
  55. {
  56. it.szWeaponsBought.push_back( FixName( pEvent->GetString( "weapon" ) ) );
  57. return;
  58. }
  59. }
  60. BuyInfo.szWeaponsBought.clear( );
  61. BuyInfo.szWeaponsBought.push_back( FixName( pEvent->GetString( "weapon" ) ) );
  62. EventInfo.BuyInfo.push_back( BuyInfo );
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement