PHP Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.0"
#define FCVAR_FLAGS FCVAR_REPLICATED|FCVAR_NOTIFY // If you are going to use the same CVar Flags, store them as a constant. Also FCVAR_PLUGIN is deprecated
/*
* Since IsFinale only lives inside an event and is calculated when its fired, remove it from global scope
static bool IsFinale; */
public Plugin myinfo =
{
name = "Unlock screen freeze",
author = "ZBzibing",
description = "After the rescue was initiated, all players failed. When restarting, the perspective of the bystander was permanently frozen.",
version = PLUGIN_VERSION,
url = "https://forums.alliedmods.net/showthread.php?p=2766144"
};
// Better on Hungarian notation (g_hRemoveCameraFinale OR g_hCvarRemoveCameraFinale) -> Useful to know what type of value is storing and if its global or not
// If there is only 1 or 2 variables should be no problem, but the more values you use the more complex will be to remember all of them
ConVar Remove_camerafinale; // With new-style declarations, use ConVar, not Handles
public void OnPluginStart() // New-Style declarations
{
CreateConVar("sm_REC_version", PLUGIN_VERSION, "Plugins Version", FCVAR_FLAGS);
Remove_camerafinale = CreateConVar("l4d_REC_Swich", "1", "Plug-in switch.0:off 1:on", FCVAR_FLAGS);
HookEventEx("round_start", REC, EventHookMode_PostNoCopy); // If you aren't going to use any event param, PostNoCopy is faster
}
Action REC(Handle event, const char[] name, bool dontBroadcast)
{
if (!Remove_camerafinale.BoolValue) // Methodmaps
{
return Plugin_Continue;
}
bool IsFinale = FindEntityByClassname(-1, "trigger_finale") != INVALID_ENT_REFERENCE; // Define IsFinale inside this event
int maxent = GetMaxEntities();
char Removeview[64];
for (int i = MaxClients; i < maxent; i++) // GetMaxClients() -> MaxClients
{
if ( IsValidEdict(i) && IsValidEntity(i) )
{
GetEdictClassname(i, Removeview, sizeof(Removeview));
if ( ( StrContains(Removeview, "point_viewcontrol")) != -1 || StrContains(Removeview, "point_deathfall_camera") != -1 )
if (IsFinale == true || IsBuggedMap())
{
//PrintToChatAll("\x04[SM] Audience freeze view is unlocked!");
RemoveEdict(i);
} // You did a mess with indentations here
}
}
return Plugin_Continue;
}
bool IsBuggedMap()
{
char sMap[64];
GetCurrentMap(sMap, sizeof(sMap));
if ( StrEqual(sMap, "l4d_hospital04_interior", false)
|| StrEqual(sMap, "l4d_hospital05_rooftop", false)
|| StrEqual(sMap, "l4d_garage02_lots", false)
|| StrEqual(sMap, "l4d_smalltown05_houseboat", false)
|| StrEqual(sMap, "l4d_airport05_runway", false)
|| StrEqual(sMap, "l4d_farm01_hilltop", false)
|| StrEqual(sMap, "l4d_farm05_cornfield", false)
|| StrEqual(sMap, "l4d_river03_port", false)
|| StrEqual(sMap, "tutorial_standards", false) )
{
return true;
}
return false;
}