View Single Post
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-23-2016 , 12:03   Re: [TF2] Map Voting Tweaks (2015-11-24)
Reply With Quote #5

OK, so I have a new beta version of NativeVotes out that has a feature inspired by this plugin (mainly because NativeVotes and this plugin don't work well together).

My implementation was pretty much done from scratch.

Now, having said that, here's a few things of note that I ran into:
  1. TF2's client always organizes its NextLevel and ChangeLevel items in alphabetical order.
  2. On rare occasions, the game writes the ServerMapCycle stringtable late. That is, it would write to it after my OnConfigsExecuted+RequestFrame ran and overwrote my changes. I had to add a 1 second timer after OnConfigsExecuted instead before I wrote to the stringtable.
  3. Occasionally, the server hadn't finished loading the names of all my workshop maps (and I only have 11) by the time OnConfigsExecuted+RequestFrame ran for the first map. This was fixed by the same timer as the above problem.
  4. SetStringTableData's length needs to be the strlen+1 (or something similar, the ImplodeStrings and strcopy functions return bytes they put in strings) of what you're writing as the game actually allocates that many bytes in the stringtable. Also, SourceMod gets grumpy if you try to allocate dynamic strings larger than a certain size.
  5. I wrote some new code to explode/implode strings to/from ArrayLists and StringMaps. Made it easier to pass these between plugins.

OK, now glancing at the code used in this plugin, you can use the GetFeatureStatus function to find out if a particular native is present. For instance:

Code:
if (GetFeatureStatus(FeatureType_Native, "GetMapDisplayName") == FeatureStatus_Available)
{
    // GetMapDisplayName can be used here
}
However, if you do this, you also have to use MarkNativeAsOptional on the same function name in AskPluginLoad2.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline