Advertisement
Guest User

Untitled

a guest
Jan 30th, 2013
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. /*
  2. Server rating script
  3. By Stream
  4. Do not re-relase or claim this script as your own.
  5. */
  6.  
  7. #include <a_samp>
  8. #define GREEN 0x21DD00FF
  9. #define RED 0xE60000FF
  10.  
  11.  
  12. //---------- Defines - set to true to enable, to false to disable ----------
  13.  
  14. #define CONNECTMSG true //Will display a message on connect so people get informed about /rate
  15. #define FILENAME "ratings.txt" //NEEDED! The file where you´ll find all ratings listed.
  16. #define DIALOG 2432 //Dialog-ID used, edit if you experience problems with your dialogs
  17.  
  18. //---------- End of defines - editing below at your own risk ----------
  19.  
  20. new rating1[MAX_PLAYERS];
  21. new rating2[MAX_PLAYERS];
  22. new rating3[MAX_PLAYERS];
  23. new rating4[MAX_PLAYERS];
  24. new rating5[MAX_PLAYERS];
  25.  
  26. forward CalculateSummary(playerid);
  27.  
  28. public OnPlayerConnect(playerid)
  29. {
  30. #if defined CONNECTMSG
  31. SendClientMessage(playerid,RED,"You can rate this server. To do so, use /rate.");
  32. #endif
  33. return 1;
  34. }
  35.  
  36. public OnPlayerCommandText(playerid, cmdtext[])
  37. {
  38. if(!strcmp(cmdtext, "/rate", true))
  39. {
  40. ShowPlayerDialog(playerid,DIALOG,DIALOG_STYLE_MSGBOX,"Server rating system","This is the server rating system.\nIf you want to rate this server,\npress Okay, else press Cancel.","Okay","Cancel");
  41. return 1;
  42. }
  43. return 0;
  44. }
  45.  
  46. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  47. {
  48. if(dialogid == DIALOG)
  49. {
  50. if(response) ShowPlayerDialog(playerid,DIALOG+1,DIALOG_STYLE_LIST,"Rate the SCRIPT FEATURES.","1 (Worst)\n2\n3\n4\n5 (Average)\n6\n7\n8\n9\n10 (Best)","Rate","Cancel");
  51. return 1;
  52. }
  53.  
  54. if(dialogid == DIALOG+1)
  55. {
  56. if(response)
  57. {
  58. rating1[playerid] = listitem+1;
  59.  
  60. ShowPlayerDialog(playerid,DIALOG+2,DIALOG_STYLE_LIST,"Rate the BUG APPEARANCE.","1 (Much)\n2\n3\n4\n5 (Average)\n6\n7\n8\n9\n10 (None)","Rate","Cancel");
  61. return 1;
  62. }
  63. }
  64.  
  65. if(dialogid == DIALOG+2)
  66. {
  67. if(response)
  68. {
  69. rating2[playerid] = listitem+1;
  70.  
  71. ShowPlayerDialog(playerid,DIALOG+3,DIALOG_STYLE_LIST,"Rate the ADMIN STAFF.","1 (Worst)\n2\n3\n4\n5 (Average)\n6\n7\n8\n9\n10 (Best)","Rate","Cancel");
  72. return 1;
  73. }
  74. }
  75.  
  76. if(dialogid == DIALOG+3)
  77. {
  78. if(response)
  79. {
  80. rating3[playerid] = listitem+1;
  81.  
  82. ShowPlayerDialog(playerid,DIALOG+4,DIALOG_STYLE_LIST,"Rate the PLAYERS.","1 (Bad)\n2\n3\n4\n5 (Average)\n6\n7\n8\n9\n10 (Nice)","Rate","Cancel");
  83. return 1;
  84. }
  85. }
  86.  
  87. if(dialogid == DIALOG+4)
  88. {
  89. if(response)
  90. {
  91. rating4[playerid] = listitem+1;
  92.  
  93. ShowPlayerDialog(playerid,DIALOG+5,DIALOG_STYLE_LIST,"Rate the FUN.","1 (Boring)\n2\n3\n4\n5 (Average)\n6\n7\n8\n9\n10 (Fun)","Rate","Cancel");
  94. return 1;
  95. }
  96. }
  97.  
  98. if(dialogid == DIALOG+5)
  99. {
  100. if(response)
  101. {
  102. rating5[playerid] = listitem+1;
  103.  
  104. CalculateSummary(playerid);
  105. return 1;
  106. }
  107. }
  108. return 0;
  109. }
  110.  
  111. public CalculateSummary(playerid)
  112. {
  113. new string[140],string2[140],pname[24];
  114. GetPlayerName(playerid,pname,sizeof(pname));
  115. new string3[140];
  116. new bool:allowed = true;
  117. new File:log2 = fopen(FILENAME,io_append);
  118. while(fread(log2, string3))
  119. {
  120. if(strcmp(string3,pname) == 0) allowed = false;
  121. }
  122. fclose(log2);
  123.  
  124. if(allowed == true)
  125. {
  126. new average;
  127. average = ((rating1[playerid]+rating2[playerid]+rating3[playerid]+rating4[playerid]+rating5[playerid])/5);
  128.  
  129. format(string,sizeof(string),"%s rated the server with %d average. [Script: %d | Bugs: %d | Staff: %d | Players: %d | Fun: %d]",pname,average,rating1[playerid],rating2[playerid],rating3[playerid],rating4[playerid],rating5[playerid]);
  130. format(string2,sizeof(string2),"%s rated the server with %d average. [Script: %d | Bugs: %d | Staff: %d | Players: %d | Fun: %d]\n",pname,average,rating1[playerid],rating2[playerid],rating3[playerid],rating4[playerid],rating5[playerid]);
  131. SendClientMessageToAll(GREEN,string);
  132. new File:log = fopen(FILENAME,io_append);
  133. fwrite(log, string2);
  134. fclose(log);
  135. ShowPlayerDialog(playerid,DIALOG+10,DIALOG_STYLE_MSGBOX,"Server rating system","Thanks for rating!","Close","Close");
  136. }
  137. else ShowPlayerDialog(playerid,DIALOG+10,DIALOG_STYLE_MSGBOX,"Server rating system","We have already received \na rating from you.","Close","Close");
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement