View Single Post
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-11-2018 , 22:18   Re: Objective Reset + Timer Control [V 0.1]
Reply With Quote #6

I did a little work using one feature (SetRoundTime):

PHP Code:
#include <amxmodx>
#include <objective_reset>

#define PLUGIN        "Pause Round"
#define VERSION     "1.0"
#define AUTHOR         "author"

#define TASK_PAUSE    2301031

new bool:g_bPausedbool:g_bPauseAskedg_bIsFreezeTime
new g_iPauses[2], g_iLastPause[2], g_iTeamg_iCountDown
new pCvarPauseTimepCvarMaxPausespCvarPauseDelay

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
pCvarMaxPauses register_cvar("pause_maxpauses_perteam""3")
    
pCvarPauseTime register_cvar("pause_pausetime""60")
    
pCvarPauseDelay register_cvar("pause_pausedelay""120")
    
    
register_logevent("RoundStart"2"1=Round_Start")  
    
register_event("HLTV""NewRound""a""1=0""2=0")  
    
    
register_clcmd("say /pause""cmdPause")
    
register_clcmd("say /unpause""cmdUnpause")
}

public 
RoundStart()
{
    
g_bIsFreezeTime false
}

public 
NewRound()
{
    
g_bIsFreezeTime true
    
if(g_bPauseAsked)
    {
        
pauseGame()
    }
}

public 
cmdPause(id)
{
    new 
iUserTeam get_user_team(id), iTeam = (iUserTeam 1)
    if(
iUserTeam >= 3)
    {
        
client_print(idprint_chat"[AMXX]: You cannot use this command while spectating.")
        return 
PLUGIN_HANDLED
    
}

    if(
g_bPaused)
    {
        
client_print(idprint_chat"[AMXX]: The game is already paused.")
        return 
PLUGIN_HANDLED
    
}
    
    if(
g_bPauseAsked)
    {
        
client_print(idprint_chat"[AMXX]: The %s already asked the pause."g_iTeam "Counter-Terrorists" "Terrorists")
        return 
PLUGIN_HANDLED
    
}
    
    if(
g_iPauses[(g_iTeam iTeam)] == get_pcvar_num(pCvarMaxPauses))
    {
        
client_print(idprint_chat"[AMXX]: Your team cannot pause anymore.")
        return 
PLUGIN_HANDLED
    
}

    new 
iSystime get_systime()
    if(
iSystime g_iLastPause[iTeam])
    {
        new 
iMath = (g_iLastPause[iTeam] - iSystime)
        if(
iMath get_pcvar_num(pCvarPauseDelay))
        {
            
client_print(idprint_chat"[AMXX]: Your team must wait %d second%s to ask a pause again."iMath, (iMath 1) ? "s" "")
            return 
PLUGIN_HANDLED
        
}
    }
    
    new 
szName[32]
    
get_user_name(idszNamecharsmax(szName))
    
client_print(idprint_chat"[AMXX]: Player %s wants to pause the game."szName)

    
g_bPauseAsked true
    
if(g_bIsFreezeTime)
    {
        
pauseGame()
    }
    else
    {
        
client_print(idprint_chat"[AMXX]: The game will be paused during the freezetime.")
    }
    
    return 
PLUGIN_HANDLED
}

public 
cmdUnpause(id)
{
    if(
get_user_team(id) > 2)
    {
        
client_print(idprint_chat"[AMXX]: You cannot use this command while spectating.")
        return 
PLUGIN_HANDLED
    
}

    if(!
g_bPaused)
    {
        
client_print(idprint_chat"[AMXX]: The game is not paused.")
        return 
PLUGIN_HANDLED
    
}
    
    new 
szName[32]
    
get_user_name(idszNamecharsmax(szName))
    
client_print(idprint_chat"[AMXX]: Player %s unpaused the game."szName)

    
unpauseGame()
    return 
PLUGIN_HANDLED
}

pauseGame()
{
    new 
iCvarPauseTime get_pcvar_num(pCvarPauseTime), iCvarMaxPauses get_pcvar_num(pCvarMaxPauses)
    
    
g_bPaused true
    g_bPauseAsked 
false
    g_iPauses
[g_iTeam]++
    
g_iCountDown iCvarPauseTime

    
new szTeam[19];szTeam g_iTeam "Counter-Terrorists" "Terrorists"
    
    
client_print(0print_chat"[AMXX]: Game paused by %s."szTeam)
    
    new 
szMessage[32]
    if(
g_iPauses[g_iTeam] < iCvarMaxPauses)
    {
        
formatex(szMessagecharsmax(szMessage), "They still have %d pauses left.", (iCvarMaxPauses g_iPauses[g_iTeam]))
    }
    else
    {
        
formatex(szMessagecharsmax(szMessage), "They have not pauses to ask anymore.")
    }
    
client_print(0print_chat"[AMXX]: %s"szMessage)
    
client_print(0print_chat"[AMXX]: The %s have %d second%s to unpause the game."szTeamiCvarPauseTime, (iCvarPauseTime 1) ? "s" "")
    
    
set_task(1.0"setPause"TASK_PAUSE, .flags "b")
}

unpauseGame()
{
    
g_iLastPause[g_iTeam] = get_systime() + get_pcvar_num(pCvarPauseDelay)
    
g_bPaused false
    g_iTeam 
0
    g_iCountDown 
0
    remove_task
(TASK_PAUSE)
}

public 
setPause()
{
    
set_hudmessage(255255255, -1.00.301.01.0)
    
show_hudmessage(0"GAME PAUSED")
    
    
SetRoundTime(11)
    
    new 
szTeam[19];szTeam g_iTeam "Counter-Terrorists" "Terrorists"
    
if(g_iCountDown == (get_pcvar_num(pCvarPauseTime) / 2))
    {
        
client_print(0print_chat"[AMXX]: The %s team have %d seconds left to unpause."szTeam, (get_pcvar_num(pCvarPauseTime) / 2))
    }
    else if(
g_iCountDown == 0)
    {
        
unpauseGame()
        
client_print(0print_chat"[AMXX]: The %s team pause time has ended."szTeam)
    }
    
    
g_iCountDown--

Basically, it's a Pause command, usefull for Pug.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 01-12-2018 at 07:39.
EFFx is offline