Skip to content

Instantly share code, notes, and snippets.

@shavitush
Created August 17, 2016 14:37
Show Gist options
  • Save shavitush/3ad894d899b44287a99372baed6642b0 to your computer and use it in GitHub Desktop.
Save shavitush/3ad894d899b44287a99372baed6642b0 to your computer and use it in GitHub Desktop.
standup_core_ljmode with bhoptimer support
#include <sourcemod>
#include <standup/stocks_chat>
#include <standup/core>
#include <standup/ljmode>
#define USES_STYLE_PROPERTIES
#include <shavit>
#pragma semicolon 1
#pragma newdecls required
Handle g_hForward_OnStatsEnable;
public Plugin myinfo =
{
author = PLUGIN_AUTHOR_CORE,
url = PLUGIN_URL_CORE,
name = PLUGIN_NAME_CORE..." - Core | LJ mode",
description = "",
version = "1.0"
};
public APLRes AskPluginLoad2( Handle hPlugin, bool late, char[] szError, int error_len )
{
// LIBRARIES
RegPluginLibrary( LIBRARY_CORE_LJMODE );
return APLRes_Success;
}
public void OnPluginStart()
{
// NATIVES
g_hForward_OnStatsEnable = CreateGlobalForward( "Standup_OnStatsEnable", ET_Hook, Param_Cell, Param_String, Param_Cell );
// CMDS
RegConsoleCmd( "sm_lj", Command_ToggleLJ, "Toggle LJ stats." );
}
public Action Command_ToggleLJ( int client, int args )
{
if ( !client ) return Plugin_Handled;
if ( Standup_IsClientStatsEnabled( client ) )
{
Standup_SetClientStats( client, false );
SU_PrintToChat( client, client, SU_PRE_CHAT..."LJ Stats: "...CLR_TEAM..."OFF" );
return Plugin_Handled;
}
Action result;
static char szMsg[256];
strcopy( szMsg, sizeof( szMsg ), "Sorry, you cannot enable LJ stats!" );
Call_StartForward( g_hForward_OnStatsEnable );
Call_PushCell( client );
Call_PushStringEx( szMsg, sizeof( szMsg ), 0, SM_PARAM_COPYBACK );
Call_PushCell( sizeof( szMsg ) );
int error = Call_Finish( result );
if ( error != SP_ERROR_NONE ) return Plugin_Handled;
BhopStyle style = Shavit_GetBhopStyle(client);
if(gI_StyleProperties[style] & STYLE_EASYBHOP || gI_StyleProperties[style] & STYLE_AUTOBHOP || !(gI_StyleProperties[style] & STYLE_100AA) || gI_StyleProperties[style] & STYLE_LOWGRAV || gI_StyleProperties[style] & STYLE_SLOWMO)
{
result = Plugin_Handled;
strcopy(szMsg, 256, "You cannot use ljstats on styles that allow either: easybhop, autobhop, over 100aa, low gravity or slow motion.");
}
if ( result == Plugin_Continue )
{
Standup_SetClientStats( client, true );
SU_PrintToChat( client, client, SU_PRE_CHAT..."LJ Stats: "...CLR_TEAM..."ON" );
}
else
{
SU_PrintToChat( client, client, SU_PRE_CHAT..."%s", szMsg );
}
return Plugin_Handled;
}
public void Shavit_OnStyleChanged(int client, BhopStyle oldstyle, BhopStyle newstyle)
{
if(gI_StyleProperties[newstyle] & STYLE_EASYBHOP || gI_StyleProperties[newstyle] & STYLE_AUTOBHOP || !(gI_StyleProperties[newstyle] & STYLE_100AA) || gI_StyleProperties[newstyle] & STYLE_LOWGRAV || gI_StyleProperties[newstyle] & STYLE_SLOWMO)
{
Standup_SetClientStats(client, false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment