View Single Post
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 07-06-2018 , 11:08   Re: [L4D2] Improved Automatic Campaign Switcher (ACS) [v1.9.0 (20180706)]
Reply With Quote #14

Both .sp files failed to compile. The reason is that you didn't parenthesize the values that you were using the view_as operator for.

Before: view_as<something>something2
After: view_as<something>(something2)

I also replaced all the "FCVAR_PLUGIN" plugin stuff with an underscore since they're deprecated.

Another thing I did was add #pragma newdecls required to both plugins. For acs.sp, you didn't add "void" for the ConVar.AddChangeHook callbacks and other things like OnMapStart and OnPluginStart. You also didn't add "int" for the MenuHandler.

Before: public VoteMenuHandler
After: public int VoteMenuHandler

Aside from that, everything checks out so far, though I do see a lot of hard-coded stuff that could easily be shortened/fixed by Silvers' suggestion. I second his suggestion since it really will reduce all those mutations to like around 25-30 lines of code and will support all mutations including custom ones.

This is the one that Silvers is suggesting.

PHP Code:
int g_iCurrentMode;
bool IsAllowedGameMode()
{
    if( 
g_hCvarMPGameMode == null )
        return 
false;

    
int iCvarModesTog g_hCvarModesTog.IntValue;
    if( 
iCvarModesTog != )
    {
        
g_iCurrentMode 0;

        
int entity CreateEntityByName("info_gamemode");
        
DispatchSpawn(entity);
        
HookSingleEntityOutput(entity"OnCoop"OnGamemodetrue);
        
HookSingleEntityOutput(entity"OnSurvival"OnGamemodetrue);
        
HookSingleEntityOutput(entity"OnVersus"OnGamemodetrue);
        
HookSingleEntityOutput(entity"OnScavenge"OnGamemodetrue);
        
ActivateEntity(entity);
        
AcceptEntityInput(entity"PostSpawnActivate");
        
AcceptEntityInput(entity"Kill");

        if( 
g_iCurrentMode == )
            return 
false;

        if( !(
iCvarModesTog g_iCurrentMode) )
            return 
false;
    }

    
char sGameModes[64], sGameMode[64];
    
g_hCvarMPGameMode.GetString(sGameModesizeof(sGameMode));
    
Format(sGameModesizeof(sGameMode), ",%s,"sGameMode);

    
g_hCvarModes.GetString(sGameModessizeof(sGameModes));
    if( 
strcmp(sGameModes"") )
    {
        
Format(sGameModessizeof(sGameModes), ",%s,"sGameModes);
        if( 
StrContains(sGameModessGameModefalse) == -)
            return 
false;
    }

    
g_hCvarModesOff.GetString(sGameModessizeof(sGameModes));
    if( 
strcmp(sGameModes"") )
    {
        
Format(sGameModessizeof(sGameModes), ",%s,"sGameModes);
        if( 
StrContains(sGameModessGameModefalse) != -)
            return 
false;
    }

    return 
true;
}

public 
void OnGamemode(const char[] outputint callerint activatorfloat delay)
{
    if( 
strcmp(output"OnCoop") == )
        
g_iCurrentMode 1;
    else if( 
strcmp(output"OnSurvival") == )
        
g_iCurrentMode 2;
    else if( 
strcmp(output"OnVersus") == )
        
g_iCurrentMode 4;
    else if( 
strcmp(output"OnScavenge") == )
        
g_iCurrentMode 8;

Make sure to call it anytime after the round starts since it creates the info_gamemode entity and you'll get errors if you try to create it on OnMapStart or anything before configs are executed. I highly recommend checking out his plugins, like Mutant Zombies and Gun Cabinet since he calls the check on OnConfigsExecuted. A lot of his plugins contain code that not many users know about or tried before so maybe they can help you optimize your plugins.
Attached Files
File Type: sp Get Plugin or Get Source (acs.sp - 193 views - 64.3 KB)
File Type: sp Get Plugin or Get Source (l4d2_mission_manager.sp - 213 views - 33.8 KB)
__________________

Last edited by Psyk0tik; 07-06-2018 at 11:25.
Psyk0tik is offline