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

new-style declarations are required


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
diasdighetto
Junior Member
Join Date: Dec 2018
Location: Portugal
Old 12-31-2020 , 10:32   new-style declarations are required
Reply With Quote #1

Hello,

I am trying to do a plugin for CS:GO that with a command next round is only with deagle, but i am getting this error:
PHP Code:
error 147: new-style declarations are required 
PHP Code:
#include <sdktools>
#include <mainlib>
#include <multicolors>
#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_TAG "{blue}[ deagleround ]{default}"
#define NAME "Deagle Round"
#define AUTHOR "dias di Ghetto"
#define DESC "Deagle Rounds by a command for VIPs"
#define VERSION "0.1"

ConVar g_bAllowedFlagsg_iTimesPerMap;

Handle:ClientTimer[MAXPLAYERS+1] = {INVALID_HANDLE, ...};

bool isdeagleround false;
bool deagleroundScheduled false;
int deaglerounds 0;
public 
Plugin myinfo 
{
    
name NAME,
    
author AUTHOR,
    
description DESC,
    
version VERSION,
    
url "https://diasdighetto.pt"
};

public 
void OnPluginStart() {
    
LoadTranslations("deagleround.phrases");
    
RegConsoleCmd("sm_deagleround"Command_deagleround);
    
g_bAllowedFlags CreateConVar("deagleround_allowedflags""b""Allowed flags to start a Deagle Round or a vote for it"_true0.0true1.0);
    
g_iTimesPerMap CreateConVar("deagleround_maxtimespermmap""0""Max amount of times a Deagle round can occur. 0 for unlimited"_true0.0false);
    
AutoExecConfig(true"deagleround");
    
HookEvent("round_start"OnRoundStart);
    
HookEvent("item_pickup"OnWeaponPickup);
    
SetDefaultValues();
}

public 
Action OnWeaponPickup(Event event, const char[] namebool dontBroadcast)
{
    if (
isdeagleround) {
        
int client GetClientOfUserId(GetEventInt(event"userid"));    
        
StripAllWeapons(client);
    }
}

public 
Action Command_deagleround(int clientint args) {
    if (!
IsValidClient(client)) {
        return 
Plugin_Handled;
    }
    
char allowedFlags[16];
    
GetConVarString(g_bAllowedFlagsallowedFlagssizeof(allowedFlags));
    if (!
HasClientFlag(clientallowedFlags)) {
        return 
Plugin_Handled;
    }
    
int maxdeaglerounds GetConVarInt(g_iTimesPerMap);
    if (
deaglerounds == maxdeaglerounds && maxdeaglerounds != 0) {
        return 
Plugin_Handled;        
    }
    
Scheduledeagleround();
    return 
Plugin_Handled;
}

void Scheduledeagleround() {
    
deagleroundScheduled true;
    
CPrintToChatAll("%s %t"PLUGIN_TAG"deagleround Scheduled");
}

public 
void OnMapStart() {
    
SetDefaultValues();
}

public 
void SetDefaultValues() {
    
deaglerounds 0;
    
isdeagleround false;
    
deagleroundScheduled false;
}
    
public 
Action OnRoundStart(Event event, const char[] namebool dontBroadcast) {    
    if (
isdeagleround) {
        
isdeagleround false;
    }
    if (
deagleroundScheduled) {
        
CreateTimer(0.5Timer_RemoveOtherWeapons_);
        
CreateTimer(0.5Timer_GiveDeagle_);
        
deagleroundScheduled false;
        
isdeagleround true;
        
deaglerounds++;
        
CPrintToChatAll("%s %t"PLUGIN_TAG"deagleround Started");
    }
}


public 
Action Timer_RemoveOtherWeapons(Handle timerany data) {
    
StripAllPlayers();
}

public 
Action Timer_GiveDeagle(Handle timerany client)
{
    
ClientTimer[client] = INVALID_HANDLE;
    
    
ServerCommand("sm_give @all weapon_deagle"client);
}


public 
void StripAllPlayers() {
    for (
int i 1<= MaxClientsi++) {
        if (
IsValidClient(i)) {    
            
StripAllWeapons(i);
        }
    }
}
public 
void StripAllWeapons(int client) {
    
int wp;
    for (
int i 05i++) {
        
wp GetPlayerWeaponSlot(clienti);
        if (
!= 2) {
            if(
IsValidEntity(wp)) {
                
RemovePlayerItem(clientwp);
            }
        }
    }

If someone can help me i really apreciate it ;)
diasdighetto is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 12-31-2020 , 11:19   Re: new-style declarations are required
Reply With Quote #2

Change
Code:
Handle:ClientTimer[MAXPLAYERS+1] = {INVALID_HANDLE, ...};
to
Code:
Handle ClientTimer[MAXPLAYERS+1] = {null, ...};

or change
Code:
#pragma newdecls required
to
Code:
#pragma newdecls optional
or just remove this line.
__________________

Last edited by MAGNAT2645; 12-31-2020 at 11:21.
MAGNAT2645 is offline
diasdighetto
Junior Member
Join Date: Dec 2018
Location: Portugal
Old 12-31-2020 , 12:11   Re: new-style declarations are required
Reply With Quote #3

thanks for the help i rewrite the Handle and i dont receive the error, but now i am trying to apply a exception on the strip part of the plugin but i dont know how. I dont want to strip the slot 2 and 3, just the others slots
diasdighetto is offline
Mr.Freeman
Senior Member
Join Date: Nov 2013
Location: Canada
Old 12-31-2020 , 15:57   Re: new-style declarations are required
Reply With Quote #4

Quote:
Originally Posted by diasdighetto View Post
thanks for the help i rewrite the Handle and i dont receive the error, but now i am trying to apply a exception on the strip part of the plugin but i dont know how. I dont want to strip the slot 2 and 3, just the others slots
Change:
PHP Code:
if (!= 2) { 
To:
PHP Code:
if ((!= 2) && (!= 3)) { 
__________________
Feel Free to PM me about any questions, I'll do my best to help

Last edited by Mr.Freeman; 12-31-2020 at 17:09.
Mr.Freeman is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 12-31-2020 , 16:37   Re: new-style declarations are required
Reply With Quote #5

Change:
PHP Code:
if (!= 2) { 
To:
PHP Code:
if ((!= 2) && (!= 3)) { 
Why the change: If "||" is used it means OR. In this case, if the number was 3 the code would execute because it wasn't a 2.... OR if the number was 2 the code would execute because it wasn't a 3.

If we use "&&" it means AND. In this case if the number wasn't a 2 AND the number wasn't a 3 it would execute. This is the intended solution.

You could also do this:
PHP Code:
if ((2) || (3)) { 
That would mean if the number was less than 2 OR if the number was greater than 3 the code would execute. This would also be the intended solution.
PC Gamer is offline
Reply



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 16:25.


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