Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =============================================================================
- # >> IMPORTS
- # =============================================================================
- # binutils
- import binutils
- from custom_types import Interfaces
- # =============================================================================
- # >> TESTS
- # =============================================================================
- # Get the IServerTools interface
- server_tools = Interfaces.server_tools
- # Get the first entity
- entity = server_tools.FirstEntity()
- def entitygetvalue(entity, field, string_t=False, buffer_size=1024):
- # Create a buffer
- buffer = binutils.alloc(buffer_size)
- # Call the function, which fills <buffer>
- if not server_tools.GetKeyValue(entity, field, buffer, buffer_size) % 2:
- # The key does not exist
- buffer.dealloc()
- return None
- # Save the result
- result = buffer.get_string() if string_t else buffer.get_string_array()
- # Deallocate the buffer
- buffer.dealloc()
- # Return the result
- return result
- # Loop through all entities on the current map
- while entity:
- # The key "model" is a string_t as it accesses this attribute:
- # string_t m_ModelName;
- # That's why we need to handle it differently. It's obviously a bug in the
- # engine itself. But that's the reason why
- # es.entitygetvalue(<index>, <field>) fails on the key "model".
- print entitygetvalue(entity, 'model', True)
- entity = server_tools.NextEntity(entity)
Advertisement
Add Comment
Please, Sign In to add comment