I want to cprinttochatall When Countdown started and countdown finished
Thanks for Helpers!! +Rep
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <morecolors>
int Minutes,
Seconds,
TimerTime,
SecondCounter = 0;
char TimerResult[128],
arg1[32],
arg2[32];
bool TimerRunning;
public void OnPluginStart()
{
RegAdminCmd("sm_timer", Command_SetTimer, ADMFLAG_SLAY, "Set a timer countdown.");
}
public Action Command_SetTimer(client, args)
{
if (args < 2 || args > 3) {
ReplyToCommand(client, "[FZG] Usage: sm_timer <minutes> <seconds> (<timer result>)");
return Plugin_Handled;
}
if (TimerRunning == false) { //check if timer aint running
TimerRunning = true;
}
else {
ReplyToCommand(client, "[FZG] Timer is already running, so you can't start a new one.");
return Plugin_Handled;
}
GetCmdArg(1, arg1, sizeof(arg1));
GetCmdArg(2, arg2, sizeof(arg2));
GetCmdArg(3, TimerResult, sizeof(TimerResult));
Minutes = StringToInt(arg1);
Seconds = StringToInt(arg2);
if (Seconds > 60 || Seconds < 0 || Minutes < 0 || Minutes > 60) {
ReplyToCommand(client, "[FZG] Seconds and Minutes must be an intiger value between 0 and 60");
return Plugin_Handled;
}
TimerTime = Seconds + (Minutes * 60);
CreateTimer(1.0, Timer_ShowTimeLeft, _, TIMER_REPEAT);
return Plugin_Handled;
}
public Action Timer_ShowTimeLeft(Handle timer)
{
if (SecondCounter >= TimerTime) {
SecondCounter = 0;
PrintToChatAll("%s", TimerResult); // print whatever stored in arg 3, when timer is done
TimerRunning = false; // set to false for new timer to be ready for use
return Plugin_Stop;
}
if (Minutes > 0 && Seconds < 1) {
Minutes--;
Seconds = 60;
}
PrintCenterTextAll("Minutes: %d | Seconds: %d", Minutes, Seconds);
SecondCounter++;
Seconds--;
return Plugin_Continue;
}
__________________