Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. prontera,139,182,4 script Donor Rewards Redeemer 987,{
  2. // ----------------- NPC Settings -----------------
  3. // --- SET THESE BEFORE LOADING THE SCRIPT! ---
  4.  
  5. // Server Name
  6. set .serverName$,"OMG Core";
  7.  
  8. // NPC Name to display during chat.
  9. // Default: "[Donor Rewards Redeemer]"
  10. set .npcName$,"[Donor Rewards Redeemer]";
  11.  
  12. // DO NOT CHANGE THIS!
  13. // Default: "cp_redeemlog"
  14. set .redeemTable$,"cp_credits";
  15. set .itemTable$,"cp_redeemlog";
  16.  
  17. // Display Credits to FluxCP Creators?
  18. // Help promote our product if its useful.
  19. // 0 = Disable. 1 = Enable.
  20. // Default: 1
  21. set .showCredits,1;
  22.  
  23. // Max number of unique items to redeem at a time.
  24. // DO NOT RAISE THIS VALUE ABOVE 128 WITHOUT
  25. // MAKING THE NECESSARY SCRIPT ENGINE MODS
  26. // FOR SCRIPT ARRAY SIZING! DANGEROUS!
  27. // Default: 128
  28. set .numRedemptionsSimul,128;
  29. // --------------- End NPC Settings ---------------
  30.  
  31. // ----------------- Begin Script -----------------
  32. mes .npcName$;
  33. mes "Well hello there " + (Sex ? "good sir!" : "young madam!");
  34. mes "How may I be of assistance to you on this fine day?";
  35. next;
  36. prompt("I wish to redeem My Credits:Collect My items :Check my balance.");
  37. mes .npcName$;
  38. switch(@menu) {
  39. case 1:
  40. query_sql("SELECT `balance` FROM `" + escape_sql(.redeemTable$) + "` WHERE `account_id` = " + getcharid(3) + " LIMIT 0,30", .@credits);
  41. if (.@credits > 0){
  42. mes "How many Donation Credits do you wish to redeem?";
  43. next;
  44. mes .npcName$;
  45. input .@withdrawCredits,1,.@credits;
  46. query_sql("UPDATE `" + escape_sql(.redeemTable$) + "` SET `balance` = `balance` - " + .@withdrawCredits + " WHERE `account_id` = " + getcharid(3) + "");
  47. set #CASHPOINTS,#CASHPOINTS + .@withdrawCredits;
  48. mes .@withdrawCredits + "x " ;
  49. } else {
  50. mes "My records indicate that there are no rewards awaiting to be redeemed.";
  51. mes "My deepest apologies for the misunderstanding.";
  52. }
  53. break;
  54. case 2:
  55. query_sql "SELECT `id`, `nameid`, `quantity` FROM `" + escape_sql(.itemTable$) + "` WHERE `account_id` = " + getcharid(3) + " AND `redeemed` = 0 LIMIT " + .numRedemptionsSimul,.@id,.@nameid,.@quantity;
  56. if (getarraysize(.@id) > 0) {
  57. mes "Items Pending Redemption: " + getarraysize(.@id);
  58. for (set .@i,0; .@i < getarraysize(.@id); set .@i,.@i+1)
  59. if (checkweight(.@nameid[.@i],.@quantity[.@i]) == 0) {
  60. mes "I'm terribly sorry, but you are carrying too much to accept " + (.@i ? "any more of " : " ") + "your rewards at this time.";
  61. mes "Please come back with fewer items.";
  62. } else {
  63. query_sql "UPDATE `" + escape_sql(.itemTable$) + "` SET `char_id` = " + getcharid(0) + ", `redeemed` = 1, `redemption_date` = NOW() WHERE `id` = " + .@id[.@i];
  64. getitem .@nameid[.@i],.@quantity[.@i];
  65. mes .@quantity[.@i] + "x " + getitemname(.@nameid[.@i]);
  66. }
  67. if (.@i == getarraysize(.@id)) {
  68. mes "Thank you for your patronage " + (Sex ? "fine sir." : "ma'am.");
  69. mes "Please enjoy your stay on " + .serverName$ + "!";
  70. }
  71. if (.showCredits)
  72. callfunc "F_FluxCredits";
  73. } else {
  74. mes "My records indicate that there are no rewards awaiting to be redeemed.";
  75. mes "My deepest apologies for the misunderstanding.";
  76. }
  77. break;
  78. case 3:
  79. query_sql("SELECT `balance` FROM `" + escape_sql(.redeemTable$) + "` WHERE `account_id` = " + getcharid(3) + " LIMIT 0,30", .@credits);
  80. mes "You currently have " + .@credits + " donation credits.";
  81. break;
  82. }
  83. close;
  84. // ------------------ End Script ------------------
  85. }
  86.  
  87. // ------------ Credits to FluxCP Creators ------------
  88. // - Please do not modify or delete this function or -
  89. // - its contents. To disable the credits from being -
  90. // - shown, set .showCredits to 0 in the NPC Settings -
  91. // - at the top of this file. -
  92. // ----------------------------------------------------
  93.  
  94. function script F_FluxCredits {
  95. mes "-----------------------------------";
  96. mes "Powered by Flux Control Panel.";
  97. mes "Copyright © 2008-2012 Matthew Harris and Nikunj Mehta.";
  98. mes "http://fluxcp.googlecode.com/";
  99. return;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement