Advertisement
Guest User

hahaha

a guest
Dec 3rd, 2014
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.59 KB | None | 0 0
  1. prontera,169,172,2 script Vote por Pontos 563,{
  2.  
  3. //Function Prototypes
  4. function garbagecol;//Garbage collection for the Character variables
  5. garbagecol();
  6. function add_item; //Syntanx: add_item(ItemID,QUANTITY,POINTS,CATEGORY);
  7. function makeCategory;//This will return a list of the categories
  8. function getItemsByCat;//This will return the list of items associated to the particular category
  9. function getItemDetails;//This will return the details of the item
  10. function getPoints;//This will return the points of the player stored in the database
  11. function updatePoints;//This will updates the points of the player stored in the database
  12.  
  13.  
  14. //NPC Name
  15. set .npcname$,"» Vote Points ";
  16.  
  17. //Initialization of the Rewards
  18. add_item(566,1,90,"» Equipes Points");
  19. add_item(6153,1,150,"» Equipes Points");
  20. add_item(5423,1,800,"» Equipes Points");
  21. add_item(5377,1,900,"» Equipes Points");
  22. add_item(5518,1,1500,"» Equipes Points");
  23. add_item(12915,3,10,"» Equipes Points");
  24. add_item(12918,3,10,"» Equipes Points");
  25. add_item(5660,1,50,"» Equipes Points");
  26. add_item(5519,1,50,"» Equipes Points");
  27. add_item(5495,1,190,"» Equipes Points");
  28. add_item(5361,1,60,"» Equipes Points");
  29. add_item(2115,1,40,"» Equipes Points");
  30. add_item(2524,1,40,"» Equipes Points");
  31. add_item(2421,1,40,"» Equipes Points");
  32. add_item(2357,1,40,"» Equipes Points");
  33. add_item(5225,1,100,"» Equipes Points");
  34.  
  35. //Script Start
  36. mes .npcname$;
  37. mes "Oi ^5566FF"+strcharinfo(0)+"^000000! Você quer trocar os seus pontos de voto?";
  38. switch(select("» Sim, eu quero trocar meus pontos:» Ver meus pontos:» Trocar Por Vip"))
  39. {
  40. case 1:
  41. next;
  42. mes .npcname$;
  43. mes "Por favor selecione uma categoria:";
  44. set .@selected,select(makeCategory())-1;
  45. next;
  46. mes .npcname$;
  47. mes "Por favor selecione uma categoria:";
  48. set .@selected,select(getItemsByCat(@listCat$[.@selected]))-1;
  49.  
  50. next;
  51. mes .npcname$;
  52. set .@rItemID,getItemDetails(@itemKeys[.@selected],"ItemID");
  53. set .@rquantity,getItemDetails(@itemKeys[.@selected],"quantity");
  54. set .@rpoints,getItemDetails(@itemKeys[.@selected],"points");
  55. mes "ID:"+.@rItemID;
  56. mes "Nome: "+getitemname(.@rItemID);
  57. mes "Quantidade: "+.@rquantity+" pc(s).";
  58. mes "Pontos Requeridos: "+.@rpoints+" pt(s).";
  59. mes "\n";
  60. mes "Voce quer este item?";
  61. if(select("Sim:Nao")==1)
  62. {
  63. set .@points,getPoints(getcharid(3));
  64. if(.@points>=.@rpoints)
  65. {
  66. next;
  67. mes .npcname$;
  68. updatePoints(getcharid(3),.@rpoints);
  69. getitem .@rItemID,.@rquantity;
  70. mes "Vamos la entao. Obrigado por votar. Nao se esqueca de votar novamente =D";
  71. }
  72. else
  73. mes "Desculpe, voce nao tem pontos suficientes para este item.";
  74. }
  75. else
  76. {
  77. next;
  78. mes .npcname$;
  79. mes "Okay xau!";
  80. }
  81. garbagecol();
  82. close;
  83.  
  84. case 2:
  85. next;
  86. mes .npcname$;
  87. set .@points,getPoints(getcharid(3));
  88. mes "Voce tem "+.@points+" pt(s).";
  89. garbagecol();
  90. close;
  91.  
  92. case 3:
  93. goto escape;
  94.  
  95. }
  96. end;
  97.  
  98. escape:
  99. next;
  100. mes .npcname$;
  101. mes "Posso lhe dar um dia VIP por 3 pontos, tudo bem?";
  102. set .@points,getPoints(getcharid(3));
  103. mes "Voce tem "+.@points+" pt(s).";
  104. switch(select("Sim","Não")){
  105.  
  106. case 1:
  107. if(.@points<3){
  108. mes "Você não tem pontos suficientes!";
  109. close;
  110. }
  111. mes "Pronto!";
  112. set .@account_id,getcharid(3);
  113. set .@usedPoints,3;
  114. set $nivelVip, 1;
  115. set $diasVip, 1;
  116. set $verificaVip, 1;
  117. query_sql("UPDATE `cp_v4p_voters` SET points=(points-"+.@usedPoints+") WHERE account_id='"+.@account_id+"'");
  118. if (getgroupid() == 0){
  119. query_sql "UPDATE `login` SET `group_id` = "+$nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = "+$nivelVip+" AND `account_id` = "+getcharid(3);dispbottom "Relogue para ter seu VIP ativado.";
  120. }else{
  121. query_sql "UPDATE `login` SET `group_id` = "+$nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = "+$nivelVip+" AND `account_id` = "+getcharid(3);
  122. }
  123. garbagecol();
  124. close2;
  125. message strcharinfo(0),"Pontos adicionados";
  126. end;
  127.  
  128. case 2:
  129. close;
  130. }
  131.  
  132. end;
  133.  
  134. //Functions Bodies
  135. function updatePoints {
  136. set .@account_id,getarg(0);
  137. set .@usedPoints,getarg(1);
  138. query_sql("UPDATE `cp_v4p_voters` SET points=(points-"+.@usedPoints+") WHERE account_id='"+.@account_id+"'");
  139. return;
  140. }
  141.  
  142. function getPoints {
  143. set .@account_id,getarg(0);
  144. query_sql("SELECT `points` FROM `cp_v4p_voters` WHERE account_id="+.@account_id+" LIMIT 1",.@points);
  145. if(getarraysize(.@points)==0)
  146. return 0;
  147. return .@points[0];
  148. }
  149.  
  150. function getItemDetails {
  151. set .@key,getarg(0); //Key
  152. set .@detail$,getarg(1); //What details to return such as ItemID, Points, Quantity, Category
  153.  
  154. if(.@detail$ == "ItemID")
  155. return @ItemID[.@key];
  156. else if((.@detail$ == "Quantity") || (.@detail$ == "quantity"))
  157. return @itemQ[.@key];
  158. else if((.@detail$ == "Points") || (.@detail$ == "points"))
  159. return @points[.@key];
  160. else if((.@detail$ == "Category") || (.@detail$ == "category"))
  161. return @category$[.@key];
  162. }
  163.  
  164. function getItemsByCat {
  165. set .@selectedCat$,getarg(0);
  166. set .@make_string$,"";
  167. set .@x,0;
  168. for(set .@i,0; .@i<getarraysize(@category$); set .@i,.@i+1)
  169. {
  170. if(.@selectedCat$ == @category$[.@i]);
  171. {
  172. setarray @itemKeys[.@x],.@i;
  173. if(.@make_string$ == "")
  174. set .@make_string$,getitemname(@ItemID[.@i]);
  175. else
  176. set .@make_string$,.@make_string$+":"+getitemname(@ItemID[.@i]);
  177.  
  178. set .@x,.@x+1;
  179. }
  180. }
  181. return .@make_string$;
  182. }
  183.  
  184.  
  185. function makeCategory {
  186. set .@make_string$,"";
  187. for(set .@i,0; .@i<getarraysize(@category$); set .@i,.@i+1)
  188. {
  189. if(.@make_string$ == "")
  190. {
  191. setarray @listCat$[getarraysize(@listCat$)],@category$[.@i];
  192. set .@make_string$,@category$[.@i];
  193. }
  194. else
  195. {
  196. if(compare(.@make_string$,@category$[.@i])==0)
  197. {
  198. setarray @listCat$[getarraysize(@listCat$)],@category$[.@i];
  199. set .@make_string$,.@make_string$+":"+@category$[.@i];
  200. }
  201. }
  202. }
  203. return .@make_string$;
  204. }
  205.  
  206. function add_item
  207. {
  208. set .@ItemID,getarg(0,-1); //IteID
  209. set .@itemQ,getarg(1,-1); //Item Quantity
  210. set .@points,getarg(2,-1);
  211. set .@cat$,getarg(3,"Uncategorized"); //Category
  212.  
  213.  
  214. if(.@ItemID == -1)
  215. {
  216. debugmes "Invalid Item ID. Script not completely loaded.";
  217. end;
  218. }
  219. else if(.@itemQ == -1)
  220. {
  221. debugmes "Invalid Item Quantity. Script not completely loaded.";
  222. end;
  223. }
  224. else if(.@points == -1)
  225. {
  226. debugmes "Points assignment error. Script not completely loaded.";
  227. end;
  228. }
  229. set .@key,getarraysize(@ItemID);
  230. setarray @ItemID[.@key],.@ItemID;
  231. setarray @itemQ[.@key],.@itemQ;
  232. setarray @points[.@key],.@points;
  233. setarray @category$[.@key],.@cat$;
  234. return 1; //return 1 as success
  235. }
  236.  
  237. function garbagecol{
  238. deletearray @ItemID[0],128;
  239. deletearray @itemQ[0],128;
  240. deletearray @points[0],128;
  241. deletearray @category$[0],128;
  242. deletearray @listCat$[0],128;
  243. deletearray @itemKeys[0],128;
  244. return;
  245. }
  246. //OnInit:
  247. //waitingroom " #voteporPONTO's ",0;
  248. //end;
  249. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement