The implementation could look like this:
1) Loop though the .res files
2) Register any event that contains "userid" for this special "lookup"
3) When the event fires and is in the lookup list, try to grab the player object and index and stuff it into sp_index and sp_player
4) Send the modified event to the scripts
Pros:
- Redundant code in scripts is avoided. Most of the time you want to implement player-related code for player_xxx events (or any events that contain "userid" for that matter)
- Having the code in C++ should actually be faster then doing it in python though a Python -> c++ - > Python call multiple times (and considering player events are used in a lot of addons, this probably makes a difference regarding CPU-time
- Adds overhead - if these "extended" features are not used, it's wasted CPU-time
- May not be fully reliable
Original discussion arised here:
your-name-here wrote:Because GetIndex isn't inside IGameEvent as a function, nor would it be valid for all game events. We're providing a 1-1 translation of every C++ function to Python. It's 1-2 extra lines of code. We're not asking for the world from you, so I don't see why you are so stressed out over this.Mahi wrote:This part really stresses me, if we're actually never going to use userid or player, why not just have a single function GetIndex('userid')? Even if it was stupid and unlogical to have such, and even if SP is not meant to be "easy to use", that would just make things so much easier for everyone, and it would already be stupid NOT TO do it like that? Ofc. anyone could define it by themselves, to do all those 3 lines in one function, but it'd be simply easier if it was built-in.Syntax: Select all
userid = GameEvent.GetInt('userid')
player = Player.EdictOfUserid(userid)
index = Engine.IndexOfEdict(player)