Posted By

haster- on 10/25/06


Tagged

script eAthena Poll NPC


Versions (?)

Poll NPC (eAthena Script)


 / Published in: Other
 

Este es un script de encuestas para eAthena

  1. //===== Description: =========================================
  2. //= Allows the GM to set a poll question and up to 9 poll options.
  3. //= Players can then vote on their prefered option.
  4. //= GMs have a menu where the poll can be set, edited or re-votes
  5. //= allowed.
  6.  
  7.  
  8. prontera.gat,154,195,4scriptPoll831,{
  9. if ($poll_question$ == "") goto L_NoQuestion;
  10.  
  11. L_Begin:
  12. mes "[Poll]";
  13. mes "^FF0000" + $poll_question$ + "^000000";
  14.  
  15. if (#pollid != $pollid) goto L_NotVoted;
  16.  
  17. // Sets bar length
  18. set @PB$[0], " ";
  19. set @PB$[1], "^0077BF| ^000000";
  20. set @PB$[2], "^0081CF|^0077BF| ^000000";
  21. set @PB$[3], "^008BDF|^0081CF|^0077BF| ^000000";
  22. set @PB$[4], "^0094EF|^008BDF|^0081CF|^0077BF| ^000000";
  23. set @PB$[5], "^009EFF|^0094EF|^008BDF|^0081CF|^0077BF| ^000000";
  24. set @PB$[6], "^0FA4FF|^009EFF|^0094EF|^008BDF|^0081CF|^0077BF| ^000000";
  25. set @PB$[7], "^1FAAFF|^0FA4FF|^009EFF|^0094EF|^008BDF|^0081CF|^0077BF| ^000000";
  26. set @PB$[8], "^2FB0FF|^1FAAFF|^0FA4FF|^009EFF|^0094EF|^008BDF|^0081CF|^0077BF| ^000000";
  27. set @PB$[9], "^3FB6FF|^2FB0FF|^1FAAFF|^0FA4FF|^009EFF|^0094EF|^008BDF|^0081CF|^0077BF| ^000000";
  28. set @PB$[10], & quot;^4FBCFF|^3FB6FF|^2FB0FF|^1FAAFF|^0FA4FF|^009EFF|^0094EF|^008BDF|^0081CF|^00
  29. 77BF| ^000000";
  30. set @PB$[11], & quot;^5FC2FF|^4FBCFF|^3FB6FF|^2FB0FF|^1FAAFF|^0FA4FF|^009EFF|^0094EF|^008BDF|^00
  31. 81CF|^0077BF| ^000000";
  32. set @PB$[12], & quot;^6FC8FF|^5FC2FF|^4FBCFF|^3FB6FF|^2FB0FF|^1FAAFF|^0FA4FF|^009EFF|^0094EF|^00
  33. 8BDF|^0081CF|^0077BF| ^000000";
  34. set @PB$[13], & quot;^7FCCFF|^6FC8FF|^5FC2FF|^4FBCFF|^3FB6FF|^2FB0FF|^1FAAFF|^0FA4FF|^009EFF|^00
  35. 94EF|^008BDF|^0081CF|^0077BF| ^000000";
  36. set @PB$[14], & quot;^8FD2FF|^7FCCFF|^6FC8FF|^5FC2FF|^4FBCFF|^3FB6FF|^2FB0FF|^1FAAFF|^0FA4FF|^00
  37. 9EFF|^0094EF|^008BDF|^0081CF|^0077BF| ^000000";
  38. set @PB$[15], & quot;^9FD8FF|^8FD2FF|^7FCCFF|^6FC8FF|^5FC2FF|^4FBCFF|^3FB6FF|^2FB0FF|^1FAAFF|^0F
  39. A4FF|^009EFF|^0094EF|^008BDF|^0081CF|^0077BF| ^000000";
  40. set @PB$[16], & quot;^AFDFFF|^9FD8FF|^8FD2FF|^7FCCFF|^6FC8FF|^5FC2FF|^4FBCFF|^3FB6FF|^2FB0FF|^1F
  41. AAFF|^0FA4FF|^009EFF|^0094EF|^008BDF|^0081CF|^0077BF| ^000000";
  42. set @PB$[17], & quot;^BFE5FF|^AFDFFF|^9FD8FF|^8FD2FF|^7FCCFF|^6FC8FF|^5FC2FF|^4FBCFF|^3FB6FF|^2F
  43. B0FF|^1FAAFF|^0FA4FF|^009EFF|^0094EF|^008BDF|^0081CF|^0077BF| ^000000";
  44. set @PB$[18], & quot;^CFEBFF|^BFE5FF|^AFDFFF|^9FD8FF|^8FD2FF|^7FCCFF|^6FC8FF|^5FC2FF|^4FBCFF|^3F
  45. B6FF|^2FB0FF|^1FAAFF|^0FA4FF|^009EFF|^0094EF|^008BDF|^0081CF|^0077BF| ^000000";
  46. set @PB$[19], & quot;^DFF1FF|^CFEBFF|^BFE5FF|^AFDFFF|^9FD8FF|^8FD2FF|^7FCCFF|^6FC8FF|^5FC2FF|^4F
  47. BCFF|^3FB6FF|^2FB0FF|^1FAAFF|^0FA4FF|^009EFF|^0094EF|^008BDF|^0081CF|^0077BF| ^000000";
  48. set @PB$[20], & quot;^EFF8FF|^DFF1FF|^CFEBFF|^BFE5FF|^AFDFFF|^9FD8FF|^8FD2FF|^7FCCFF|^6FC8FF|^5F
  49. C2FF|^4FBCFF|^3FB6FF|^2FB0FF|^1FAAFF|^0FA4FF|^009EFF|^0094EF|^008BDF|^0081CF|^00
  50. 77BF|^000000";
  51.  
  52. // Calculates percentage
  53. set @total,$PA[1]+$PA[2]+$PA[3]+$PA[4]+$PA[5]+$PA[6]+$PA[7]+$PA[8]+$PA[9];
  54. set @PC[1],$PA[1]*100/@total;
  55. set @PC[2],$PA[2]*100/@total;
  56. set @PC[3],$PA[3]*100/@total;
  57. set @PC[4],$PA[4]*100/@total;
  58. set @PC[5],$PA[5]*100/@total;
  59. set @PC[6],$PA[6]*100/@total;
  60. set @PC[7],$PA[7]*100/@total;
  61. set @PC[8],$PA[8]*100/@total;
  62. set @PC[9],$PA[9]*100/@total;
  63.  
  64. // Displays results
  65. if ($PQ$[1] != "") mes $PQ$[1];
  66. if ($PQ$[1] != "") mes "["+@PB$[@PC[1]/5]+"] " + $PA[1] + " ("+@PC[1]+"%)";
  67. if ($PQ$[2] != "") mes $PQ$[2];
  68. if ($PQ$[2] != "") mes "["+@PB$[@PC[2]/5]+"] " + $PA[2] + " ("+@PC[2]+"%)";
  69. if ($PQ$[3] != "") mes $PQ$[3];
  70. if ($PQ$[3] != "") mes "["+@PB$[@PC[3]/5]+"] " + $PA[3] + " ("+@PC[3]+"%)";
  71. if ($PQ$[4] != "") mes $PQ$[4];
  72. if ($PQ$[4] != "") mes "["+@PB$[@PC[4]/5]+"] " + $PA[4] + " ("+@PC[4]+"%)";
  73. if ($PQ$[5] != "") mes $PQ$[5];
  74. if ($PQ$[5] != "") mes "["+@PB$[@PC[5]/5]+"] " + $PA[5] + " ("+@PC[5]+"%)";
  75. if ($PQ$[6] != "") mes $PQ$[6];
  76. if ($PQ$[6] != "") mes "["+@PB$[@PC[6]/5]+"] " + $PA[6] + " ("+@PC[6]+"%)";
  77. if ($PQ$[7] != "") mes $PQ$[7];
  78. if ($PQ$[7] != "") mes "["+@PB$[@PC[7]/5]+"] " + $PA[7] + " ("+@PC[7]+"%)";
  79. if ($PQ$[8] != "") mes $PQ$[8];
  80. if ($PQ$[8] != "") mes "["+@PB$[@PC[8]/5]+"] " + $PA[8] + " ("+@PC[8]+"%)";
  81. if ($PQ$[9] != "") mes $PQ$[9];
  82. if ($PQ$[9] != "") mes "["+@PB$[@PC[9]/5]+"] " + $PA[9] + " ("+@PC[9]+"%)";
  83. mes "Total Votes: " + @total;
  84. if (getgmlevel(3) > 90) menu "Continue",-,"Edit poll option",L_Edit,"Edit poll score",L_EditCount,"Add poll option",L_Add,"Set new poll",L_SetQuestion,"Allow re-vote",L_ReVote;
  85. close;
  86.  
  87. // Vote menu
  88. L_NotVoted:
  89. menu$PQ$[1],P1,
  90. $PQ$[2],P2,
  91. $PQ$[3],P3,
  92. $PQ$[4],P4,
  93. $PQ$[5],P5,
  94. $PQ$[6],P6,
  95. $PQ$[7],P7,
  96. $PQ$[8],P8,
  97. $PQ$[9],P9,
  98. "Cancel",L_Cancel;
  99.  
  100. P1:set @vote,1; goto P_Vote;
  101. P2:set @vote,2; goto P_Vote;
  102. P3:set @vote,3; goto P_Vote;
  103. P4:set @vote,4; goto P_Vote;
  104. P5:set @vote,5; goto P_Vote;
  105. P6:set @vote,6; goto P_Vote;
  106. P7:set @vote,7; goto P_Vote;
  107. P8:set @vote,8; goto P_Vote;
  108. P9:set @vote,9; goto P_Vote;
  109.  
  110. P_Vote:
  111. if ($PQ$[@vote] == "") goto L_Begin;
  112.  
  113. set $PA[@vote],$PA[@vote]+1;
  114. set #pollid,$pollid;
  115. next;
  116. mes "[Poll]";
  117. mes "Thank you for voting!";
  118. next;
  119. goto L_Begin;
  120.  
  121. // No question is set
  122. L_NoQuestion:
  123. mes "[Poll]";
  124. mes "No question set.";
  125. if (getgmlevel(3) > 90) goto L_SetQuestion;
  126. close;
  127.  
  128. // Set question
  129. L_SetQuestion:
  130. set $PQ$[1],"";
  131. set $PQ$[2],"";
  132. set $PQ$[3],"";
  133. set $PQ$[4],"";
  134. set $PQ$[5],"";
  135. set $PQ$[6],"";
  136. set $PQ$[7],"";
  137. set $PQ$[8],"";
  138. set $PQ$[9],"";
  139. set $PA[1],"";
  140. set $PA[2],"";
  141. set $PA[3],"";
  142. set $PA[4],"";
  143. set $PA[5],"";
  144. set $PA[6],"";
  145. set $PA[7],"";
  146. set $PA[8],"";
  147. set $PA[9],"";
  148.  
  149. next;
  150. mes "[Poll]";
  151. mes "Set question?";
  152. next;
  153. menu "Yes",-,"No",L_Cancel;
  154.  
  155. input $poll_question$;
  156. set $pollid,rand (100000,999999);
  157. mes "Question set to: " + $poll_question$;
  158. next;
  159. mes "[Poll]";
  160. mes "Input choices";
  161. mes "type 'end' to stop";
  162. next;
  163.  
  164. P_Set:
  165. input $PQ$[1];
  166. if ($PQ$[1] == "end") goto P_Set;// Disallows no option poll
  167. P_Set2:
  168. input $PQ$[2];
  169. if ($PQ$[2] == "end") goto P_Set2; // Disallows 1 option poll
  170. input $PQ$[3];
  171. set @last,3;
  172. if ($PQ$[3] == "end") goto L_SetEnd;
  173. input $PQ$[4];
  174. set @last,4;
  175. if ($PQ$[4] == "end") goto L_SetEnd;
  176. input $PQ$[5];
  177. set @last,5;
  178. if ($PQ$[5] == "end") goto L_SetEnd;
  179. input $PQ$[6];
  180. set @last,6;
  181. if ($PQ$[6] == "end") goto L_SetEnd;
  182. input $PQ$[7];
  183. set @last,7;
  184. if ($PQ$[7] == "end") goto L_SetEnd;
  185. input $PQ$[8];
  186. set @last,8;
  187. if ($PQ$[8] == "end") goto L_SetEnd;
  188. input $PQ$[9];
  189. set @last,9;
  190. if ($PQ$[9] == "end") goto L_SetEnd;
  191.  
  192. // Add poll field
  193. L_Add:
  194. next;
  195. mes "[Poll]";
  196.  
  197. if ($PQ$[3] == "") goto PA3;
  198. if ($PQ$[4] == "") goto PA4;
  199. if ($PQ$[5] == "") goto PA5;
  200. if ($PQ$[6] == "") goto PA6;
  201. if ($PQ$[7] == "") goto PA7;
  202. if ($PQ$[8] == "") goto PA8;
  203. if ($PQ$[9] == "") goto PA9;
  204.  
  205. mes "Sorry, the options are full.";
  206. close;
  207.  
  208. PA3:set @add,3; goto L_Add2;
  209. PA4:set @add,4; goto L_Add2;
  210. PA5:set @add,5; goto L_Add2;
  211. PA6:set @add,6; goto L_Add2;
  212. PA7:set @add,7; goto L_Add2;
  213. PA8:set @add,8; goto L_Add2;
  214. PA9:set @add,9; goto L_Add2;
  215.  
  216. L_Add2:
  217. mes "Enter the name of the poll you wish you add.";
  218. input $PQ$[@add];
  219. next;
  220. mes "[Poll]";
  221. mes "Option added";
  222. close;
  223.  
  224. // Edit poll count
  225. L_EditCount:
  226. next;
  227. mes "[Poll]";
  228. mes "Which option would you like to change the score of?";
  229. next;
  230. menu$PQ$[1],PEC1,
  231. $PQ$[2],PEC2,
  232. $PQ$[3],PEC3,
  233. $PQ$[4],PEC4,
  234. $PQ$[5],PEC5,
  235. $PQ$[6],PEC6,
  236. $PQ$[7],PEC7,
  237. $PQ$[8],PEC8,
  238. $PQ$[9],PEC9,
  239. "Cancel",L_Cancel;
  240.  
  241. PEC1:input $PA[1]; goto L_EditCountSet;
  242. PEC2:input $PA[2]; goto L_EditCountSet;
  243. PEC3:input $PA[3]; goto L_EditCountSet;
  244. PEC4:input $PA[4]; goto L_EditCountSet;
  245. PEC5:input $PA[5]; goto L_EditCountSet;
  246. PEC6:input $PA[6]; goto L_EditCountSet;
  247. PEC7:input $PA[7]; goto L_EditCountSet;
  248. PEC8:input $PA[8]; goto L_EditCountSet;
  249. PEC9:input $PA[9]; goto L_EditCountSet;
  250.  
  251. L_EditCountSet:
  252. mes "[Poll]";
  253. mes "Option changed";
  254. close;
  255.  
  256. // Edit poll field
  257. L_Edit:
  258. next;
  259. mes "[Poll]";
  260. mes "Which option would you like to edit?";
  261. next;
  262. menu$PQ$[1],PE1,
  263. $PQ$[2],PE2,
  264. $PQ$[3],PE3,
  265. $PQ$[4],PE4,
  266. $PQ$[5],PE5,
  267. $PQ$[6],PE6,
  268. $PQ$[7],PE7,
  269. $PQ$[8],PE8,
  270. $PQ$[9],PE9,
  271. "Cancel",L_Cancel;
  272.  
  273. PE1:input $PQ$[1]; goto L_EditSet;
  274. PE2:input $PQ$[2]; goto L_EditSet;
  275. PE3:input $PQ$[3]; goto L_EditSet;
  276. PE4:input $PQ$[4]; goto L_EditSet;
  277. PE5:input $PQ$[5]; goto L_EditSet;
  278. PE6:input $PQ$[6]; goto L_EditSet;
  279. PE7:input $PQ$[7]; goto L_EditSet;
  280. PE8:input $PQ$[8]; goto L_EditSet;
  281. PE9:input $PQ$[9]; goto L_EditSet;
  282.  
  283. L_EditSet:
  284. mes "[Poll]";
  285. mes "Option changed";
  286. close;
  287.  
  288. L_SetEnd:
  289. Announce "A new poll has been set!",8;
  290. Announce $poll_question$,8;
  291. set $PQ$[@last],"";
  292. mes "[Poll]";
  293. mes "Poll set";
  294. close;
  295.  
  296. // Allow players to re-cast their vote
  297. L_ReVote:
  298. next;
  299. set $pollid,rand (100000,999999);
  300. mes "[Poll]";
  301. mes "Re-vote allowed";
  302. close;
  303.  
  304. L_Cancel:
  305. mes "[Poll]";
  306. mes "Goodbye";
  307. close;
  308. }

Report this snippet  

You need to login to post a comment.