Advertisement
Guest User

Untitled

a guest
Oct 13th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.46 KB | None | 0 0
  1.  
  2.  
  3. // ---
  4. //= Script administrador de Cash Points v1.0 [Rokimoki]
  5. // * Only SQL eAthena Version (trunk/stable)
  6. // * Add Cash Points
  7. // * Delete Cash Points
  8. // * Search Cash Points
  9. // * Only for Admins
  10. // * Password system in the script (Search "putyourpasswordhere" and modify the password)
  11. // * Notify if your cashpoint amount was changed, added/deleted and who changed (the guy who used this script) only if you are online when cash point was changed
  12. // * Notify if your cashpoint amount was changed when you was offline, if deleted or added but don't show who modified
  13. // * Log System, Store in your DB (SQL DB or TXT DB) User, Account ID, Cash Ammound (added or deleted), Affected Account ID in that cases:
  14. // -> If a GM input a wrong password
  15. // -> If a GM add/delete Cash Points to someone
  16. // ---
  17. //= Script works if the user affected is online or not
  18. // If online not SQL method, if offline SQL method, no need to relog game if online
  19. // ---
  20. - script Cashpoint -1,{
  21. OnWhisperGlobal:
  22. if (getgmlevel() < 99) { // If not admin shows cash point ammount
  23. dispbottom "Tu cantidad de cash points es: " +#CASHPOINTS;
  24. end;
  25. } // End if
  26. if (@whispervar0$ != "Cash") { // Password line
  27. logmes "User: " +strcharinfo(0) +" with account id: " +getcharid(3) +" has inserted a wrong pasword in SQL Manager NPC, he wrote: " +@whispervar0$; // PAWN!
  28. end;
  29. } // End if
  30. deletearray .@array$[0], 128; // Debug
  31. deletearray .@idcuenta[0], 128;
  32. set .@nombre$, "[^0000FFCash Point Assistant^000000]";
  33. mes .@nombre$;
  34. mes "Hello I'm the Cash Point Manager, choose what you want...";
  35. next;
  36. switch (select("Add Cash Points:Delete Cash Points:Search Cash Points:Exit")) {
  37. case 1: // Add cash points
  38. callfunc("CashPoints",1);
  39. break;
  40.  
  41. case 2: // Delete cash points
  42. callfunc("CashPoints",2);
  43. break;
  44.  
  45. case 3: // Search cash points
  46. callfunc("CashPoints",3);
  47. break;
  48.  
  49. case 4: // Exit
  50. mes "Bye bye...";
  51. break;
  52. } // End switch
  53. close;
  54.  
  55. OnPCLoginEvent: // Offline Notify
  56. if (#CASHPOINTS > UltimoCash) dispbottom "Hi, some admin has added some cash points to your account, actual balance: " +#CASHPOINTS +", before: " +UltimoCash;
  57. set UltimoCash, #CASHPOINTS;
  58. end;
  59. } // End Script
  60.  
  61. function script CashPoints {
  62. mes .@nombre$;
  63. mes "I need to know something first...";
  64. next;
  65. mes .@nombre$;
  66. if (select("Input character name:Input login account name") == 1) {
  67. mes "Input character name: ";
  68. next;
  69. input .@nombre$;
  70. query_sql "SELECT `account_id` FROM `char` WHERE `name` = '" +escape_sql(.@nombre$) +"'", .@idcuenta[0];
  71. } else {
  72. mes "Input login account name: ";
  73. next;
  74. input .@login$;
  75. query_sql "SELECT `account_id` FROM `login` WHERE `userid` = '" +escape_sql(.@login$) +"'", .@idcuenta[0];
  76. } // End if
  77. if (!.@idcuenta[0]) {
  78. mes "I'm sorry but I can't find anything with that datum you gave me, try again.";
  79. close;
  80. } // End if
  81. if (getarg(0) == 3) {
  82. if (isloggedin(.@idcuenta[0])) { // If online
  83. // Store GM data
  84. set .@gm$, strcharinfo(0);
  85. set .@id, getcharid(3);
  86. detachrid;
  87. // Attach user who will recieve cash points
  88. attachrid(.@idcuenta[0]);
  89. set .@cash, #CASHPOINTS; // Store current cash points
  90. detachrid;
  91. attachrid(.@id);
  92. mes .@nombre$;
  93. mes "User searched has in his account: ^FF0000" +.@cash +"^000000 Cash Points.";
  94. } else { // Si está Offline
  95. query_sql "SELECT `value` FROM global_reg_value WHERE `str` = '#CASHPOINTS' and account_id = " +.@idcuenta[0], .@valor[0]; // Store how many Cash Points
  96. if (!.@valor[0]) mes "That user has no Cash Point in his account."; // If he has Cash Points
  97. else mes "The user has ^FF0000" +.@valor[0] +"^000000 Cash Points in his account."; // If he hasn't Cash Points
  98. } // End if
  99. close;
  100. } // End if
  101. mes .@nombre$;
  102. mes "Now input the Cash Point amount: ";
  103. next;
  104. input .@cantidad, -1000000, 1000000; // Debug
  105. if (.@cantidad < 1 || .@cantidad > 1000000) { // Define here the max cash point value per use
  106. mes .@nombre$;
  107. mes "You have to input a valid value, must be positive number and lower than ^FF00001000000^000000 to avoid abuse."; // Modify number here
  108. close;
  109. } // End if
  110. if (isloggedin(.@idcuenta[0])) { // If online
  111. // Store GM data
  112. set .@gm$, strcharinfo(0);
  113. set .@id, getcharid(3);
  114. detachrid;
  115. // Attach user who will recieve cash points
  116. attachrid(.@idcuenta[0]);
  117. set .@cash, #CASHPOINTS; // Store current cash points
  118. if (getarg(0) == 1) {
  119. set #CASHPOINTS, #CASHPOINTS + .@cantidad; // Add cash points, map-server will do that
  120. dispbottom "The Admin [" + .@gm$ +"] has added you: " +.@cantidad +" cash points in your account, current cash points: " +#CASHPOINTS; // Online Notify
  121. } else if (getarg(0) == 2) {
  122. if (.@cash <= 0) {
  123. detachrid;
  124. attachrid(.@id);
  125. mes .@nombre$;
  126. mes "I'm sorry but you can't delete any cash point because he has no cash point in his account.";
  127. close;
  128. } else if (.@cash - .@cantidad < 0) {
  129. detachrid;
  130. attachrid(.@id);
  131. mes .@nombre$;
  132. mes "Sorry but you tried to delete so many cash points, you probably put his cash points to negative numbers, you only can delete ^FF0000" +.@cash +"^000000 cash points.";
  133. close;
  134. } // End if
  135. set #CASHPOINTS, #CASHPOINTS - .@cantidad; // Delete cash points, map-server will do that
  136. dispbottom "The Admin [" + .@gm$ +"] has deleted you: " +.@cantidad +" cash points in your account, current cash points: " +#CASHPOINTS; // Online Notify
  137. set .@accion, 1; // Semaphore
  138. } // End if
  139. detachrid;
  140. attachrid(.@id);
  141. } else { // If not online
  142. query_sql "SELECT `str` FROM global_reg_value WHERE account_id = " +.@idcuenta[0], .@array$[0]; // Check if he has any cash points
  143. if (.@array$[0] != "#CASHPOINTS") { // He has no cash points
  144. if (getarg(0) == 1) {
  145. query_sql "INSERT INTO `global_reg_value` (`char_id`,`str`,`value`,`type`,`account_id`) VALUES ('0','#CASHPOINTS','" +.@cantidad +"','2','" +.@idcuenta[0] +"')"; // Create SQL cash points
  146. } else {
  147. mes .@nombre$;
  148. mes "Sorry but you can't delete cash points since he has not.";
  149. close;
  150. } // End if
  151. } else { // He has cash points
  152. if (getarg(0) == 1) {
  153. query_sql "UPDATE global_reg_value SET `value` = `value` + '" +.@cantidad +"' WHERE `str` = '#CASHPOINTS' and account_id = '" +.@idcuenta[0] +"'"; // Update cash points value
  154. } else if (getarg(0) == 2) {
  155. query_sql "SELECT `value` FROM global_reg_value WHERE `str` = '#CASHPOINTS' and account_id = " +.@idcuenta[0], .@valor[0]; // Store cash points value
  156. mes .@nombre$;
  157. if (.@valor[0] <= 0) {
  158. mes "Sorry but you can't delete cash points since he has not.";
  159. close;
  160. } else if (.@valor[0] - .@cantidad < 0) {
  161. mes "Sorry but you tried to delete so many cash points, you probably put his cash points to negative numbers, you only can delete ^FF0000" +.@valor[0] +"^000000 cash points.";
  162. close;
  163. } // End if
  164. query_sql "UPDATE global_reg_value SET `value` = `value` - '" +.@cantidad +"' WHERE `str` = '#CASHPOINTS' and account_id = '" +.@idcuenta[0] +"'";
  165. set .@accion, 1; // Semaphore
  166. } // End if
  167. } // End if
  168. } // End if
  169. // Store LOGs
  170. if (!.@accion) logmes "The user: " +strcharinfo(0) +" with account id: " +getcharid(3) +" has added " +.@cantidad +" Cash Points to the account ID: " +.@idcuenta[0];
  171. else logmes "The user: " +strcharinfo(0) +" with account id: " +getcharid(3) +" has deleted " +.@cantidad +" Cash Points to the account ID: " +.@idcuenta[0];
  172. mes "The Cash Points was modified, thanks for using this servide made by ^FF0000Admin of Fullguard^000000 from eAthena forums.";
  173. return;
  174. } // End function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement