Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define VoteTimeSeconds 45000
- static VoteAvailable = 0;
- static AlreadyVoted[MAX_PLAYERS] = 0;
- static ShowName[MAX_PLAYERS] = 0;
- static PlayersThatSaidYes = 0;
- static PlayersThatSaidNo = 0;
- forward VotingTime();
- main() {
- print("\n-------------------------");
- print(" Vote Game Mode By JaYmE ");
- print("-------------------------\n");
- }
- public OnGameModeInit() {
- SetGameModeText("Voting Test !");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid) {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new String[100];
- new pName[25];
- new Answer[5];
- if (strcmp("/PollHelp", cmdtext, true, 9) == 0) {
- SendClientMessage(playerid, 0x24000019, "/MakePoll : Makes A Poll ( Admin Only ) !");
- SendClientMessage(playerid, 0x00240019, "/Vote : Cast Your Vote ( Yes / No ) !");
- SendClientMessage(playerid, 0x00002419, "/ShowName : Do You Want People To Know Your Vote !");
- return 1;
- }
- if (strcmp("/MakePoll", cmdtext, true, 9) == 0) {
- if ( !IsPlayerAdmin(playerid) )
- return SendClientMessage(playerid, 0x24000019, "Error: You cannot start a poll !");
- else
- if ( cmdtext[9] == 0 || cmdtext[10] == 0 ) {
- return SendClientMessage(playerid, 0x24000019, "Usage: /MakePoll < Question > !");
- }
- format(String, sizeof String, "New Poll Question: %s. ", cmdtext[10]);
- SendClientMessageToAll(0x00340056, String);
- VoteAvailable = 1;
- SetTimer("VotingTime", VoteTimeSeconds, false);
- return 1;
- }
- if (strcmp("/Vote", cmdtext, true, 5) == 0) {
- if ( VoteAvailable == 0 )
- return SendClientMessage(playerid, 0x24000019, "Error: No polls are available !");
- else if ( AlreadyVoted[playerid] == 1 )
- return SendClientMessage(playerid, 0x00240019, "Error: You have already voted !");
- else if ( cmdtext[5] == 0 || cmdtext[6] == 0 )
- return SendClientMessage(playerid, 0x00002419, "Usage: /Vote < Yes / No > !");
- else if ( strcmp("Yes", cmdtext[6], true ) == 0 ) {
- Answer = "Yes";
- PlayersThatSaidYes++;
- }
- else if ( strcmp("No", cmdtext[6], true ) == 0 ) {
- Answer = "No";
- PlayersThatSaidNo++;
- }
- else
- return SendClientMessage(playerid, 0x24000019, "Error: Invalid Vote !");
- if ( ShowName[playerid] == 1 )
- GetPlayerName(playerid, pName, sizeof pName);
- else
- pName = "Annoumous";
- format(String, sizeof String, "%s Voted: %s", pName, Answer);
- SendClientMessageToAll(0x00350019, String);
- AlreadyVoted[playerid] = 1;
- return 1;
- }
- if (strcmp("/ShowName", cmdtext, true, 9) == 0) {
- if ( ShowName[playerid] == 0 )
- ShowName[playerid] = 1;
- else
- ShowName[playerid] = 0;
- if ( ShowName[playerid] == 1 )
- SendClientMessage(playerid, 0x00350019, "Your Name Will Be Shown !");
- else
- SendClientMessage(playerid, 0x00003519, "Your Name Will Not Be Shown !");
- return 1;
- }
- return 0;
- }
- public VotingTime() {
- SendClientMessageToAll(0xff000019, "Vote: Vote Has Finished Here's The Results:");
- new String[50];
- format(String, sizeof String, "People Who Voted Yes: %d", PlayersThatSaidYes);
- SendClientMessageToAll(0x00002319, String);
- format(String, sizeof String, "People Who Voted No: %d", PlayersThatSaidNo);
- SendClientMessageToAll(0x00230019, String);
- VoteAvailable = 0;
- for ( new i = 0; i < MAX_PLAYERS; i++ )
- AlreadyVoted[i] = 0;
- PlayersThatSaidYes = 0;
- PlayersThatSaidNo = 0;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment