View Single Post
Cruze
Veteran Member
Join Date: May 2017
Old 03-26-2021 , 05:09   Re: [REQ] Disable AWP for 2 rounds
Reply With Quote #2

Untested.

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

#pragma semicolon 1
#pragma newdecls required

int g_Round;

public 
void OnPluginStart()
{
    
HookEvent("round_start"OnRoundStart);
    
HookUserMessage(GetUserMessageId("TextMsg"), TextMsgHook);
}

public 
void OnMapStart()
{
    
g_Round 0;
}

public 
Action CS_OnBuyCommand(int client, const char[] weapon)
{
    if (
GameRules_GetProp("m_bWarmupPeriod") == || g_Round 3
    {
        return 
Plugin_Continue;
    }
    if(
StrContains(weapon"awp"false) != -|| StrContains(weapon"scar20"false) != -|| StrContains(weapon"g3sg1"false) != -1)
    {
        return 
Plugin_Handled;
    }
    return 
Plugin_Continue;
}

public 
void OnRoundStart(Event hEvent, const char[] sNamebool dontBroadcast)
{
    if(
GameRules_GetProp("m_bWarmupPeriod") == 0
    { 
        
g_Round++;
    }
}

public 
Action TextMsgHook(UserMsg umIdHandle hMsg, const int[] iPlayersint iPlayersNumbool bReliablebool bInit)
{
    
//Thank you SM9(); for this!!
    
char name[128], szValue[128]; 
    
PbReadString(hMsg"params"szValuesizeof(szValue), 1);
    
PbReadString(hMsg"params"namesizeof(name), 0);   
    if (
StrEqual(name"#SFUI_Notice_Game_will_restart_in"false)) 
    {
        
CreateTimer(StringToFloat(szValue), Timer_GameRestarted);
    }
    return 
Plugin_Continue;
}

public 
Action Timer_GameRestarted(Handle hTimer)
{
    
g_Round 1;

Attached Files
File Type: sp Get Plugin or Get Source (ahelpplugin.sp - 32 views - 1.4 KB)
__________________
Taking paid private requests! Contact me
Cruze is offline