Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*--------------------------------------------
- Topic: Day Or Night Time Changer
- File: dayAndnight.pwn
- Author: SyntaxQ
- ----------------------------------------------*/
- #include <a_samp>
- new gIsVoteActive = 0;
- new VoteDone[MAX_PLAYERS];
- new dayVotes;
- new nightVotes;
- new startTimer;
- new endTimer;
- // Time in milliseconds..
- #define START_TIME 60000 // After how many milliseconds the question will be asked..
- #define END_TIME 30000 // After how many milliseconds the results will appear / how much time players get to vote.
- public OnFilterScriptInit()
- {
- printf(">> Loaded DayOrNight Time Changer || Author: SyntaxQ");
- startTimer = SetTimer("StartDayAndNightVote", START_TIME, false);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- forward StartDayAndNightVote ();
- public StartDayAndNightVote()
- {
- KillTimer(endTimer);
- GameTextForAll("~r~DAY ~y~OR ~b~NIGHT~y~?", 3000, 5);
- gIsVoteActive = 1;
- dayVotes = 0;
- nightVotes = 0;
- for (new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- VoteDone[i] = 0;
- }
- }
- endTimer = SetTimer("EndDayAndNightVote", END_TIME, false);
- return 1;
- }
- forward EndDayAndNightVote ();
- public EndDayAndNightVote()
- {
- KillTimer(startTimer);
- if (dayVotes == nightVotes)
- {
- GameTextForAll("~p~DRAW!", 3000, 5);
- }
- if (dayVotes > nightVotes)
- {
- GameTextForAll("~r~DAY ~y~WINS!", 3000, 5);
- SetWorldTime(10);
- }
- if (nightVotes > dayVotes)
- {
- GameTextForAll("~b~NIGHT ~y~WINS!", 3000, 5);
- SetWorldTime(23);
- }
- gIsVoteActive = 0;
- SetTimer("StartDayAndNightVote", START_TIME, false);
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if (!strcmp(text, "day", true))
- {
- if (gIsVoteActive == 1 && VoteDone[playerid] == 0)
- {
- dayVotes++;
- VoteDone[playerid] = 1;
- }
- }
- if (!strcmp(text, "night", true))
- {
- if (gIsVoteActive == 1 && VoteDone[playerid] == 0)
- {
- nightVotes++;
- VoteDone[playerid] = 1;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment