Guest User

Day Or Night | Time Changer | Votes || By: SyntaxQ

a guest
May 5th, 2014
616
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.04 KB | None | 0 0
  1. /*--------------------------------------------
  2.             Topic: Day Or Night Time Changer
  3.              File: dayAndnight.pwn
  4.            Author: SyntaxQ
  5. ----------------------------------------------*/
  6. #include <a_samp>
  7.  
  8. new gIsVoteActive = 0;
  9. new VoteDone[MAX_PLAYERS];
  10. new dayVotes;
  11. new nightVotes;
  12.  
  13. new startTimer;
  14. new endTimer;
  15.  
  16. // Time in milliseconds..
  17. #define START_TIME 60000 // After how many milliseconds the question will be asked..
  18. #define END_TIME 30000 // After how many milliseconds the results will appear / how much time players get to vote.
  19.  
  20. public OnFilterScriptInit()
  21. {
  22.     printf(">> Loaded DayOrNight Time Changer || Author: SyntaxQ");
  23.     startTimer = SetTimer("StartDayAndNightVote", START_TIME, false);
  24.     return 1;
  25. }
  26.  
  27. public OnFilterScriptExit()
  28. {
  29.     return 1;
  30. }
  31.  
  32. forward StartDayAndNightVote ();
  33. public StartDayAndNightVote()
  34. {
  35.     KillTimer(endTimer);
  36.     GameTextForAll("~r~DAY ~y~OR ~b~NIGHT~y~?", 3000, 5);
  37.     gIsVoteActive = 1;
  38.     dayVotes = 0;
  39.     nightVotes = 0;
  40.     for (new i = 0; i < MAX_PLAYERS; i++)
  41.     {
  42.         if (IsPlayerConnected(i))
  43.         {
  44.             VoteDone[i] = 0;
  45.         }
  46.     }
  47.     endTimer = SetTimer("EndDayAndNightVote", END_TIME, false);
  48.     return 1;
  49. }
  50.  
  51. forward EndDayAndNightVote ();
  52. public EndDayAndNightVote()
  53. {
  54.     KillTimer(startTimer);
  55.     if (dayVotes == nightVotes)
  56.     {
  57.         GameTextForAll("~p~DRAW!", 3000, 5);
  58.     }
  59.     if (dayVotes > nightVotes)
  60.     {
  61.         GameTextForAll("~r~DAY ~y~WINS!", 3000, 5);
  62.         SetWorldTime(10);
  63.     }
  64.     if (nightVotes > dayVotes)
  65.     {
  66.         GameTextForAll("~b~NIGHT ~y~WINS!", 3000, 5);
  67.         SetWorldTime(23);
  68.     }
  69.     gIsVoteActive = 0;
  70.     SetTimer("StartDayAndNightVote", START_TIME, false);
  71.     return 1;
  72. }
  73.  
  74. public OnPlayerText(playerid, text[])
  75. {
  76.     if (!strcmp(text, "day", true))
  77.     {
  78.         if (gIsVoteActive == 1 && VoteDone[playerid] == 0)
  79.         {
  80.             dayVotes++;
  81.             VoteDone[playerid] = 1;
  82.         }
  83.     }
  84.     if (!strcmp(text, "night", true))
  85.     {
  86.         if (gIsVoteActive == 1 && VoteDone[playerid] == 0)
  87.         {
  88.             nightVotes++;
  89.             VoteDone[playerid] = 1;
  90.         }
  91.     }
  92.     return 1;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment