Guest User

JaYmE

a guest
Feb 24th, 2009
600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.78 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define VoteTimeSeconds             45000
  4.  
  5. static  VoteAvailable               =   0;
  6. static  AlreadyVoted[MAX_PLAYERS]   =   0;
  7. static  ShowName[MAX_PLAYERS]       =   0;
  8. static  PlayersThatSaidYes          =   0;
  9. static  PlayersThatSaidNo           =   0;
  10.  
  11. forward VotingTime();
  12.  
  13. main() {
  14.     print("\n-------------------------");
  15.     print(" Vote Game Mode By JaYmE ");
  16.     print("-------------------------\n");
  17. }
  18.  
  19. public OnGameModeInit() {
  20.     SetGameModeText("Voting Test !");
  21.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  22.     return 1;
  23. }
  24.  
  25. public OnPlayerRequestClass(playerid, classid) {
  26.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  27.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  28.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  29.     return 1;
  30. }
  31.  
  32. public OnPlayerCommandText(playerid, cmdtext[])
  33. {
  34.     new String[100];
  35.     new pName[25];
  36.     new Answer[5];
  37.    
  38.     if (strcmp("/PollHelp", cmdtext, true, 9) == 0) {
  39.         SendClientMessage(playerid, 0x24000019, "/MakePoll  : Makes A Poll ( Admin Only ) !");
  40.         SendClientMessage(playerid, 0x00240019, "/Vote      : Cast Your Vote ( Yes / No ) !");
  41.         SendClientMessage(playerid, 0x00002419, "/ShowName  : Do You Want People To Know Your Vote  !");
  42.         return 1;
  43.     }
  44.    
  45.     if (strcmp("/MakePoll", cmdtext, true, 9) == 0) {
  46.         if ( !IsPlayerAdmin(playerid) )
  47.             return SendClientMessage(playerid, 0x24000019, "Error: You cannot start a poll !");
  48.         else
  49.             if ( cmdtext[9] == 0 || cmdtext[10] == 0 ) {
  50.                 return SendClientMessage(playerid, 0x24000019, "Usage: /MakePoll < Question > !");
  51.             }
  52.         format(String, sizeof String, "New Poll Question: %s. ", cmdtext[10]);
  53.         SendClientMessageToAll(0x00340056, String);
  54.         VoteAvailable   =   1;
  55.         SetTimer("VotingTime", VoteTimeSeconds, false);
  56.         return 1;
  57.     }
  58.    
  59.     if (strcmp("/Vote", cmdtext, true, 5) == 0) {
  60.         if ( VoteAvailable == 0 )
  61.             return SendClientMessage(playerid, 0x24000019, "Error: No polls are available !");
  62.         else if ( AlreadyVoted[playerid] == 1 )
  63.             return SendClientMessage(playerid, 0x00240019, "Error: You have already voted !");
  64.         else if ( cmdtext[5] == 0 || cmdtext[6] == 0 )
  65.             return SendClientMessage(playerid, 0x00002419, "Usage: /Vote < Yes / No > !");
  66.         else if ( strcmp("Yes", cmdtext[6], true ) == 0 ) {
  67.             Answer  =   "Yes";
  68.             PlayersThatSaidYes++;
  69.         }
  70.         else if ( strcmp("No", cmdtext[6], true ) == 0 ) {
  71.             Answer  =   "No";
  72.             PlayersThatSaidNo++;
  73.         }
  74.         else
  75.             return SendClientMessage(playerid, 0x24000019, "Error: Invalid Vote !");
  76.            
  77.         if ( ShowName[playerid] == 1 )
  78.                 GetPlayerName(playerid, pName, sizeof pName);
  79.             else
  80.                 pName = "Annoumous";
  81.         format(String, sizeof String, "%s Voted: %s", pName, Answer);
  82.         SendClientMessageToAll(0x00350019, String);
  83.         AlreadyVoted[playerid] = 1;
  84.         return 1;
  85.     }
  86.    
  87.     if (strcmp("/ShowName", cmdtext, true, 9) == 0) {
  88.         if ( ShowName[playerid] == 0 )
  89.             ShowName[playerid]  =   1;
  90.          else
  91.             ShowName[playerid]  =   0;
  92.         if ( ShowName[playerid] == 1 )
  93.             SendClientMessage(playerid, 0x00350019, "Your Name Will Be Shown !");
  94.         else
  95.             SendClientMessage(playerid, 0x00003519, "Your Name Will Not Be Shown !");
  96.         return 1;
  97.     }
  98.     return 0;
  99. }
  100.  
  101. public VotingTime() {
  102.     SendClientMessageToAll(0xff000019, "Vote: Vote Has Finished Here's The Results:");
  103.     new String[50];
  104.     format(String, sizeof String, "People Who Voted Yes:    %d", PlayersThatSaidYes);
  105.     SendClientMessageToAll(0x00002319, String);
  106.     format(String, sizeof String, "People Who Voted No:     %d", PlayersThatSaidNo);
  107.     SendClientMessageToAll(0x00230019, String);
  108.     VoteAvailable       =   0;
  109.     for ( new i = 0; i < MAX_PLAYERS; i++ )
  110.         AlreadyVoted[i] =   0;
  111.     PlayersThatSaidYes  =   0;
  112.     PlayersThatSaidNo   =   0;
  113.     return 1;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment