Raised This Month: $32 Target: $400
 8% 

Solved [CS:GO] error 147: new-style declarations are required


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 01-18-2018 , 13:35   [CS:GO] error 147: new-style declarations are required
Reply With Quote #1

I wanned to add a check on "mp_humanteam" before adding teams to prevent exploiting, when that command allows on CTs for example.

PHP Code:
#pragma semicolon 1

#define PLUGIN_NAME "[CSGO] Team Limit Bypass"
#define PLUGIN_AUTHOR "Zephyrus"
#define PLUGIN_DESCRIPTION "Bypasses hardcoded team limits"
#define PLUGIN_VERSION "1.1"
#define PLUGIN_URL ""

#include <sourcemod>
#include <sdktools>
#include <cstrike>
#pragma newdecls required

enum EJoinTeamReason
{
    
k_OneTeamChange=0,
    
k_TeamsFull=1,
    
k_TTeamFull=2,
    
k_CTTeamFull=3
}

int g_iTSpawns=-1;
int g_iCTSpawns=-1;
int g_iSelectedTeam[MAXPLAYERS+1];

public 
Plugin myinfo =
{
    
name PLUGIN_NAME,
    
author PLUGIN_AUTHOR,
    
description PLUGIN_DESCRIPTION,
    
version PLUGIN_VERSION,
    
url PLUGIN_URL
};

public 
void OnPluginStart()
{
    
HookEvent("jointeam_failed"Event_JoinTeamFailedEventHookMode_Pre);
    
AddCommandListener(Command_JoinTeam"jointeam");
}

public 
void OnMapStart()
{
    
g_iTSpawns=-1;
    
g_iCTSpawns=-1;

    
// Give plugins a chance to create new spawns
    
CreateTimer(0.1Timer_OnMapStart);
}

public 
void OnClientConnected(int client)
{
    
g_iSelectedTeam[client]=0;
}

public 
Action Timer_OnMapStart(Handle timerany data)
{
    
g_iTSpawns=0;
    
g_iCTSpawns=0;

    
int ent = -1;
    while((
ent FindEntityByClassname(ent"info_player_counterterrorist")) != -1) ++g_iCTSpawns;
    
ent = -1;
    while((
ent FindEntityByClassname(ent"info_player_terrorist")) != -1) ++g_iTSpawns;

    return 
Plugin_Stop;
}

public 
Action Event_JoinTeamFailed(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    if(!
client || !IsClientInGame(client))
        return 
Plugin_Continue;

    new 
EJoinTeamReason:m_eReason EJoinTeamReason:GetEventInt(event"reason");

    
char teamcvar[4];
    
int m_iTs GetTeamClientCount(CS_TEAM_T);
    
int m_iCTs GetTeamClientCount(CS_TEAM_CT);
    
GetConVarString(FindConVar("mp_humanteam"), teamcvarsizeof(teamcvar));

    switch(
m_eReason)
    {
        case 
k_OneTeamChange:
        {
            return 
Plugin_Continue;
        }

        case 
k_TeamsFull:
        {
            if(
m_iCTs == g_iCTSpawns && m_iTs == g_iTSpawns)
                return 
Plugin_Continue;
        }

        case 
k_TTeamFull:
        {
            if(
m_iTs == g_iTSpawns && StrEqual(teamcvar"t"))
                return 
Plugin_Continue;
        }

        case 
k_CTTeamFull:
        {
            if(
m_iCTs == g_iCTSpawns && StrEqual(teamcvar"ct"))
                return 
Plugin_Continue;
        }

        default:
        {
            return 
Plugin_Continue;
        }
    }

    
ChangeClientTeam(clientg_iSelectedTeam[client]);

    return 
Plugin_Handled;
}

public 
Action Command_JoinTeam(int clientchar[] commandint args)
{
    if(!
args || !client || !IsClientInGame(client))
        return 
Plugin_Continue;

    
char m_szTeam[8];
    
GetCmdArg(1m_szTeamsizeof(m_szTeam));
    
int m_iTeam StringToInt(m_szTeam);

    if(
CS_TEAM_SPECTATOR<=m_iTeam<=CS_TEAM_CT)
        
g_iSelectedTeam[client]=m_iTeam;

    return 
Plugin_Continue;

This is the line that needs new-style declaration:
PHP Code:
new EJoinTeamReason:m_eReason EJoinTeamReason:GetEventInt(event"reason"); 
__________________

Last edited by PinHeaDi; 01-18-2018 at 17:37.
PinHeaDi is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 01-18-2018 , 14:27   Re: [CS:GO] error 147: new-style declarations are required
Reply With Quote #2

in new syntax this would look like this:
PHP Code:
EJoinTeamReason m_eReason view_as<EJoinTeamReason>(event.GetInt("reason")); 

Last edited by hmmmmm; 01-18-2018 at 14:27.
hmmmmm is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 01-18-2018 , 17:37   Re: [CS:GO] error 147: new-style declarations are required
Reply With Quote #3

You're the real MVP.
__________________
PinHeaDi is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:09.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode