The update solves the following problems:
- Proper loading/unloading of a module with SourceMod tools (
sm plugins load/reload/unload) - Fixing the player spawn event:
- Fatal error when starting the module:
Native "VIP_HookClientSpawn" was not found - Warning when compiling the module:
warning 234: symbol "VIP_HookClientSpawn" is marked as deprecated: Use VIP_OnPlayerSpawn - Fatal error when compiling the module:
error 017: undefined symbol "VIP_HookClientSpawn"
- Fatal error when starting the module:
The following code is used as an example:
// This is the unique feature name. It is different in every module
#define VIP_MODULE "module1"
// It may also look like this
new const String:g_sFeature[] = "module1";
public OnPluginStart()
{
// code
}
public VIP_OnVIPLoaded()
{
VIP_RegisterFeature(VIP_MODULE, BOOL);
}- If the unique feature name looks like this:
#define VIP_MODULE "module1"Change it to
new const String:g_sFeature[] = "module1";Or, for the new syntax
static const char g_sFeature[] = "module1";- Then replace every
VIP_MODULE(it may be named differently) withg_sFeature - Find the function
public OnPluginStart()
{
// code
}And add the following at its end
if(VIP_IsVIPLoaded())
{
VIP_OnVIPLoaded();
}It should look like this:
public OnPluginStart()
{
// code
if(VIP_IsVIPLoaded())
{
VIP_OnVIPLoaded();
}
}If there is no OnPluginStart() function, add it:
public OnPluginStart()
{
if(VIP_IsVIPLoaded())
{
VIP_OnVIPLoaded();
}
}- Next, find the function
public OnPluginEnd()
{
// code
}Most often it does not exist, so add it:
public OnPluginEnd()
{
// code (if there was any)
if(CanTestFeatures() && GetFeatureStatus(FeatureType_Native, "VIP_UnregisterFeature") == FeatureStatus_Available)
{
VIP_UnregisterFeature(g_sFeature);
}
}After this, problem #1 is solved.
One more example, for modules with 2 features (like skins, trails, etc.):
- A toggle (on/off) feature
- A settings feature
They look roughly like this:
#define VIP_SKINS "Skins"
#define VIP_SKINS_MENU "Skins_Menu"
public VIP_OnVIPLoaded()
{
VIP_RegisterFeature(VIP_SKINS, STRING, _, OnToggleItem);
VIP_RegisterFeature(VIP_SKINS_MENU, _, SELECTABLE, OnSelectItem, _, OnDrawItem);
}To update this type of module, do the following:
- Replace the feature declarations
#define VIP_SKINS "Skins"
#define VIP_SKINS_MENU "Skins_Menu"with
static const String:g_sFeature[][] = {"Skins", "Skins_Menu"};Or, for the new syntax
static const char g_sFeature[][] = {"Skins", "Skins_Menu"};- Replace every
VIP_SKINSwithg_sFeature[0]andVIP_SKINS_MENUwithg_sFeature[1] - Modify/add
OnPluginStart()
public OnPluginStart()
{
// Code, if there was any
if(VIP_IsVIPLoaded())
{
VIP_OnVIPLoaded();
}
}- Modify/add
OnPluginEnd()
public OnPluginEnd()
{
// code (if there was any)
if(CanTestFeatures() && GetFeatureStatus(FeatureType_Native, "VIP_UnregisterFeature") == FeatureStatus_Available)
{
VIP_UnregisterFeature(g_sFeature[0]);
VIP_UnregisterFeature(g_sFeature[1]);
}
}The main thing is to follow this rule:
Every
VIP_RegisterFeatureinVIP_OnVIPLoaded()must have a matchingVIP_UnregisterFeatureinOnPluginEnd()
You can find more examples in the modules that have already been updated.
To solve problem #2:
- In
OnPluginStart()findVIP_HookClientSpawn(OnPlayerSpawn); - Delete this line
- Then find:
public OnPlayerSpawn(iClient, iTeam, bool:bIsVIP)and replace it with
public VIP_OnPlayerSpawn(iClient, iTeam, bool:bIsVIP)