Ayuto

custom_types example2

Dec 27th, 2013
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.34 KB | None | 0 0
  1. # =============================================================================
  2. # >> IMPORTS
  3. # =============================================================================
  4. # EventScripts
  5. import es
  6.  
  7. # binutils
  8. import custom_types
  9.  
  10. from custom_types import utils
  11.  
  12.  
  13. # =============================================================================
  14. # >> TESTS
  15. # =============================================================================
  16. # Get the IServerTools interface
  17. server_tools = custom_types.IServerTools(utils.CreateInterface('VSERVERTOOLS002', 0))
  18.  
  19. # Get the factory dictionary
  20. factory_dict = server_tools.GetEntityFactoryDictionary()
  21.  
  22. # Loop through all entities on the map
  23. entity = server_tools.FirstEntity()
  24. while entity:
  25.     # Get its classname. E.g. player or func_button
  26.     classname = entity.m_iClassname
  27.  
  28.     # Get the name of the C++ class. E.g. CCSPlayer or CFuncButton
  29.     cppclassname = entity.GetDataDescMap().dataClassName
  30.  
  31.     # Get the entity's handle and convert it to an index
  32.     index = es.getindexfromhandle(entity.GetRefHandle().m_Index)
  33.  
  34.     # Get the entity's size. E.g. sizeof(CCSPlayer)
  35.     size = factory_dict.FindFactory(classname).GetEntitySize()
  36.  
  37.     # Now print all the information
  38.     print index, cppclassname, classname, size
  39.  
  40.     # Get next entity
  41.     entity = server_tools.NextEntity(entity)
Advertisement
Add Comment
Please, Sign In to add comment