PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdkhooks>
#include <multicolors>
bool NoZoom, DisabledBhop, SpecialRound, MapWithRounds;
int m_flNextSecondaryAttack;
public void OnPluginStart()
{
HookEvent("round_prestart", RoundStart);
HookEvent("round_end", RoundEnd);
m_flNextSecondaryAttack = FindSendPropInfo("CBaseCombatWeapon", "m_flNextSecondaryAttack");
}
public void OnMapStart()
{
char g_CurrentMap[128];
GetCurrentMap(g_CurrentMap, sizeof(g_CurrentMap));
if (StrEqual(g_CurrentMap, "mg_awp_multigames_csgo", true))
{
MapWithRounds = true;
}
else
{
MapWithRounds = false;
}
}
public Action RoundStart(Event event, const char[] name, bool dontBroadcast)
{
if(!MapWithRounds)
{
return Plugin_Handled;
}
static int roundcount;
if(++roundcount >= 5)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
CPrintToChatAll("[{lightred}Server{default}] <{green}SPECIAL ROUND{default}> now choosing.");
roundcount = 0;
SpecialRound = true;
switch(GetRandomInt(1, 3))
{
case 1:
{
SDKHook(client, SDKHook_PreThink, OnPreThink);
CPrintToChatAll("[{lightred}Server{default}] <{green}SPECIAL ROUND{default}> zooming is {lighred}disabled {default}for this round.");
NoZoom = true;
}
case 2:
{
Handle bhop = FindConVar("abner_bhop_autobhop");
CPrintToChatAll("[{lightred}Server{default}] <{green}SPECIAL ROUND{default}> auto bunny-hop is {lighred}disabled {default}for this round.");
DisabledBhop = true;
SetConVarInt(bhop, 0, true, false);
delete bhop;
}
case 3:
{
SDKHook(client, SDKHook_PreThink, OnPreThink);
Handle bhop = FindConVar("abner_bhop_autobhop");
CPrintToChatAll("[{lightred}Server{default}] <{green}SPECIAL ROUND{default}> auto bunny-hop and zooming are both {lighred}disabled {default}for this round.");
NoZoom = true;
DisabledBhop = true;
SetConVarInt(bhop, 0, true, false);
delete bhop;
}
}
}
return Plugin_Continue;
}
public void RoundEnd(Event event, const char[] name, bool dontBroadcast)
{
if (SpecialRound)
{
if(DisabledBhop)
{
Handle bhopcvar = FindConVar("abner_bhop_autobhop");
SetConVarInt(bhopcvar, 1, true, false);
DisabledBhop = false;
delete bhopcvar;
}
for (int i = 1; i <= MaxClients; i++) if (IsClientInGame(i))
{
if(NoZoom)
{
SDKUnhook(i, SDKHook_PreThink, OnPreThink);
NoZoom = false;
}
}
SpecialRound = false;
CPrintToChatAll("[{lightred}Server{default}] The special round is now over. The next one will be in {green}5 {default}rounds.");
}
}
void MakeNoScope(int weapon)
{
if (NoZoom)
{
return;
}
if (!IsValidEdict(weapon))
{
return;
}
char classname[MAX_NAME_LENGTH];
if (GetEdictClassname(weapon, classname, sizeof(classname)))
{
SetEntDataFloat(weapon, m_flNextSecondaryAttack, GetGameTime() + 1.0);
}
}
public Action OnPreThink(int client)
{
int iWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
MakeNoScope(iWeapon);
return Plugin_Continue;
}
I tried this way, but I get:
PHP Code:
L 01/26/2018 - 10:55:30: Info (map "mg_awp_multigames_csgo") (file "errors_20180126.log")
L 01/26/2018 - 10:55:30: [SM] Exception reported: Hook type not valid for this type of entity (0/worldspawn)
L 01/26/2018 - 10:55:30: [SM] Blaming: minigamesplugins/a_specialround.smx
L 01/26/2018 - 10:55:30: [SM] Call stack trace:
L 01/26/2018 - 10:55:30: [SM] [0] SDKHook
L 01/26/2018 - 10:55:30: [SM] [1] Line 50, D:\Sourcemod Plugins\a_specialround.sp::RoundStart
L 01/26/2018 - 10:58:39: [SM] Exception reported: Hook type not valid for this type of entity (0/worldspawn)
L 01/26/2018 - 10:58:39: [SM] Blaming: minigamesplugins/a_specialround.smx
L 01/26/2018 - 10:58:39: [SM] Call stack trace:
L 01/26/2018 - 10:58:39: [SM] [0] SDKHook
L 01/26/2018 - 10:58:39: [SM] [1] Line 64, D:\Sourcemod Plugins\a_specialround.sp::RoundStart
__________________