Advertisement
Guest User

Untitled

a guest
May 6th, 2017
878
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.20 KB | None | 0 0
  1. //===== Athena Script =======================================================
  2. //= Event Ticket Handler NPC
  3. //= Purpose: It passes out Event Ticket(s) to specific
  4. //= players through GM input.
  5. //= Players can talk to NPC and retrieve them easily.
  6. //===== By ==================================================================
  7. //= LuminousRO Admin
  8. //===== Version =============================================================
  9. //= 1.0 - Might contain bug
  10. //= 1.1 - Fixed bug: Adding when the table has user in it but 0 tickets
  11. //= 1.2a - Added deduction function in case GMs give extra
  12. //= 1.2b - Added remove from database if there's nothing to deduct from
  13. //= 1.3 - Added set functions to set name, item to be rewarded, and GM level
  14. //- 1.4 - Changed it so that it can also give it to players when offline
  15. //===========================================================================
  16.  
  17. prontera,152,188,6 script Event Ticket Girl 719,{
  18. set @name$,"Event Ticket Girl";
  19. set @itemid,6116;
  20. set @gmlvl,20; // Set
  21. if (getgmlevel() >= @gmlvl) goto L_GM;
  22. L_START:
  23. mes "["+@name$+"]";
  24. mes "Hellow what would you like to do today?";
  25. next;
  26. menu "More info",-,"Make a claim",L_CHECK,"Cancel",L_CLOSE;
  27. L_INFO:
  28. mes "["+@name$+"]";
  29. mes "GMs randomly host fun events";
  30. mes "and to make the event worth while,";
  31. mes "we reward the winner with Event";
  32. mes "Tickets so they could be exchanged";
  33. mes "for Event Items";
  34. next;
  35. menu "Make a claim",L_CHECK,"Cancel",L_CLOSE;
  36.  
  37. L_CHECK:
  38. query_sql "SELECT `amount` FROM `event_tickets` WHERE `account_id` = "+getcharid(3), @amount$;
  39. query_sql "SELECT '"+@amount$+"' > 0", @enough;
  40. if(!@enough) {
  41. mes "["+@name$+"]";
  42. mes "Sorry but you must first participate in an Event to get Event Tickets";
  43. mes "But if you already did and still don't have any, please PM the GM who hosted the Event";
  44. mes "Thank you.";
  45. close;
  46. }
  47.  
  48. L_CLAIM:
  49. mes "["+@name$+"]";
  50. mes "You have "+@amount$+" Event Ticket(s)!";
  51. mes "What would you like to claim them?";
  52. next;
  53. menu "Yes",L_CLAIMITEM,"No",L_Close;
  54.  
  55. L_CLAIMITEM:
  56. mes "["+@name$+"]";
  57. mes "Here you go!";
  58. query_sql "SELECT `amount` FROM `event_tickets` WHERE `account_id` = "+getcharid(3), @amount$;
  59. getitem @itemid,@amount$;
  60. query_sql "UPDATE `event_tickets` SET `amount` = '0' WHERE `account_id` = "+getcharid(3);
  61. close;
  62.  
  63. L_GM:
  64. mes "[GM Menu]";
  65. mes "Hello GM!";
  66. mes "What would you like to do?";
  67. next;
  68. menu "Add/Remove Event Tickets",L_GM2,"Test Script",L_START,"Nothing",L_CLOSE;
  69. L_GM2:
  70. menu "Give Event Tickets",L_TICKET,"Deduct Event Tickets",L_REMOVE,"Return to main menu",L_GM;
  71.  
  72. L_TICKET:
  73. mes "[GM Menu]";
  74. mes "Please enter the player's name:";
  75. input @winner$;
  76. query_sql "SELECT `account_id` FROM `char` WHERE `name` = '"+@winner$+"'", @aid;
  77. set @wonBefore$, "";
  78. if(@aid==0)
  79. {
  80. goto L_NONE;
  81. }
  82. query_sql "SELECT `amount` FROM `event_tickets` WHERE `account_id` = "+@aid, @wonBefore$;
  83. query_sql "SELECT '"+@wonBefore$+"' > 0", @wonBefore;
  84. switch(@wonBefore) {
  85. case 0:
  86. mes @winner$+" has 0 Event Tickets.";
  87. break;
  88. case 1:
  89. mes @winner$+" has "+@wonBefore$+" Event Tickets already.";
  90. break;
  91. }
  92. next;
  93. mes "[GM Menu]";
  94. mes "Please enter the amount of tickets to give to "+@winner$;
  95. input @ticketAmount$;
  96. query_sql "SELECT '"+escape_sql(@ticketAmount$)+"' > 0", @valid;
  97. if(!@valid)
  98. {
  99. next;
  100. goto L_ZERO;
  101. }
  102. next;
  103. mes "[GM Menu]";
  104. mes "You have specified that "+@winner$+" has won "+@ticketAmount$+" Event Ticket(s).";
  105. mes "Would you like to continue?";
  106. next;
  107. menu "No",L_GM,"Yes",-;
  108. set @boolean$,0;
  109. query_sql "SELECT `account_id` FROM `event_tickets` WHERE `account_id` = "+@aid, @boolean$;
  110. query_sql "SELECT '"+@boolean$+"' > 0", @boolean;
  111. if (@boolean != 0)
  112. {
  113. set @boolean,1;
  114. }
  115. else
  116. {
  117. set @boolean,0;
  118. }
  119. switch(@boolean) {
  120. case 0:
  121. query_sql "INSERT INTO `event_tickets` VALUES ("+@aid+", '"+@ticketAmount$+"')";
  122. break;
  123. case 1:
  124. query_sql "UPDATE `event_tickets` SET `amount` = `amount` + "+@ticketAmount$+" WHERE `account_id` = "+@aid;
  125. break;
  126. }
  127. logmes "Credited "+@winner$+" with "+@ticketAmount$ + " Event Ticket(s) by GM " +getcharid(3);
  128. query_sql "SELECT `amount` FROM `event_tickets` WHERE `account_id` = "+@aid, @currentAmount$;
  129. mes "[GM Menu]";
  130. mes "Event Ticket(s) added successfully!";
  131. mes @winner$+" has a total of "+@currentAmount$+ " Event Ticket(s).";
  132. close;
  133.  
  134. L_ZERO:
  135. mes "[GM Menu]";
  136. mes "You can't have 0 as an amount!";
  137. next;
  138. goto L_GM;
  139.  
  140. L_NONE:
  141. mes "[GM Menu]";
  142. mes "Character name "+@winner$+" does not exist.";
  143. next;
  144. goto L_GM;
  145.  
  146. L_REMOVE:
  147. mes "[GM Menu]";
  148. mes "Please enter the players's name:";
  149. input @winner$;
  150. set @aid, getcharid(3,@winner$);
  151. if(@aid==0)
  152. {
  153. next;
  154. goto L_NONE;
  155. }
  156. query_sql "SELECT `amount` FROM `event_tickets` WHERE `account_id` = "+@aid, @wonBefore$;
  157. query_sql "SELECT '"+@wonBefore$+"' > 0", @wonBefore;
  158. next;
  159. mes "[GM Menu]";
  160. if(!@wonBefore) {
  161. query_sql "DELETE FROM `event_tickets` WHERE `account_id` = "+@aid;
  162. logmes "Deleted "+@winner$+" from Event Tickets database by GM " +getcharid(3);
  163. mes @winner$+" has no Event Tickets and has been deleted from the Event Tickets database.";
  164. } else {
  165. mes @winner$+" has "+@wonBefore$+" Event Ticket(s).";
  166. next;
  167. switch(select("Deduct an amount from "+@winner$,"Return to main menu")){
  168. mes "[GM Menu]";
  169. case 1:
  170. mes "Please enter the amount "+@winner$+" is to be deducted by:";
  171. input @deduct$;
  172. query_sql "SELECT '"+escape_sql(@deduct$)+"' > 0", @valid;
  173. if(!@valid)
  174. {
  175. next;
  176. goto L_ZERO;
  177. }
  178. mes "You have specified that "+@winner$+" is to be deducted by "+@deduct$+".";
  179. mes "Would you like to continue?";
  180. next;
  181. menu "No",L_GM,"Yes",-;
  182. query_sql "UPDATE `event_tickets` SET `amount` = `amount` - "+@deduct$+" WHERE `account_id` = "+@aid;
  183. query_sql "SELECT `amount` FROM `event_tickets` WHERE `account_id` = "+@aid, @afterdeduct$;
  184. logmes "Deducted "+@deduct$+" from "+@winner$ + " Event Ticket(s) by GM " +getcharid(3);
  185. mes "[GM Menu]";
  186. mes "Event Ticket(s) deducted successfully!";
  187. mes @winner$+" has a total of "+@afterdeduct$+" Event Ticket(s)";
  188. break;
  189. case 2:
  190. next;
  191. goto L_GM;
  192. }
  193. }
  194. close;
  195. L_CLOSE:
  196. close;
  197. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement