Raised This Month: $51 Target: $400
 12% 

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
nergal
Veteran Member
Join Date: Apr 2012
Old 07-11-2015 , 09:18   Re: New API and Syntax
Reply With Quote #551

Quote:
Originally Posted by R1KO View Post
The old syntax:
PHP Code:
new Function:MyFunc = Function:GetArrayCell(hArrayFEATURES_ITEM_FUNC); 
In the new syntax:
PHP Code:
Function MyFunc view_as<Function> hArray.Get(FEATURES_ITEM_FUNC); 
and

How to correct?
use DataPack for Functions...
__________________
nergal is offline
R1KO
Member
Join Date: Sep 2013
Old 07-11-2015 , 10:12   Re: New API and Syntax
Reply With Quote #552

functions are obtained from native
R1KO is offline
Send a message via Skype™ to R1KO
BAILOPAN
Join Date: Jan 2004
Old 07-13-2015 , 15:26   Re: New API and Syntax
Reply With Quote #553

It is no longer legal to store functions inside arrays. This will be fixed in a future release, but we will need to introduce a new array type.
__________________
egg
BAILOPAN is offline
kossolax
AlliedModders Donor
Join Date: Jan 2008
Location: Belgium
Old 07-20-2015 , 15:22   Re: New API and Syntax
Reply With Quote #554

Quote:
Originally Posted by BAILOPAN View Post
It is no longer legal to store functions inside arrays. This will be fixed in a future release, but we will need to introduce a new array type.
Quote:
Originally Posted by nergal View Post
use DataPack for Functions...
So the only way right now is using the datapack ?

PHP Code:
DataPack dp;
dp.WriteFunction(fct1);
dp.WriteFunction(fct2);
dp.WriteFunction(fct3);
    
dp.Position 1;
Function 
fct dp.ReadFunction(); 
fct = fct2 ? Right?

EDIT: Well, it is kind of, but need to reset pack on each time the position is set.
By the way, what is the max size of a datapack ?

Last edited by kossolax; 07-21-2015 at 08:46.
kossolax is offline
BAILOPAN
Join Date: Jan 2004
Old 07-21-2015 , 14:11   Re: New API and Syntax
Reply With Quote #555

when you run out of memory though I would consider anything variable size to have a hard limit of INT_MAX (2^31-1) elements or bytes of storage.
__________________
egg
BAILOPAN is offline
Byte
Senior Member
Join Date: Jun 2010
Location: 📦 CCSPlayer
Old 07-24-2015 , 12:59   Re: New API and Syntax
Reply With Quote #556

I only saw this recently but the new syntax is pretty good
__________________
STEAM: /id/invexbyte | Github: Mo Beigi | Discord: Byte#0017
Community: Invex Gaming | My Plugins: Click Me!

Byte is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 07-25-2015 , 15:29   Re: New API and Syntax
Reply With Quote #557

Not too relevant to this thread, but does the 1.7 source code release zip contain the lexer and parser that spcomp uses to compile sourcepawn files, including the dual syntax support? (I want to see it for my own general education.)
Potato Uno is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-25-2015 , 15:53   Re: New API and Syntax
Reply With Quote #558

The release package only contains binaries. Have a look at the repo.
__________________
Peace-Maker is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 08-02-2015 , 00:01   Re: New API and Syntax
Reply With Quote #559

Before I publish an update to my Beacon plugin, can you guys confirm to me that this is okay?
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <autoexecconfig>
#include <csgocolors>

#pragma semicolon 1

#pragma newdecls required

#define SOUND_BLIP "buttons/blip1.wav"
#define PLUGIN_VERSION "1.4"
 
int g_BeamSprite = -1;
int g_HaloSprite = -1;
int g_iBeaconValidation 1;
bool g_bBeaconOn false;

Handle g_hPluginEnabled INVALID_HANDLE;
bool g_bPluginEnabled;

Handle g_hTagEnabled INVALID_HANDLE;
bool g_bTagEnabled;

Handle g_hMinimumBeacon INVALID_HANDLE;
int g_iMinimumBeacon;

Handle g_hPluginColor INVALID_HANDLE;
bool g_bPluginColor;

Handle g_hBeaconRadius INVALID_HANDLE;
float g_fBeaconRadius;

Handle g_hBeaconWidth INVALID_HANDLE;
float g_fBeaconWidth;

Handle g_hBeaconTimelimit INVALID_HANDLE;
float g_fBeaconTimelimit;

Handle g_hWarnPlayers INVALID_HANDLE;
bool g_bWarnPlayers;

int ga_iRedColor[4] = {2557575255};

public 
Plugin myinfo =
{
    
name "Hunger Games Beacon",
    
author "Headline",
    
description "Beacons players designed for Hunger Games",
    
version PLUGIN_VERSION
};

public 
void OnConfigsExecuted()
{
    if (
g_bTagEnabled)
    {
        
Handle hTags FindConVar("sv_tags");
        
char sTags[128];
        
GetConVarString(hTagssTagssizeof(sTags));
        
StrCat(sTagssizeof(sTags), ", Headline");
        
ServerCommand("sv_tags %s"sTags);
    }
}

public 
void OnPluginStart()
{
    
AutoExecConfig_SetFile("sm_beacon");
    
AutoExecConfig_SetCreateFile(true);

    
AutoExecConfig_CreateConVar("beacon_version""1.4""Headline's Beacon Plugin: Version"FCVAR_PLUGIN|FCVAR_NOTIFY);

    
g_hPluginEnabled AutoExecConfig_CreateConVar("sm_beacon_enabled""1""Enables and disables the beacon plugin"FCVAR_NOTIFYtrue0.0true1.0);
    
HookConVarChange(g_hPluginEnabledOnCVarChange);
    
g_bPluginEnabled GetConVarBool(g_hPluginEnabled);
    
    
g_hTagEnabled AutoExecConfig_CreateConVar("sm_tag_enabled""1""Allow \"Headline\" to be added to the server tags?"FCVAR_NOTIFYtrue0.0true1.0);
    
HookConVarChange(g_hTagEnabledOnCVarChange);
    
g_bTagEnabled GetConVarBool(g_hTagEnabled);

    
g_hMinimumBeacon AutoExecConfig_CreateConVar("sm_players_for_beacon""2""Sets the ammount of players for when the beacon should start"FCVAR_NOTIFYtrue0.0true32.0);
    
HookConVarChange(g_hMinimumBeaconOnCVarChange);
    
g_iMinimumBeacon GetConVarInt(g_hMinimumBeacon);

    
g_hPluginColor AutoExecConfig_CreateConVar("sm_beacon_color""1""Enables and disables the beacon plugin's chat colors"FCVAR_NOTIFYtrue0.0true1.0);
    
HookConVarChange(g_hPluginColorOnCVarChange);
    
g_bPluginColor GetConVarBool(g_hPluginColor);

    
g_hBeaconRadius AutoExecConfig_CreateConVar("sm_beacon_radius""750""Sets the radius for the beacon's rings."FCVAR_NOTIFYtrue50.0true1500.0);
    
HookConVarChange(g_hBeaconRadiusOnCVarChange);
    
g_fBeaconRadius GetConVarFloat(g_hBeaconRadius);

    
g_hBeaconWidth AutoExecConfig_CreateConVar("sm_beacon_width""10""Sets the thickness for the beacon's rings."FCVAR_NOTIFYtrue10.0true30.0);
    
HookConVarChange(g_hBeaconWidthOnCVarChange);
    
g_fBeaconWidth GetConVarFloat(g_hBeaconWidth);

    
g_hBeaconTimelimit AutoExecConfig_CreateConVar("sm_beacon_timelimit""0""Sets the amount of time (in seconds) until the beacon gets manually turned on (set to 0 to disable)"FCVAR_NOTIFYtrue0.0true600.0);
    
HookConVarChange(g_hBeaconTimelimitOnCVarChange);
    
g_fBeaconTimelimit GetConVarFloat(g_hBeaconTimelimit);

    
g_hWarnPlayers AutoExecConfig_CreateConVar("sm_warn_players""0""If it is = 1, players will be warned to not delay the round when beacons start"FCVAR_NOTIFYtrue0.0true1.0);
    
HookConVarChange(g_hWarnPlayersOnCVarChange);
    
g_bWarnPlayers GetConVarBool(g_hWarnPlayers);

    
AutoExecConfig_ExecuteFile();
    
AutoExecConfig_CleanFile();

    
HookEvent("player_death"Event_PlayerDeath);
    
HookEvent("round_end"Event_RoundEnd);
    
HookEvent("round_start"Event_RoundStart);
    
    
RegAdminCmd("sm_beaconall"Command_BeaconAllADMFLAG_GENERIC"Toggles beacon on all players");
    
RegAdminCmd("sm_stopbeacon"Command_StopBeaconADMFLAG_GENERIC"Toggles beacon on all players");
}

public 
void OnCVarChange(Handle hCVar, const char[] sOldValue, const char[] sNewValue)
{
    if(
hCVar == g_hPluginEnabled)
    {
        
g_bPluginEnabled GetConVarBool(g_hPluginEnabled);
    }
    if(
hCVar == g_hPluginColor)
    {
        
g_bPluginColor GetConVarBool(g_hPluginColor);
    }
    if(
hCVar == g_hBeaconRadius)
    {
        
g_fBeaconRadius GetConVarFloat(g_hBeaconRadius);
    }
    if(
hCVar == g_hBeaconTimelimit)
    {
        
g_fBeaconTimelimit GetConVarFloat(g_hBeaconTimelimit);
    }
    if(
hCVar == g_hMinimumBeacon)
    {
        
g_iMinimumBeacon GetConVarInt(g_hMinimumBeacon);
    }
    if(
hCVar == g_hWarnPlayers)
    {
        
g_bWarnPlayers GetConVarBool(g_hWarnPlayers);
    }
    if(
hCVar == g_hTagEnabled)
    {
        
g_bTagEnabled GetConVarBool(g_hTagEnabled);
    }
}

public 
void OnMapStart()
{
    
PrecacheSound(SOUND_BLIPtrue);
    
g_BeamSprite PrecacheModel("materials/sprites/bomb_planted_ring.vmt");
    
g_HaloSprite PrecacheModel("materials/sprites/halo.vtf");
    
g_iBeaconValidation 1;
}

public 
void OnClientDisconnected(int client)
{
    if (!
g_bPluginEnabled)
    {
        return;
    }
    
    if(
GetPlayerCount() == g_iMinimumBeacon)
    {
        
g_iBeaconValidation++;
        
CreateTimer(1.0BeaconAll_Callbackg_iBeaconValidationTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action Event_PlayerDeath(Handle hEvent, const char[] sNamebool bDontBroadcast)
{
    if (!
g_bPluginEnabled)
    {
        return 
Plugin_Continue;
    }
    if(
GetPlayerCount() == g_iMinimumBeacon)
    {
        if (
g_bWarnPlayers)
        {
            if (!
g_bPluginColor)
            {
                
PrintToChatAll("Reminder! Teaming while the beacons are on is prohibited!!!");
            }
            else
            {
                
CPrintToChatAll("Reminder! Teaming while the beacons are on is {PINK}prohibited!!!");
            }
        }
        
g_iBeaconValidation++;
        
CreateTimer(1.0BeaconAll_Callbackg_iBeaconValidationTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
    }
    return 
Plugin_Continue;
}

public 
Action Event_RoundStart(Handle hEvent, const char[] sNamebool bDontBroadcast)
{
    if (!
g_bPluginEnabled)
    {
        return 
Plugin_Continue;
    }
    
g_iBeaconValidation++;
    if (!
g_fBeaconTimelimit)
    {
        return 
Plugin_Continue;
    }
    
g_bBeaconOn false;
    
CreateTimer(g_fBeaconTimelimitbeacon_all_timelimitg_iBeaconValidationTIMER_FLAG_NO_MAPCHANGE);
    return 
Plugin_Continue;
}

public 
Action beacon_all_timelimit(Handle hTimerany iValidation)
{
    if(
g_iBeaconValidation == iValidation)
    {
        
g_iBeaconValidation++;
        
CreateTimer(1.0BeaconAll_Callbackg_iBeaconValidationTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action Event_RoundEnd(Handle hEvent, const char[] sNamebool bDontBroadcast)
{
    if (!
g_bPluginEnabled)
    {
        return 
Plugin_Continue;
    }
    
g_bBeaconOn false;
    
g_iBeaconValidation++;
    return 
Plugin_Continue;
}

public 
Action Command_StopBeacon(int clientint iArgs)
{
    if (
iArgs != 0)
    {
        
PrintToConsole(client"[SM] Usage : sm_stopbeacon");
    }
    if (!
g_bPluginEnabled)
    {
        
ReplyToCommand(client"Hunger Games Beacon is Disabled");
        return 
Plugin_Handled;
    }
    
g_iBeaconValidation++;
    
g_bBeaconOn false;
    if (!
g_bPluginColor)
    {
        
PrintToChatAll("[SM] %N toggled beacon OFF"client);
    }
    else
    {
        
CPrintToChatAll("[SM] {PINK}%N {NORMAL}toggled beacon {PINK}OFF"client);
    }
    return 
Plugin_Handled;
}

public 
Action Command_BeaconAll(int clientint iArgs)
 {
    if (
iArgs != 0)
    {
        
PrintToConsole(client"[SM] Usage : beaconall");
    }
    if (!
g_bPluginEnabled)
    {
        
ReplyToCommand(client"Hunger Games Beacon is Disabled");
        return 
Plugin_Handled;
    }
    if (!
g_bPluginColor)
    {
        
PrintToChatAll("[SM] %N toggled beacon ON"client);
    }
    else
    {
        
CPrintToChatAll("[SM] {PINK}%N {NORMAL}toggled beacon {PINK}ON"client);
    }
    if (
g_bBeaconOn)
    {
        
g_iBeaconValidation++;
        if (!
g_bPluginColor)
        {
            
PrintToChatAll("[SM] %N toggled beacon OFF"client);
        }
        else
        {
            
CPrintToChatAll("[SM] {PINK}%N {NORMAL}toggled beacon {PINK}OFF"client);
        }
    }
    
g_bBeaconOn true;
    
g_iBeaconValidation++;
    
CreateTimer(1.0BeaconAll_Callbackg_iBeaconValidationTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
    return 
Plugin_Handled;
}

public 
Action BeaconAll_Callback(Handle hTimerany iValidation)
{
    if(
iValidation != g_iBeaconValidation)
    {
        return 
Plugin_Stop;
    }
    for(
int i 1<= MaxClientsi++)
    {
        if (
IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) >= 2)
        {
            
float a_fOrigin[3];
            
GetClientAbsOrigin(ia_fOrigin);
            
a_fOrigin[2] += 10;
            
TE_SetupBeamRingPoint(a_fOrigin10.0g_fBeaconRadiusg_BeamSpriteg_HaloSprite0100.6g_fBeaconWidth0.5ga_iRedColor50);

            
TE_SendToAll();

            
GetClientEyePosition(ia_fOrigin);
            
EmitAmbientSound(SOUND_BLIPa_fOriginiSNDLEVEL_RAIDSIREN);
        }
    }
    return 
Plugin_Continue;
}

bool IsValidClient(int iClient)
{
    if(
iClient || iClient MaxClients || !IsClientConnected(iClient) || IsClientInKickQueue(iClient) || IsClientSourceTV(iClient))
    {
        return 
false;
    }
    else
    {
        return 
IsClientInGame(iClient);
    }
}

stock int GetPlayerCount()
{
    
int iPlayers;
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) >= 2)
        {
            
iPlayers++;
        }
    }
    return 
iPlayers;
}

/*    Changelog
    1.0 - Initial Release
    1.1 - Added CVAR sm_players_for_beacon
    1.2 - ThatOneGuy helped fix the issue where sm_beaconall would cause the beacons to happen twice.
    1.3 - Created a warning for when beacons come on and a CVAR to go with it. Also added a sv_tags with my name in it so I can see servers using this!
    1.4 - Updated plugin to 1.7 transitional syntax
*/ 

Last edited by headline; 08-02-2015 at 00:02.
headline is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 08-02-2015 , 01:24   Re: New API and Syntax
Reply With Quote #560

Quote:
Originally Posted by Headline22 View Post
Before I publish an update to my Beacon plugin, can you guys confirm to me that this is okay?
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <autoexecconfig>
#include <csgocolors>

#pragma semicolon 1

#pragma newdecls required

#define SOUND_BLIP "buttons/blip1.wav"
#define PLUGIN_VERSION "1.4"
 
int g_BeamSprite = -1;
int g_HaloSprite = -1;
int g_iBeaconValidation 1;
bool g_bBeaconOn false;

Handle g_hPluginEnabled INVALID_HANDLE;
bool g_bPluginEnabled;

Handle g_hTagEnabled INVALID_HANDLE;
bool g_bTagEnabled;

Handle g_hMinimumBeacon INVALID_HANDLE;
int g_iMinimumBeacon;

Handle g_hPluginColor INVALID_HANDLE;
bool g_bPluginColor;

Handle g_hBeaconRadius INVALID_HANDLE;
float g_fBeaconRadius;

Handle g_hBeaconWidth INVALID_HANDLE;
float g_fBeaconWidth;

Handle g_hBeaconTimelimit INVALID_HANDLE;
float g_fBeaconTimelimit;

Handle g_hWarnPlayers INVALID_HANDLE;
bool g_bWarnPlayers;

int ga_iRedColor[4] = {2557575255};

public 
Plugin myinfo =
{
    
name "Hunger Games Beacon",
    
author "Headline",
    
description "Beacons players designed for Hunger Games",
    
version PLUGIN_VERSION
};

public 
void OnConfigsExecuted()
{
    if (
g_bTagEnabled)
    {
        
Handle hTags FindConVar("sv_tags");
        
char sTags[128];
        
GetConVarString(hTagssTagssizeof(sTags));
        
StrCat(sTagssizeof(sTags), ", Headline");
        
ServerCommand("sv_tags %s"sTags);
    }
}

public 
void OnPluginStart()
{
    
AutoExecConfig_SetFile("sm_beacon");
    
AutoExecConfig_SetCreateFile(true);

    
AutoExecConfig_CreateConVar("beacon_version""1.4""Headline's Beacon Plugin: Version"FCVAR_PLUGIN|FCVAR_NOTIFY);

    
g_hPluginEnabled AutoExecConfig_CreateConVar("sm_beacon_enabled""1""Enables and disables the beacon plugin"FCVAR_NOTIFYtrue0.0true1.0);
    
HookConVarChange(g_hPluginEnabledOnCVarChange);
    
g_bPluginEnabled GetConVarBool(g_hPluginEnabled);
    
    
g_hTagEnabled AutoExecConfig_CreateConVar("sm_tag_enabled""1""Allow \"Headline\" to be added to the server tags?"FCVAR_NOTIFYtrue0.0true1.0);
    
HookConVarChange(g_hTagEnabledOnCVarChange);
    
g_bTagEnabled GetConVarBool(g_hTagEnabled);

    
g_hMinimumBeacon AutoExecConfig_CreateConVar("sm_players_for_beacon""2""Sets the ammount of players for when the beacon should start"FCVAR_NOTIFYtrue0.0true32.0);
    
HookConVarChange(g_hMinimumBeaconOnCVarChange);
    
g_iMinimumBeacon GetConVarInt(g_hMinimumBeacon);

    
g_hPluginColor AutoExecConfig_CreateConVar("sm_beacon_color""1""Enables and disables the beacon plugin's chat colors"FCVAR_NOTIFYtrue0.0true1.0);
    
HookConVarChange(g_hPluginColorOnCVarChange);
    
g_bPluginColor GetConVarBool(g_hPluginColor);

    
g_hBeaconRadius AutoExecConfig_CreateConVar("sm_beacon_radius""750""Sets the radius for the beacon's rings."FCVAR_NOTIFYtrue50.0true1500.0);
    
HookConVarChange(g_hBeaconRadiusOnCVarChange);
    
g_fBeaconRadius GetConVarFloat(g_hBeaconRadius);

    
g_hBeaconWidth AutoExecConfig_CreateConVar("sm_beacon_width""10""Sets the thickness for the beacon's rings."FCVAR_NOTIFYtrue10.0true30.0);
    
HookConVarChange(g_hBeaconWidthOnCVarChange);
    
g_fBeaconWidth GetConVarFloat(g_hBeaconWidth);

    
g_hBeaconTimelimit AutoExecConfig_CreateConVar("sm_beacon_timelimit""0""Sets the amount of time (in seconds) until the beacon gets manually turned on (set to 0 to disable)"FCVAR_NOTIFYtrue0.0true600.0);
    
HookConVarChange(g_hBeaconTimelimitOnCVarChange);
    
g_fBeaconTimelimit GetConVarFloat(g_hBeaconTimelimit);

    
g_hWarnPlayers AutoExecConfig_CreateConVar("sm_warn_players""0""If it is = 1, players will be warned to not delay the round when beacons start"FCVAR_NOTIFYtrue0.0true1.0);
    
HookConVarChange(g_hWarnPlayersOnCVarChange);
    
g_bWarnPlayers GetConVarBool(g_hWarnPlayers);

    
AutoExecConfig_ExecuteFile();
    
AutoExecConfig_CleanFile();

    
HookEvent("player_death"Event_PlayerDeath);
    
HookEvent("round_end"Event_RoundEnd);
    
HookEvent("round_start"Event_RoundStart);
    
    
RegAdminCmd("sm_beaconall"Command_BeaconAllADMFLAG_GENERIC"Toggles beacon on all players");
    
RegAdminCmd("sm_stopbeacon"Command_StopBeaconADMFLAG_GENERIC"Toggles beacon on all players");
}

public 
void OnCVarChange(Handle hCVar, const char[] sOldValue, const char[] sNewValue)
{
    if(
hCVar == g_hPluginEnabled)
    {
        
g_bPluginEnabled GetConVarBool(g_hPluginEnabled);
    }
    if(
hCVar == g_hPluginColor)
    {
        
g_bPluginColor GetConVarBool(g_hPluginColor);
    }
    if(
hCVar == g_hBeaconRadius)
    {
        
g_fBeaconRadius GetConVarFloat(g_hBeaconRadius);
    }
    if(
hCVar == g_hBeaconTimelimit)
    {
        
g_fBeaconTimelimit GetConVarFloat(g_hBeaconTimelimit);
    }
    if(
hCVar == g_hMinimumBeacon)
    {
        
g_iMinimumBeacon GetConVarInt(g_hMinimumBeacon);
    }
    if(
hCVar == g_hWarnPlayers)
    {
        
g_bWarnPlayers GetConVarBool(g_hWarnPlayers);
    }
    if(
hCVar == g_hTagEnabled)
    {
        
g_bTagEnabled GetConVarBool(g_hTagEnabled);
    }
}

public 
void OnMapStart()
{
    
PrecacheSound(SOUND_BLIPtrue);
    
g_BeamSprite PrecacheModel("materials/sprites/bomb_planted_ring.vmt");
    
g_HaloSprite PrecacheModel("materials/sprites/halo.vtf");
    
g_iBeaconValidation 1;
}

public 
void OnClientDisconnected(int client)
{
    if (!
g_bPluginEnabled)
    {
        return;
    }
    
    if(
GetPlayerCount() == g_iMinimumBeacon)
    {
        
g_iBeaconValidation++;
        
CreateTimer(1.0BeaconAll_Callbackg_iBeaconValidationTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action Event_PlayerDeath(Handle hEvent, const char[] sNamebool bDontBroadcast)
{
    if (!
g_bPluginEnabled)
    {
        return 
Plugin_Continue;
    }
    if(
GetPlayerCount() == g_iMinimumBeacon)
    {
        if (
g_bWarnPlayers)
        {
            if (!
g_bPluginColor)
            {
                
PrintToChatAll("Reminder! Teaming while the beacons are on is prohibited!!!");
            }
            else
            {
                
CPrintToChatAll("Reminder! Teaming while the beacons are on is {PINK}prohibited!!!");
            }
        }
        
g_iBeaconValidation++;
        
CreateTimer(1.0BeaconAll_Callbackg_iBeaconValidationTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
    }
    return 
Plugin_Continue;
}

public 
Action Event_RoundStart(Handle hEvent, const char[] sNamebool bDontBroadcast)
{
    if (!
g_bPluginEnabled)
    {
        return 
Plugin_Continue;
    }
    
g_iBeaconValidation++;
    if (!
g_fBeaconTimelimit)
    {
        return 
Plugin_Continue;
    }
    
g_bBeaconOn false;
    
CreateTimer(g_fBeaconTimelimitbeacon_all_timelimitg_iBeaconValidationTIMER_FLAG_NO_MAPCHANGE);
    return 
Plugin_Continue;
}

public 
Action beacon_all_timelimit(Handle hTimerany iValidation)
{
    if(
g_iBeaconValidation == iValidation)
    {
        
g_iBeaconValidation++;
        
CreateTimer(1.0BeaconAll_Callbackg_iBeaconValidationTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action Event_RoundEnd(Handle hEvent, const char[] sNamebool bDontBroadcast)
{
    if (!
g_bPluginEnabled)
    {
        return 
Plugin_Continue;
    }
    
g_bBeaconOn false;
    
g_iBeaconValidation++;
    return 
Plugin_Continue;
}

public 
Action Command_StopBeacon(int clientint iArgs)
{
    if (
iArgs != 0)
    {
        
PrintToConsole(client"[SM] Usage : sm_stopbeacon");
    }
    if (!
g_bPluginEnabled)
    {
        
ReplyToCommand(client"Hunger Games Beacon is Disabled");
        return 
Plugin_Handled;
    }
    
g_iBeaconValidation++;
    
g_bBeaconOn false;
    if (!
g_bPluginColor)
    {
        
PrintToChatAll("[SM] %N toggled beacon OFF"client);
    }
    else
    {
        
CPrintToChatAll("[SM] {PINK}%N {NORMAL}toggled beacon {PINK}OFF"client);
    }
    return 
Plugin_Handled;
}

public 
Action Command_BeaconAll(int clientint iArgs)
 {
    if (
iArgs != 0)
    {
        
PrintToConsole(client"[SM] Usage : beaconall");
    }
    if (!
g_bPluginEnabled)
    {
        
ReplyToCommand(client"Hunger Games Beacon is Disabled");
        return 
Plugin_Handled;
    }
    if (!
g_bPluginColor)
    {
        
PrintToChatAll("[SM] %N toggled beacon ON"client);
    }
    else
    {
        
CPrintToChatAll("[SM] {PINK}%N {NORMAL}toggled beacon {PINK}ON"client);
    }
    if (
g_bBeaconOn)
    {
        
g_iBeaconValidation++;
        if (!
g_bPluginColor)
        {
            
PrintToChatAll("[SM] %N toggled beacon OFF"client);
        }
        else
        {
            
CPrintToChatAll("[SM] {PINK}%N {NORMAL}toggled beacon {PINK}OFF"client);
        }
    }
    
g_bBeaconOn true;
    
g_iBeaconValidation++;
    
CreateTimer(1.0BeaconAll_Callbackg_iBeaconValidationTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
    return 
Plugin_Handled;
}

public 
Action BeaconAll_Callback(Handle hTimerany iValidation)
{
    if(
iValidation != g_iBeaconValidation)
    {
        return 
Plugin_Stop;
    }
    for(
int i 1<= MaxClientsi++)
    {
        if (
IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) >= 2)
        {
            
float a_fOrigin[3];
            
GetClientAbsOrigin(ia_fOrigin);
            
a_fOrigin[2] += 10;
            
TE_SetupBeamRingPoint(a_fOrigin10.0g_fBeaconRadiusg_BeamSpriteg_HaloSprite0100.6g_fBeaconWidth0.5ga_iRedColor50);

            
TE_SendToAll();

            
GetClientEyePosition(ia_fOrigin);
            
EmitAmbientSound(SOUND_BLIPa_fOriginiSNDLEVEL_RAIDSIREN);
        }
    }
    return 
Plugin_Continue;
}

bool IsValidClient(int iClient)
{
    if(
iClient || iClient MaxClients || !IsClientConnected(iClient) || IsClientInKickQueue(iClient) || IsClientSourceTV(iClient))
    {
        return 
false;
    }
    else
    {
        return 
IsClientInGame(iClient);
    }
}

stock int GetPlayerCount()
{
    
int iPlayers;
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) >= 2)
        {
            
iPlayers++;
        }
    }
    return 
iPlayers;
}

/*    Changelog
    1.0 - Initial Release
    1.1 - Added CVAR sm_players_for_beacon
    1.2 - ThatOneGuy helped fix the issue where sm_beaconall would cause the beacons to happen twice.
    1.3 - Created a warning for when beacons come on and a CVAR to go with it. Also added a sv_tags with my name in it so I can see servers using this!
    1.4 - Updated plugin to 1.7 transitional syntax
*/ 

All fine but it's easier to put Handles to "null" instead of INVALID_HANDLE
__________________
nergal 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 05:51.


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