Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //==============================================================================
- //==============================================================================
- //
- // mascii's countdown &
- // countup timers v3(UPDATED)
- //
- //==============================================================================
- //==============================================================================
- //==============================================================================
- // Includes
- //==============================================================================
- #include "a_samp"
- //==============================================================================
- // Defines
- //==============================================================================
- #define FILTERSCRIPT
- #define COLOR_GREY 0xAFAFAFAA
- //==============================================================================
- // New
- //==============================================================================
- new Menu:MainMenu;
- new Menu:CountUp;
- new Menu:CountDownPos;
- new Menu:CountDownTime;
- new CountDownMinutes;
- new CountDownSeconds;
- new CountUpSeconds;
- new CountUpMinutes;
- new Counting;
- // 0=false
- // 1=true
- new Text:Pos1;// bottom
- new Text:Pos2;// top
- new Pos;
- // 0=bottom
- // 1=top
- //==============================================================================
- // Forwards
- //==============================================================================
- forward CountUpTimer();
- forward CountDownTimer();
- forward CountDownFinish();
- //==============================================================================
- // OnFilterScriptInit()
- //==============================================================================
- public OnFilterScriptInit()
- {
- MainMenu = CreateMenu("Main Menu", 1, 200, 150, 240, 0.0);
- AddMenuItem(MainMenu, 0, "Count Up");
- AddMenuItem(MainMenu, 0, "Count Down");
- AddMenuItem(MainMenu, 0, "Stop Count");
- AddMenuItem(MainMenu, 0, "Exit");
- CountUp = CreateMenu("Count Up", 1, 200, 150, 240, 0.0);
- AddMenuItem(CountUp, 0, "Position 1");
- AddMenuItem(CountUp, 0, "Position 2");
- AddMenuItem(CountUp, 0, "Main Menu");
- CountDownPos = CreateMenu("Count Down Pos", 1, 200, 150, 240, 0.0);
- AddMenuItem(CountDownPos, 0, "Position 1");
- AddMenuItem(CountDownPos, 0, "Position 2");
- AddMenuItem(CountDownPos, 0, "Main Menu");
- CountDownTime = CreateMenu("Count Down Time", 1, 200, 150, 240, 0.0);
- AddMenuItem(CountDownTime, 0, "5 min");
- AddMenuItem(CountDownTime, 0, "10 min");
- AddMenuItem(CountDownTime, 0, "20 min");
- AddMenuItem(CountDownTime, 0, "30 min");
- AddMenuItem(CountDownTime, 0, "60 min");
- AddMenuItem(CountDownTime, 0, "Main Menu");
- Pos1 = TextDrawCreate(324.000000,412.000000," "); //bottom
- Pos2 = TextDrawCreate(324.000000,23.000000," "); //top
- TextDrawAlignment(Pos1,2);
- TextDrawAlignment(Pos2,2);
- TextDrawBackgroundColor(Pos1,0x000000ff);
- TextDrawBackgroundColor(Pos2,0x000000ff);
- TextDrawFont(Pos1,3);
- TextDrawLetterSize(Pos1,0.399999,1.400000);
- TextDrawFont(Pos2,3);
- TextDrawLetterSize(Pos2,0.399999,1.400000);
- TextDrawColor(Pos1,0xffffffff);
- TextDrawColor(Pos2,0xffffffff);
- TextDrawSetOutline(Pos1,1);
- TextDrawSetOutline(Pos2,1);
- TextDrawSetProportional(Pos1,1);
- TextDrawSetProportional(Pos2,1);
- TextDrawSetShadow(Pos1,1);
- TextDrawSetShadow(Pos2,1);
- CountDownMinutes = 0; //in minutes
- CountDownSeconds = 0; //in seconds
- CountUpSeconds = 0;
- CountUpMinutes = 0;
- Counting = 0;
- Pos = 0;
- return 1;
- }
- //==============================================================================
- // OnFilterScriptExit()
- //==============================================================================
- public OnFilterScriptExit()
- {
- TextDrawDestroy(Pos1);
- TextDrawDestroy(Pos2);
- DestroyMenu(MainMenu);
- DestroyMenu(CountUp);
- DestroyMenu(CountDownPos);
- DestroyMenu(CountDownTime);
- return 1;
- }
- //==============================================================================
- // CountUpTimer()
- //==============================================================================
- public CountUpTimer()
- {
- if (Pos == 0)
- {
- if (Counting == 1)
- {
- CountUpSeconds++;
- if (CountUpSeconds == 60)
- {
- CountUpSeconds = 0;
- CountUpMinutes++;
- }
- new string[256];
- format(string, sizeof(string), "%d:%d", CountUpMinutes, CountUpSeconds);
- TextDrawSetString(Text:Pos1, string);
- SetTimer("CountUpTimer", 1000, 0);
- }
- }
- if (Pos == 1)
- {
- if (Counting == 1)
- {
- CountUpSeconds++;
- if (CountUpSeconds == 60)
- {
- CountUpSeconds = 0;
- CountUpMinutes++;
- }
- new string2[256];
- format(string2, sizeof(string2), "%d:%d", CountUpMinutes, CountUpSeconds);
- TextDrawSetString(Text:Pos2, string2);
- SetTimer("CountUpTimer", 1000, 0);
- }
- }
- return 1;
- }
- //==============================================================================
- // CountDownTimer()
- //==============================================================================
- public CountDownTimer()
- {
- if (Pos == 0)
- {
- if (Counting == 1)
- {
- CountDownSeconds--;
- if (CountDownSeconds == 0)
- {
- CountDownSeconds = 60;
- if (CountDownMinutes == 0)
- {
- Counting = 0;
- TextDrawHideForAll(Pos1);
- SetTimer("CountDownFinish", 500, 0);
- }
- CountDownMinutes--;
- }
- new string[256];
- format(string, sizeof(string), "%d:%d", CountDownMinutes, CountDownSeconds);
- TextDrawSetString(Text:Pos1, string);
- SetTimer("CountDownTimer", 1000, 0);
- }
- }
- if (Pos == 1)
- {
- if (Counting == 1)
- {
- CountDownSeconds--;
- if (CountDownSeconds == 0)
- {
- CountDownSeconds = 60;
- if (CountDownMinutes == 0)
- {
- Counting = 0;
- TextDrawHideForAll(Pos2);
- SetTimer("CountDownFinish", 500, 0);
- }
- CountDownMinutes--;
- }
- new string2[256];
- format(string2, sizeof(string2), "%d:%d", CountDownMinutes, CountDownSeconds);
- TextDrawSetString(Text:Pos2, string2);
- SetTimer("CountDownTimer", 1000, 0);
- }
- }
- return 1;
- }
- //==============================================================================
- // CountDownFinish()
- //==============================================================================
- public CountDownFinish()
- {
- // do somthing here if you want
- // eg
- // SetGravity(0.008)
- SendClientMessageToAll(COLOR_GREY, "Times up!");
- return 1;
- }
- //==============================================================================
- // OnPlayerSelectedMenuRow(playerid, row)
- //==============================================================================
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- new Menu:Current;
- Current = GetPlayerMenu(playerid);
- if(Current == MainMenu)
- {
- switch(row)
- {
- case 0:
- {
- if (Counting == 1)
- {
- SendClientMessage(playerid, COLOR_GREY, "A count is already in progress.");
- ShowMenuForPlayer(MainMenu, playerid);
- }
- if (Counting == 0)
- {
- ShowMenuForPlayer(CountUp, playerid);
- }
- }
- case 1:
- {
- if (Counting == 1)
- {
- SendClientMessage(playerid, COLOR_GREY, "A count is already in progress.");
- ShowMenuForPlayer(MainMenu, playerid);
- }
- if (Counting == 0)
- {
- ShowMenuForPlayer(CountDownPos, playerid);
- }
- }
- case 2:
- {
- if (Counting == 0)
- {
- SendClientMessage(playerid, COLOR_GREY, "No count in progress.");
- ShowMenuForPlayer(MainMenu, playerid);
- }
- if (Counting == 1)
- {
- CountDownMinutes = 0; //in minutes
- CountDownSeconds = 0; //in seconds
- CountUpSeconds = 0;
- CountUpMinutes = 0;
- Counting = 0;
- TextDrawHideForAll(Pos1);
- TextDrawHideForAll(Pos2);
- SendClientMessageToAll(COLOR_GREY, "Admin: Count Cancelled!");
- new string[256];
- format(string, sizeof(string), " ");
- TextDrawSetString(Text:Pos1, string);
- new string2[256];
- format(string2, sizeof(string2), " ");
- TextDrawSetString(Text:Pos2, string2);
- ShowMenuForPlayer(MainMenu, playerid);
- }
- }
- case 3:
- {
- TogglePlayerControllable(playerid, 1);
- }
- }
- }
- if(Current == CountUp)
- {
- switch(row)
- {
- case 0:
- {
- Counting = 1;
- CountUpSeconds = 0;
- CountUpMinutes = 0;
- Pos = 0; // bottom
- TextDrawShowForAll(Pos1); // bottom
- SetTimer("CountUpTimer", 1000, 0);
- SendClientMessageToAll(COLOR_GREY, "Admin: Count Started!");
- ShowMenuForPlayer(MainMenu, playerid);
- }
- case 1:
- {
- Counting = 1;
- CountUpSeconds = 0;
- CountUpMinutes = 0;
- Pos = 1; // top
- TextDrawShowForAll(Pos2); // top
- SetTimer("CountUpTimer", 1000, 0);
- SendClientMessageToAll(COLOR_GREY, "Admin: Count Started!");
- ShowMenuForPlayer(MainMenu, playerid);
- }
- case 2:
- {
- ShowMenuForPlayer(MainMenu, playerid);
- }
- }
- }
- if(Current == CountDownPos)
- {
- switch(row)
- {
- case 0:
- {
- Pos = 0; // bottom
- new string[256];
- format(string, sizeof(string), " ");
- TextDrawSetString(Text:Pos1, string);
- TextDrawShowForAll(Pos1); // bottom
- ShowMenuForPlayer(CountDownTime, playerid);
- }
- case 1:
- {
- Pos = 1; // top
- new string2[256];
- format(string2, sizeof(string2), " ");
- TextDrawSetString(Text:Pos2, string2);
- TextDrawShowForAll(Pos2); // top
- ShowMenuForPlayer(CountDownTime, playerid);
- }
- case 2:
- {
- ShowMenuForPlayer(MainMenu, playerid);
- }
- }
- }
- if(Current == CountDownTime)
- {
- switch(row)
- {
- case 0:
- {
- Counting = 1;
- CountDownMinutes = 5; //in minutes
- CountDownSeconds = 1; //in seconds
- SetTimer("CountDownTimer", 1000, 0);
- SendClientMessageToAll(COLOR_GREY, "Admin: Count Started!");
- ShowMenuForPlayer(MainMenu, playerid);
- }
- case 1:
- {
- Counting = 1;
- CountDownMinutes = 10; //in minutes
- CountDownSeconds = 1; //in seconds
- SetTimer("CountDownTimer", 1000, 0);
- SendClientMessageToAll(COLOR_GREY, "Admin: Count Started!");
- ShowMenuForPlayer(MainMenu, playerid);
- }
- case 2:
- {
- Counting = 1;
- CountDownMinutes = 20; //in minutes
- CountDownSeconds = 1; //in seconds
- SetTimer("CountDownTimer", 1000, 0);
- SendClientMessageToAll(COLOR_GREY, "Admin: Count Started!");
- ShowMenuForPlayer(MainMenu, playerid);
- }
- case 3:
- {
- Counting = 1;
- CountDownMinutes = 30; //in minutes
- CountDownSeconds = 1; //in seconds
- SetTimer("CountDownTimer", 1000, 0);
- SendClientMessageToAll(COLOR_GREY, "Admin: Count Started!");
- ShowMenuForPlayer(MainMenu, playerid);
- }
- case 4:
- {
- Counting = 1;
- CountDownMinutes = 60; //in minutes
- CountDownSeconds = 1; //in seconds
- SetTimer("CountDownTimer", 1000, 0);
- SendClientMessageToAll(COLOR_GREY, "Admin: Count Started!");
- ShowMenuForPlayer(MainMenu, playerid);
- }
- case 5:
- {
- TextDrawHideForAll(Pos1);
- TextDrawHideForAll(Pos2);
- ShowMenuForPlayer(MainMenu, playerid);
- }
- }
- }
- return 1;
- }
- //==============================================================================
- // OnPlayerCommandText(playerid, cmdtext[])
- //==============================================================================
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/count", cmdtext, true, 10) == 0)
- {
- if (IsPlayerAdmin(playerid) == 1)
- {
- TogglePlayerControllable(playerid, 0);
- ShowMenuForPlayer(MainMenu, playerid);
- }
- return 1;
- }
- return 0;
- }
- //==============================================================================
- // OnPlayerExitedMenu(playerid)
- //==============================================================================
- public OnPlayerExitedMenu(playerid)
- {
- TogglePlayerControllable(playerid, 1);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement