how can I create something like both teams has a total timer of 300sec each they can type !pause to pause the match for 300 second but if they type !unpause before the time it will get stored and they can again use the !pause until the time finish for their team. How can I achieve this?
if anyone can help that will be great.
i m new to sourcepawn/programming ignore my mistakes.
HTML Code:
int timertimeT = 0;
int timertimeCT = 0;
bool Ttime = false;
bool CTtime = false;
public void OnPluginStart() {
RegConsoleCmd("sm_pause", Command_Pause, "Requests a pause");
RegConsoleCmd("sm_unpause", Command_Unpause, "Requests an unpause");
}
public Action Command_Pause(int client, int args) {
if(GetClientTeam(client)==2){
if(timertimeT>=5){
PrintToChatAll("Terrorist has No Timeout Left.");
return Plugin_Stop;
}
CreateTimer(1.0, PauseTimerTCheck, _, TIMER_REPEAT);
ServerCommand("mp_pause_match");
PrintToChatAll("Terrorist has requested a pause.");
return Plugin_Handled;
}
if(GetClientTeam(client)==3){
if(timertimeCT>=5){
PrintToChatAll("Counter Terrorist has No Timeout Left.");
return Plugin_Stop;
}
CreateTimer(1.0, PauseTimerCTCheck, _, TIMER_REPEAT);
ServerCommand("mp_pause_match");
PrintToChatAll("CT has requested a pause.");
return Plugin_Handled;
}
return Plugin_Handled;
}
public Action Command_Unpause(int client, int args) {
if(GetClientTeam(client)==2){
}
if(GetClientTeam(client)==3){
}
return Plugin_Handled;
}
public Action PauseTimerTCheck(Handle timer){
if (GameRules_GetProp("m_bFreezePeriod") != 0)
{
CreateTimer(60.0, PauseTimerT, _, TIMER_REPEAT);
}
}
public Action PauseTimerCTCheck(Handle timer){
if (GameRules_GetProp("m_bFreezePeriod") != 0)
{
CreateTimer(60.0, PauseTimerCT, _, TIMER_REPEAT);
}
}
public Action PauseTimerT(Handle timer){
if(Ttime){
return Plugin_Stop;
}
timertimeT++;
if(timertimeT>=5){
Ttime = true;
ServerCommand("mp_unpause_match");
PrintToChatAll("Terrorist Timeout Has Ended.");
return Plugin_Handled;
}
else if(timertimeT==4){
PrintToChatAll("Terrorist 1 Minute Left.");
}
else if(timertimeT==3){
PrintToChatAll("Terrorist 2 Minute Left.");
}
else if(timertimeT==2){
PrintToChatAll("Terrorist 3 Minute Left.");
}
else if(timertimeT==1){
PrintToChatAll("Terrorist 4 Minute Left.");
}
return Plugin_Continue;
}
public Action PauseTimerCT(Handle timer){
if(CTtime){
return Plugin_Stop;
}
timertimeCT++;
if(timertimeCT<=5){
CTtime = true;
ServerCommand("mp_unpause_match");
PrintToChatAll("Counter Terrorist Timeout Has Ended.");
return Plugin_Handled;
}
else if(timertimeCT==4){
PrintToChatAll("Counter Terrorist 1 Minute Left.");
}
else if(timertimeCT==3){
PrintToChatAll("Counter Terrorist 2 Minute Left.");
}
else if(timertimeCT==2){
PrintToChatAll("Counter Terrorist 3 Minute Left.");
}
else if(timertimeCT==1){
PrintToChatAll("Counter Terrorist 4 Minute Left.");
}
return Plugin_Continue;
}