View Single Post
Author Message
checkster
BANNED
Join Date: Apr 2007
Location: Norway
Old 09-30-2017 , 11:00   L4d2, editing a plugin
Reply With Quote #1

To start its not my code.

How do I get this to work with sourcebans?
Been so long since I did anything I'm pretty sure I'm lagging on info

PHP Code:
#pragma semicolon 1

#include <sourcemod>

public Plugin:myinfo =
{
    
name "Thirdpersonshoulder Block",
    
author "Don",
    
description "Kicks clients who enable the thirdpersonshoulder mode on L4D1/2 to prevent them from looking around corners, through walls etc.",
    
version "1.3",
    
url "http://forums.alliedmods.net/showthread.php?t=159582"
}

public 
APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max)
{
    
decl String:sGame[12];
    
GetGameFolderName(sGamesizeof(sGame));
    if (
StrEqual(sGame"left4dead") || StrEqual(sGame"left4dead2"))    /* Only load the plugin if the server is running Left 4 Dead or Left 4 Dead 2.
                                         * Loading the plugin on Counter-Strike: Source or Team Fortress 2 would cause all clients to get kicked,
                                         * because the thirdpersonshoulder mode and the corresponding ConVar that we check do not exist there.
                                         */
    
{
        return 
APLRes_Success;
    }
    else
    {
        
strcopy(errorerr_max"Plugin only supports L4D1/2");
        return 
APLRes_Failure;
    }
}

public 
OnPluginStart()
{
    
CreateConVar("l4d_tpsblock_version""1.3""Version of the Thirdpersonshoulder Block plugin"FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
CreateTimer(GetRandomFloat(2.53.5), CheckClients_TIMER_REPEAT);
}

public 
Action:CheckClients(Handle:timer)
{
    for (new 
iClientIndex 1iClientIndex <= MaxClientsiClientIndex++)
    {
        if (
IsClientInGame(iClientIndex) && !IsFakeClient(iClientIndex))
        {
            if (
GetClientTeam(iClientIndex) == || GetClientTeam(iClientIndex) == 3)    // Only query clients on survivor or infected team, ignore spectators.
            
{
                
QueryClientConVar(iClientIndex"c_thirdpersonshoulder"QueryClientConVarCallback);
            }
        }
    }    
}

public 
QueryClientConVarCallback(QueryCookie:cookieclientConVarQueryResult:result, const String:cvarName[], const String:cvarValue[])
{
    if (
IsClientInGame(client) && !IsClientInKickQueue(client))
    {
        if (
result != ConVarQuery_Okay)        /* If the ConVar was somehow not found on the client, is not valid or is protected, kick the client.
                             * The ConVar should always be readable unless the client is trying to prevent it from being read out.
                             */
        
{
            new 
String:sName[MAX_NAME_LENGTH];
            
GetClientName(clientsNamesizeof(sName));
            
BanClient(client,5,BANFLAG_AUTHID,"Banned for potentially using thirdpersonshoulder mode.\nConVar c_thirdpersonshoulder not found, not valid or protected");
            
LogAction(0client"Banned \"%L\" for potentially using thirdpersonshoulder mode, ConVar c_thirdpersonshoulder not found, not valid or protected"client);
            
PrintToChatAll("[SM] Banned %s for potentially using thirdpersonshoulder mode, ConVar c_thirdpersonshoulder not found, not valid or protected"sName);
        }
        else if (!
StrEqual(cvarValue"false") && !StrEqual(cvarValue"0"))    /* If the ConVar was found on the client, but is not set to either "false" or "0",
                                             * kick the client as well, as he might be using thirdpersonshoulder.
                                             */
        
{
            new 
String:sName[MAX_NAME_LENGTH];
            
GetClientName(clientsNamesizeof(sName));
            
BanClient(client,5,BANFLAG_AUTHID,"Banned for potentially using thirdpersonshoulder mode.\nEnter \"c_thirdpersonshoulder 0\" (without the \"\") in your console before rejoining the server");
            
LogAction(0client"Banned \"%L\" for potentially using thirdpersonshoulder mode"client);
            
PrintToChatAll("[SM] Banned %s for potentially using thirdpersonshoulder mode"sName);
        }
    }

checkster is offline