Advertisement
akbare

Guild-ranker

Oct 3rd, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.60 KB | None | 0 0
  1. //===== eAthena Script =======================================
  2. //= Guild Manager
  3. //===== By ===================================================
  4. //= lllchrislll
  5. //===== Version ==============================================
  6. //= 1.0 - Script Made
  7. // - Added many features (Didn't write that down...)
  8. // - Added the possiblity to use the donation via an Shop
  9. // Items can only be set by the GM's, see 'OnInit'
  10. // - Fixxed some bugs with the Reward Function
  11. // Reward can only be set by the GM's, see 'OnInit'
  12. //= 1.1 - Changed Reward Giving via Quest, also fixxed some bugs reported by darkis
  13. // - Rewritten the Ranking Check, well it is using more memory now.... (Sorry for that)
  14. // - Added an Random EXP Boost depending how much "rank" points
  15. // you possess, also added an menu option for it, see 'G_EXP'.
  16. // - Also rewritten the explanation how to add this system to WoE:SE
  17. //= 1.2 - Removed the Quest Area from preventing exploits.
  18. //====== ToDo List ===========================================
  19. //= Guild Shop: Looking for way to prevent the usage of your own Zeny instead
  20. // of the donation for checking if you want to buy something
  21. // Well, I found a way, but would cause a huge exploit.....
  22. //= Ranking Decrease: - How about when you lost a castle?
  23. // Previous WoE: 3, This WoE: 2 > -1 Rank for Guild only or Member too? ;I
  24. //
  25. //===== Compatible/Created/Tested With ======================================
  26. //= eAthena SQL 14434 Trunk
  27. //===== Description ==========================================
  28. //= This Script handles a Ranking System in the Guild itself,
  29. //= the ranking itself can increase and decrease.
  30. //= Increasing the Ranking:
  31. // - Donating money to the guild, which can be used by the
  32. // Guild Master only
  33. // - Emperium Break during WoE
  34. //
  35. //= Decreasing of the Ranking:
  36. // - Killing the Guild Members in PvP Rooms
  37. // - Being offline for 1 week without telling the
  38. // guild master, to update the "Holiday List".
  39. //
  40. //= Also you can recieve other rewards from breaking the Emp,
  41. // which is done by collecting points.
  42. //===== MySQL Entries =======================================
  43. /* //= Member Table:
  44. DROP TABLE IF EXISTS `guild_rank_mem`;
  45. CREATE TABLE `guild_rank_mem` (
  46. `char_id` int(10) unsigned NOT NULL,
  47. `guild_id` smallint(5) unsigned NOT NULL,
  48. `rank` smallint(5) unsigned DEFAULT '0',
  49. `woe` smallint(5) unsigned DEFAULT '0',
  50. `donate` int(11) unsigned DEFAULT '0',
  51. `donate_am` int(11) unsigned DEFAULT '0',
  52. `holiday` smallint(5) unsigned DEFAULT '0',
  53. PRIMARY KEY (`char_id`)
  54. ) ENGINE=MyISAM;
  55. //= Guild Table:
  56. DROP TABLE IF EXISTS `guild_rank_guild`;
  57. CREATE TABLE `guild_rank_guild` (
  58. `guild_id` smallint(5) unsigned NOT NULL,
  59. `type` smallint(5) unsigned DEFAULT '1',
  60. `rank` smallint(5) unsigned DEFAULT '0',
  61. `woe` smallint(5) unsigned DEFAULT '0',
  62. `donate` int(11) unsigned DEFAULT '0',
  63. `donate_min` int(11) unsigned DEFAULT '0',
  64. `donate_max` int(11) unsigned DEFAULT '0',
  65. PRIMARY KEY (`guild_id`)
  66. ) ENGINE=MyISAM;
  67. */
  68. //===== Comments =============================================
  69. //= You need to edit the following line in the
  70. // npc/guild/agit_template.txt
  71. //========== Find this ==========//
  72. /*
  73. // Adjust Economy Invest Level for Castle
  74. set .@Economy,GetCastleData(strnpcinfo(2),2) - 5;
  75. if (.@Economy < 0) set .@Economy, 0;
  76.  
  77. //========== Add above ==========//
  78. // Callfunc for Guild Rank System
  79. callfunc "GLD_RANK_WOE";
  80.  
  81. //= WoE:SE : Open these file under npc/guild2/
  82. arug_cas02.txt arug_cas04.txt schg_cas01.txt schg_cas03.txt schg_cas05.txt
  83. arug_cas01.txt arug_cas03.txt arug_cas05.txt schg_cas02.txt schg_cas04.txt
  84.  
  85. //========== Find this, which only shows up once every file. =========//
  86. mapannounce "arug_cas01","The emperium has been shattered!",bc_map,"0x00FF00",FW_NORMAL,20,0,40;
  87. // ------- or -------- //
  88. announce "The emperium has been shattered!",bc_map,"0x00FF00",FW_NORMAL,20,0,40;
  89.  
  90. //========== Add after ==========//
  91. // Callfunc for Guild Rank System
  92. callfunc "GLD_RANK_WOE";
  93. */
  94. //============================================================
  95. - script GuildRanks#Events -1,{
  96. end;
  97.  
  98. OnInit:
  99. query_sql "SHOW TABLES LIKE 'guild_rank_guild'",.@ch_gld_tbl$;
  100. query_sql "SHOW TABLES LIKE 'guild_rank_mem'",.@ch_mem_tbl$;
  101. if($gld_ranker_tbl == 1) {
  102.  
  103. // If the tables exists
  104. if(.@ch_gld_tbl$[0] != "" && .@ch_mem_tbl$[0] != "") {
  105. end;
  106.  
  107. // If one of the tables doesn't exists
  108. } else if(.@ch_gld_tbl[0] == "" || .@ch_mem_tbl[0] == "") {
  109. query_sql "DROP TABLE IF EXISTS `guild_rank_guild`";
  110. query_sql "DROP TABLE IF EXISTS `guild_rank_mem`";
  111. set $gld_ranker_tbl,0;
  112. }
  113. }
  114. // Checking if the System is on or not
  115. if(!$gld_ranker_tbl) disablenpc "GuildRanks#Events"; end;
  116.  
  117. setarray .expboost[0],5,10,15,20,25; // Exp Boost in %
  118. setarray .rankreq[0],15,30,60,120,240; // Rank Points required
  119. // Example: To gain 15% EXP Bonus, you need 60 Rank Points.
  120. set .boostuse,1; // Which day it will be activated on: 0-6 = Sunday - Saturday, 7 = Random
  121. switch(.boostuse) {
  122. case 0: set .expdayn$,"Sunday"; break;
  123. case 1: set .expdayn$,"Monday"; break;
  124. case 2: set .expdayn$,"Tuesday"; break;
  125. case 3: set .expdayn$,"Wednesday"; break;
  126. case 4: set .expdayn$,"Thursday"; break;
  127. case 5: set .expdayn$,"Friday"; break;
  128. case 6: set .expdayn$,"Saturday"; break;
  129. default: set .expdayn$,"a random day."; break;
  130. }
  131. set .GldEXPBoost,0;
  132.  
  133. if(gettime(4) == ( (.boostuse != 7) ? .boostuse : rand(7) ) ) {
  134. set .GldEXPBoost,1;
  135. announce "Guild Rank System: EXP Bonus has been activated.",0,0x00FF00;
  136. }
  137. end;
  138.  
  139. OnNPCKillEvent:
  140. if(!getcharid(2)) end; // If the player is not in a guild.
  141. // =========== EXP Boost ============== //
  142. if(.GldEXPBoost == 1) {
  143. if(EXPLastRank < query_sql("SELECT `rank` FROM `guild_rank_mem` WHERE `guild_id` = '"+getcharid(2)+"' AND `char_id` = '"+getcharid(0)+"'",@rank) ) {
  144. set EXPLastRank,@rank;
  145. for( set @b,0; @b < getarraysize(.rankreq); set @b,@b + 1) {
  146. if(EXPLastRank >= .rankreq[@b]) {
  147. if(.rankreq[@b+1] != 0) {
  148. set EXPBoost,.expboost[@b];
  149. if(EXPLastRank < .rankreq[@b+1] ) break;
  150. } else {
  151. set EXPBoost,.expboost[@b];
  152. break;
  153. }
  154. }
  155. }
  156. }
  157. set @bexp,(getmonsterinfo(killedrid,3)*EXPBoost);
  158. if(getgmlevel()) dispbottom "Debug: Monster: "+getmonsterinfo(killedrid,0)+" with "+@bexp+" Base EXP, "+@jexp+" Job EXP";
  159. set @jexp,(getmonsterinfo(killedrid,4)*EXPBoost);
  160. set BaseEXP,BaseEXP + @bexp;
  161. set JobEXP,JobEXP + @jexp;
  162. dispbottom "EXP Bonus: "+EXPBoost+"%. You have recieved additionally "+@bexp+" Base EXP and "+@jexp+" Job EXP.";
  163. }
  164. end;
  165.  
  166. OnPCKillEvent:
  167. if(!getcharid(2)) end;
  168. if(getmapflag(strcharinfo(3),mf_pvp) == 0) end;
  169.  
  170. query_sql "SELECT `name` FROM `guild_member` WHERE `guild_id` = '"+getcharid(2)+"'",@gld_mem$;
  171. set @Killer$,rid2name(killerrid);
  172. for( set @gpvp,0; @gm < getarraysize(@gld_mem$); set @gpvp,@gpvp + 1) {
  173. if(@Killer$ == @gld_mem$[@gpvp]) {
  174. query_sql "UPDATE `guild_rank_mem` SET `rank` = `rank` - 1 WHERE `guild_id` = '"+getcharid(2)+"' AND `char_id` = '"+getcharid(0,@Killer$)+"'";
  175. break;
  176. }
  177. }
  178. donpcevent "::OnReset";
  179. end;
  180.  
  181. OnPCLogoutEvent:
  182. if(!getcharid(2)) end;
  183. if(query_sql("SELECT `holiday` FROM `guild_rank_mem` WHERE `guild_id` = '"+getcharid(2)+"' AND `char_id` = '"+getcharid(0)+"'",@holiday) == 0) {
  184. set gld_off_log,gettimetick(2) + 691200; // 8 Days
  185. set gld_last,getcharid(2);
  186. }
  187. end;
  188.  
  189. OnPCLoginEvent:
  190. if($gld_ranker_tbl) announce "The Guild Ranking System is online.",4,0x00FF00;
  191. if(.GldEXPBoost == 1) announce "Guild Rank System: EXP Bonus has been activated.",4,0x00FF00;;
  192. // Don't enable these lines, NEVER!! Need a solution for this problem
  193. // if(BkpZeny != 0) { set Zeny,BkpZeny; set BkpZeny,0; } // Guild Shop Exploit Preventing
  194. if(!getcharid(2)) end;
  195. set EXPBoost,0;
  196. if(gld_last != getcharid(2)) set gld_off_log,0; end;
  197. query_sql "SELECT `holiday` FROM `guild_rank_mem` WHERE `guild_id` = '"+getcharid(2)+"' AND `char_id` = '"+getcharid(0)+"'",@holiday;
  198. if(@holiday == 0 && (gettimetick(2) > gld_off_log)) {
  199. query_sql "UPDATE `guild_rank_mem` SET `rank` = `rank` - 1 WHERE `guild_id` = '"+getcharid(2)+"' AND `char_id` = '"+getcharid(0)+"'";
  200. } else {
  201. set gld_off_log,0;
  202. }
  203. end;
  204.  
  205. // ========================= Auto Guild Checking =========================//
  206. // This part checks the Registered Guilds and their members.
  207. // If the guild doesn't exists anymore or an Member has left a guild,
  208. // they will be deleted from the ranking and if the new Guild is registered
  209. // it will insert them into the new guild.
  210. // ==========================================================================
  211. OnClock0000:
  212. set .GldEXPBoost,0;
  213. if(gettime(4) == ( (.boostuse != 7) ? .boostuse : rand(7) ) ) {
  214. set .GldEXPBoost,1;
  215. announce "Guild Rank System: EXP Bonus has been activated.",0,0x00FF00;;
  216. }
  217. OnRankCheck:
  218. // Which Guild is registered and still exists
  219. query_sql "SELECT `guild_id` FROM `guild_rank_guild`",.@gld_ids;
  220. for( set .@w,0; .@w < getarraysize(.@gld_ids); set .@w,.@w + 1) {
  221. if(query_sql("SELECT `guild_id` FROM `guild` WHERE `guild_id` = '"+.@gld_ids[.@w]+"'",.@c_gld) != 0) {
  222.  
  223. // Getting the Guild Member ID's from the Guild_Member Table
  224. query_sql "SELECT `char_id` FROM `guild_member` WHERE `guild_id` = '"+.@gld_ids[.@w]+"'",.@gld_mem;
  225.  
  226. for ( set .@m,0; .@m < getarraysize(.@gld_mem); set .@m,.@m+1) {
  227. // Checking if the Member is in the ranking
  228. if(query_sql("SELECT `char_id` FROM `guild_rank_mem` WHERE `guild_id` = '"+.@gld_ids[.@w]+"' AND `char_id` = '"+.@gld_mem[.@m]+"'",.@c_chid) == 0) {
  229.  
  230. // Checking in which Guild the Member is
  231. if(query_sql("SELECT `guild_id` FROM `guild_member` WHERE `char_id` = '"+.@gld_mem[.@m]+"'",.@c_gid) != .@gld_ids[.@w]) {
  232.  
  233. // If the Member doesn't exists anymore in this guild
  234. query_sql "DELETE FROM `guild_rank_mem` WHERE `char_id` = '"+.@gld_mem[.@m]+"'";
  235. }
  236.  
  237. // Member is not in the ranking
  238. query_sql "INSERT INTO `guild_rank_mem` ( `guild_id` , `char_id` ) VALUES ( '"+.@gld_ids[.@w]+"' , '"+.@gld_mem[.@m]+"' )";
  239. }
  240. }
  241. // If the Guild doesn't exist anymore delete it from the ranking.
  242. } else {
  243. query_sql "DELETE FROM `guild_rank_guild` WHERE `guild_id` = '"+.@gld_ids[.@w]+"'";
  244. query_sql "DELETE FROM `guild_rank_mem` WHERE `guild_id` = '"+.@gld_ids[.@w]+"'";
  245. callsub OnGuildBreak;
  246. }
  247. }
  248. donpcevent "::OnReset";
  249. end;
  250.  
  251. OnGuildBreak:
  252. announce "The guild "+getguildname(.@gld_ids[.@w])+" has been disbanded.",0,0xFF0000;
  253.  
  254. OnReset:
  255. deletearray .@gld_ids[0],getarraysize(.@gld_ids);
  256. deletearray .@gld_mem[0],getarraysize(.@gld_mem);
  257. deletearray .@c_chid[0],getarraysize(.@c_chid);
  258. deletearray .@c_gid[0],getarraysize(.@c_gid);
  259. end;
  260. }
  261.  
  262. //OnAgitBreak:
  263. function script GLD_RANK_WOE {
  264. query_sql "SELECT `type` FROM `guild_rank_guild` WHERE `guild_id` = '"+getcharid(2)+"'",@type;
  265. if(@type == 1) {
  266. query_sql "UPDATE `guild_rank_mem` SET `rank` = `rank` + 1 , `woe` = `woe` + 1 WHERE `guild_id` = '"+getcharid(2)+"' AND `char_id` = '"+getcharid(0)+"'";
  267. query_sql "UPDATE `guild_rank_guild` SET `rank` = `rank` + 1 , `woe` = `woe` + 1 WHERE `guild_id` = '"+getcharid(2)+"'";
  268. announce "You have gained 1 Point for breaking an Emperium while WoE.",4,0xFF0000;
  269. }
  270. //end;
  271. return;
  272. }
  273.  
  274. // ===================== Guild Shop Pre-Setting ==================== //
  275. - shop GUILD_SHOP -1,512:-1
  276.  
  277. // ===================== Guild Rank Manager ====================== //
  278. prontera,152,193,4 script Guild Ranker#gldrank 110,{
  279. callsub G_Array;
  280. set .@n$,"[Guild Ranker]";
  281. set .@last_id,25077; // Highest Item ID
  282. set @guild_id,getcharid(2);
  283.  
  284. OnStart:
  285. mes .@n$;
  286. // **********************************************************************//
  287. // // GM Menu Selection \\ //
  288. // **********************************************************************//
  289. if(getgmlevel() >= 80) {
  290. mes "Player or GM Menu?";
  291. menu "Player Menu",-,"GM Menu",G_GM;
  292. next;
  293. mes .@n$;
  294. }
  295. // **********************************************************************//
  296. // // No MySQL Entries made \\ //
  297. // **********************************************************************//
  298. if(!$gld_ranker_tbl) {
  299. mes "I'm sorry, but";
  300. mes "the System hasn't been";
  301. mes "enabled yet.";
  302. close;
  303. }
  304. // **********************************************************************//
  305. // // Not in a Guild \\ //
  306. // **********************************************************************//
  307. if(!@guild_id) {
  308. mes "I'm sorry, but you";
  309. mes "are not in a guild.";
  310. close;
  311. }
  312. // **********************************************************************//
  313. // // Main Greeting \\ //
  314. // **********************************************************************//
  315. mes "Hello, "+strcharinfo(0)+"!";
  316. if(query_sql("SELECT `guild_id` FROM `guild_rank_guild` WHERE `guild_id` = '"+@guild_id+"'",@gld_check) == 0) {
  317. mes "As I can see your Guild has not been registered yet,";
  318. if(strcharinfo(0) == getguildmaster(@guild_id)) {
  319. mes "wanna register it now?";
  320. next;
  321. if(select("- Yes register:- No, thanks") == 2) {
  322. goto G_Quit;
  323. } else {
  324. goto G_Register;
  325. }
  326. } else {
  327. mes "if you want to join,";
  328. mes "please inform your Guild Master about it.";
  329. close;
  330. }
  331. }
  332. mes "How can I help ya?";
  333. next;
  334. if(strcharinfo(0) == getguildmaster(@guild_id)) {
  335. if(select("- Guild Master Menu:- Member Menu") == 1) {
  336. menu "- Guild Summary",G_Summary,"- EXP Boost Info",G_EXP,"- Guild Shop",G_Shop,"- Donation Limit",G_Donate_L,"- Holiday List",G_Holiday,"- Nothing",G_Quit;
  337. }
  338. }
  339. menu "- Guild Summary",G_Summary,"- EXP Boost Info",G_EXP,"- See Ranking",G_Rank,"- Get Reward",G_Reward,"- Donation",G_Donate,"- Nothing",G_Quit;
  340.  
  341. // **********************************************************************//
  342. // // Guild Summary \\ //
  343. // **********************************************************************//
  344.  
  345. G_Summary:
  346. query_sql "SELECT `type` , `donate` , `donate_min` , `donate_max` FROM `guild_rank_guild` WHERE `guild_id` = '"+@guild_id+"'",@type,@donate,@donate_min,@donate_max;
  347. mes .@n$;
  348. mes "Guild Type: "+ ( (@type == 2) ? "Non-WoE" : "WoE");
  349. mes " ";
  350. mes "Donation Status:";
  351. mes "Currently we have "+@donate+" Zeny on our Account.";
  352. mes "Donation Limit:";
  353. mes "Minium: " + @donate_min + " Zeny."; // Donate Minimum Amount
  354. mes "Maximum: " + @donate_max + " Zeny."; // Donate Maximum Amount
  355. close;
  356.  
  357. // **********************************************************************//
  358. // // EXP Boost Info \\ //
  359. // **********************************************************************//
  360.  
  361. G_EXP:
  362. mes .@n$;
  363. mes "The EXP Boost is global to every guild.";
  364. mes "The boost depends on your rank and the percent set by the GM Team.";
  365. mes "And will be activated on "+getvariableofnpc(.expdayn$,"GuildRanks#Events");
  366. mes "Status: " + ( (getvariableofnpc(.GldEXPBoost,"GuildRanks#Events") == 1) ? "Active" : "Not Active.");
  367. mes " ";
  368. mes "Current Rank Requirements and EXP Boost.";
  369. for( set @e,0; @e < getarraysize(getvariableofnpc(.expboost,"GuildRanks#Events")); set @e,@e + 1) {
  370. mes getvariableofnpc(.rankreq[@e],"GuildRanks#Events")+" Points = "+getvariableofnpc(.expboost[@e],"GuildRanks#Events")+"% EXP Boost.";
  371. }
  372. close;
  373.  
  374. // **********************************************************************//
  375. // // Ranking \\ //
  376. // **********************************************************************//
  377.  
  378. G_Rank:
  379. mes .@n$;
  380. mes "What kind of ranking";
  381. mes "do you want to see?";
  382. next;
  383. switch(select("- Donation:- WoE:- All")) {
  384.  
  385. // **********************************************************************//
  386. // // Total Donation \\ //
  387. // **********************************************************************//
  388.  
  389. case 1:
  390. mes .@n$;
  391. query_sql "SELECT `char_id` , `donate` , `donate_am` FROM `guild_rank_mem` WHERE `guild_id` = '"+@guild_id+"' ORDER BY `donate_am` DESC",@char_id,@donate,@donate_am;
  392. query_sql "SELECT `donate` FROM `guild_rank_guild` WHERE `guild_id` = '"+@guild_id+"'",@donate_total;
  393. mes "Total Donation:";
  394. mes @donate_total;
  395. mes " ";
  396. mes "Name - Quantity - Donated Amount Total";
  397. for( set @gm,0; @gm < getarraysize(@char_id); set @gm,@gm + 1) {
  398. query_sql "SELECT `name` FROM `guild_member` WHERE `guild_id` = '"+@guild_id+"' AND `char_id` = '"+@char_id[@gm]+"'",@c_name$;
  399. mes @c_name$+" - "+@donate[@gm]+" - "+@donate_am[@gm];
  400. }
  401. close;
  402.  
  403. // **********************************************************************//
  404. // // Emperium Breaks \\ //
  405. // **********************************************************************//
  406.  
  407. case 2:
  408. mes .@n$;
  409. query_sql "SELECT `char_id` , `woe` FROM `guild_rank_mem` WHERE `guild_id` = '"+@guild_id+"' ORDER BY `woe` DESC",@char_id,@woe;
  410. query_sql "SELECT `woe` FROM `guild_rank_guild` WHERE `guild_id` = '"+@guild_id+"'",@woe2;
  411. mes "Total Emp Breaks:";
  412. mes @woe2;
  413. mes " ";
  414. mes "Name - Break Quantity";
  415. for( set @gm,0; @gm < getarraysize(@char_id); set @gm,@gm + 1) {
  416. query_sql "SELECT `name` FROM `guild_member` WHERE `guild_id` = '"+@guild_id+"' AND `char_id` = '"+@char_id[@gm]+"'",@c_name$;
  417. mes @c_name$+" - "+@woe[@gm];
  418. }
  419. close;
  420.  
  421. // **********************************************************************//
  422. // // Member Ranking \\ //
  423. // **********************************************************************//
  424.  
  425. case 3:
  426. mes .@n$;
  427. query_sql "SELECT `char_id` , `rank` FROM `guild_rank_mem` WHERE `guild_id` = '"+@guild_id+"' ORDER BY `rank` DESC",@char_id,@rank;
  428. mes "Name - Ranking";
  429. for( set @gm,0; @gm < getarraysize(@char_id); set @gm,@gm + 1) {
  430. query_sql "SELECT `name` FROM `guild_member` WHERE `guild_id` = '"+@guild_id+"' AND `char_id` = '"+@char_id[@gm]+"'",@c_name$;
  431. mes @c_name$+" - "+@rank[@gm];
  432. }
  433. close;
  434. }
  435.  
  436. // **********************************************************************//
  437. // // Recieving Reward \\ //
  438. // **********************************************************************//
  439. G_Reward:
  440. query_sql "SELECT `woe` FROM `guild_rank_mem` WHERE `guild_id` = '"+@guild_id+"' AND `char_id` = '"+getcharid(0)+"'",@woe;
  441. mes .@n$;
  442. mes "Your current balance is:";
  443. mes "WoE Points: "+@woe;
  444. next;
  445. mes .@n$;
  446. mes "Reward - Points needed";
  447. mes .rew_woe_need[0] + ". " + .rew_woe_am[0] + "x " + ( (.rew_woe[0] == 1) ? " Zeny": getitemname(.rew_woe[0]) + " (ID:" + .rew_woe[0] + ")" ) + " - "+.rew_woe_need[0];
  448. set @r_menu$,"- "+.rew_woe_need[0] + " "+( (.rew_woe_need[0] > 1) ? "Points": "Point");
  449. for( set @r,1; @r < getarraysize(.rew_woe); set @r,@r+1) {
  450. mes .rew_woe_am[@r] + "x " + ( (.rew_woe[@r] == 1) ? " Zeny": getitemname(.rew_woe[@r]) + " (ID: " + .rew_woe[@r] + ")" ) + " - "+.rew_woe_need[@r];
  451. set @r_menu$,@r_menu$ + ":- "+.rew_woe_need[@r] + " "+( (.rew_woe_need[@r] > 1) ? "Points": "Point");
  452. }
  453. mes " ";
  454. mes "Please choose the reward you want.";
  455. next;
  456. switch(prompt(@r_menu$)) {
  457.  
  458. default:
  459. set @m,@menu - 1;
  460. break;
  461.  
  462. case 255:
  463. goto G_Quit;
  464. break;
  465. }
  466. mes .@n$;
  467. mes "You have chosen:";
  468. mes .rew_woe_am[@m] + "x " + ( (.rew_woe[@m] == 1) ? " Zeny": getitemname(.rew_woe[@m]) + " (ID: " + .rew_woe[@m] + ")" ) + " - "+.rew_woe_need[@m];
  469. mes "Is that correct?";
  470. next;
  471. if(select("- Yes:- No") == 2) {
  472. goto G_Quit;
  473. } else {
  474. mes .@n$;
  475. if(.rew_woe_need[@m] > @woe) {
  476. mes "I'm sorry, but it seems you don't have enough points for this reward.";
  477. close;
  478. }
  479. if(.rew_woe[@m] == 1) {
  480. mes "You have recieved "+.@rew_woe_am[@m]+" Zeny.";
  481. set Zeny,Zeny + .rew_woe_am[@m];
  482. } else {
  483. mes "You have recieved "+.rew_woe_am[@m] + "x "+getitemname(.rew_woe[@m]);
  484. getitem .rew_woe[@m],.rew_woe_am[@m];
  485. }
  486. query_sql "UPDATE `guild_rank_mem` SET `woe` = `woe` - "+.rew_woe_need[@m]+" WHERE `guild_id` = '"+@guild_id+"' AND `char_id` = '"+getcharid(0)+"'";
  487. close;
  488. }
  489.  
  490. // **********************************************************************//
  491. // // Making Donation \\ //
  492. // **********************************************************************//
  493.  
  494. G_Donate:
  495. query_sql "SELECT `donate` , `donate_min` , `donate_max` FROM `guild_rank_guild` WHERE `guild_id` = '"+@guild_id+"'",@donate,@donate_min,@donate_max;
  496. mes .@n$;
  497. if(@donate_min < 1) {
  498. mes "Your Guild Master hasn't set the";
  499. mes "Donation Limit yet.";
  500. close;
  501. }
  502. mes "Total Donation: "+@donate;
  503. mes "The account can hold up to "+.don_limit+" Zeny.";
  504. if(@donate < .don_limit) {
  505. mes (.don_limit - @donate) +" can be donated until the limit will be reached.";
  506. } else if(@donate >= .don_limit) {
  507. mes "Limit reached, the account is full.";
  508. mes "Please wait until your Guild Master used some donations up.";
  509. close;
  510. }
  511. mes "You can donate once per week.";
  512. mes "The minimum amount is " + @donate_min + " Zeny"; // Donate Minimum Amount
  513. mes "and the maximum "+ @donate_max + " Zeny."; // Donate Maximum Amount
  514. next;
  515. if(@guild_id == last_gld && gld_don_delay > gettimetick(2)) {
  516. mes .@n$;
  517. mes "I'm sorry, but the week hasn't passed yet.";
  518. close;
  519.  
  520. } else if(@guild_id != last_gld) { set gld_don_delay,0; }
  521.  
  522. if(input(@do_don,@donate_min,@donate_max) != 0) {
  523. mes .@n$;
  524. mes "You have put an invalid amount.";
  525. close;
  526. }
  527. if(Zeny < @do_don) {
  528. mes .@n$;
  529. mes "You don't have the needed money.";
  530. close;
  531. }
  532. if( (@donate + @do_don) >= .don_limit) {
  533. mes "The donation you are trying to make is too much for the account to handle.";
  534. mes "Please wait until your Guild Master uses some donations.";
  535. close;
  536. }
  537. query_sql "UPDATE `guild_rank_mem` SET `donate` = donate + 1 , `donate_am` = donate_am + "+@do_don+" , `rank` = rank + 1 WHERE `guild_id` = '"+@guild_id+"' AND `char_id` = '"+getcharid(0)+"'";
  538. query_sql "UPDATE `guild_rank_guild` SET `donate` = donate + "+@do_don+" WHERE `guild_id` = '"+@guild_id+"'";
  539. set Zeny,Zeny - @do_don;
  540. set gld_don_delay,gettimetick(2) + 604800; // 1 Week Delay
  541. set last_gld,@guild_id;
  542. mes .@n$;
  543. mes "Thank you for your";
  544. mes "donation.";
  545. close;
  546.  
  547.  
  548. // **********************************************************************//
  549. // // Adding Donation Limit \\ //
  550. // **********************************************************************//
  551.  
  552. G_Donate_L:
  553. mes .@n$;
  554. mes "Type the minimum amount";
  555. mes "Note: Highest is 10,000,000";
  556. next;
  557. input @don_min;
  558. if(@don_min < 1 || @don_min > 10000000) close;
  559. mes .@n$;
  560. mes "Now the maximum amount:";
  561. mes "Note: Highest is 10,000,000 too";
  562. input @don_max;
  563. if(@don_max < @don_min || @don_max > 10000000) close;
  564. next;
  565. mes .@n$;
  566. mes "Result:";
  567. mes "Minium: "+@don_min;
  568. mes "Maximum: "+@don_max;
  569. mes " ";
  570. mes "Correct?";
  571. if(select("- Yes:- No") == 1) {
  572. query_sql "UPDATE `guild_rank_guild` SET `donate_min` = '"+@don_min+"' , `donate_max` = '"+@don_max+"' WHERE `guild_id` = '"+@guild_id+"'";
  573. }
  574. close;
  575.  
  576. // **********************************************************************//
  577. // // Guild Shop - using Donations \\ //
  578. // **********************************************************************//
  579.  
  580. G_Shop:
  581. query_sql "SELECT `donate` FROM `guild_rank_guild` WHERE `guild_id` = '"+@guild_id+"'",@don_total;
  582. mes .@n$;
  583. mes "Hello Master,";
  584. mes "how can I help you?";
  585. mes "You guild members have donated "+@don_total+" Zeny so far.";
  586. next;
  587. menu "Open Shop",-,"Nothing",G_Quit;
  588.  
  589. mes .@n$;
  590. mes "I will now open the shop for you.";
  591. mes "Note: The Skill Discount won't work here.";
  592. mes "The difference will be shown, but I will use the actual costs.";
  593. mes "Also it checks the Zeny in your inventory, so if you get enough";
  594. mes "donations, but not enough Zeny with you, it could result in an error.";
  595. close2;
  596. // Don't enable these lines, NEVER!! Need a solution for this problem
  597. // set BkpZeny,Zeny; // A way to surprass the bug by having not enough Zeny with you even if he uses the donations?
  598. // if(@don_total > .don_limit) set Zeny,.don_limit; else set Zeny,@don_total;
  599. callshop "GUILD_SHOP",1;
  600. npcshopattach "GUILD_SHOP";
  601. end;
  602.  
  603. OnBuyItem:
  604. for( set @bid,0; @bid < getarraysize(@bought_nameid); set @bid,@bid + 1) {
  605. for( set @sid,0; @sid < getarraysize(.gshop_id); set @sid,@sid + 1) {
  606. if(.gshop_id[@sid] == @bought_nameid[@bid]) {
  607. set @cost_item,(.gshop_cost[@sid]*@bought_quantity[@bid]);
  608. set @cost_total,(@cost_total+@cost_item);
  609. break;
  610. }
  611. }
  612. }
  613. query_sql "SELECT `donate` FROM `guild_rank_guild` WHERE `guild_id` = '"+@guild_id+"'",@don_total;
  614. if(@cost_total > .don_limit) {
  615. dispbottom "I'm sorry, but you can't buy this much at once.";
  616. dispbottom "Maximum is " + .don_limit + " Zeny.";
  617. } else {
  618. if(@cost_total > @don_total) {
  619. dispbottom "You don't have enough Zeny.";
  620. } else {
  621. for( set @buy,0; @buy < getarraysize(@bought_nameid); set @buy,@buy + 1) {
  622. getitem @bought_nameid[@buy],@bought_quantity[@buy];
  623. }
  624. dispbottom "Thank you for shopping.";
  625. dispbottom "You have used "+@cost_total+" Zeny of the Donations.";
  626. query_sql "UPDATE `guild_rank_guild` SET `donate` = `donate` - '"+@cost_total+"' WHERE `guild_id` = '"+@guild_id+"'";
  627. }
  628. }
  629. set @cost_total,0;
  630. deletearray @bought_nameid[0],128;
  631. deletearray @bought_quantity[0],128;
  632. // Don't enable this line, NEVER!! Need a solution for this problem
  633. // if(BkpZeny != 0) { set Zeny,BkpZeny; set BkpZeny,0; }
  634. end;
  635.  
  636. // **********************************************************************//
  637. // // Holiday List \\ //
  638. // **********************************************************************//
  639.  
  640. G_Holiday:
  641. mes .@n$;
  642. mes "What do you like to do?";
  643. next;
  644. switch(select("- Add:- Remove:- Show List:- Nothing")) {
  645.  
  646. // **********************************************************************//
  647. // // Adding Member on the Holiday List \\ //
  648. // **********************************************************************//
  649.  
  650. case 1:
  651. mes .@n$;
  652. mes "Type the member name you want to add:";
  653. next;
  654. input @hl_name$;
  655. query_sql "SELECT `char_id` FROM `guild_member` WHERE `guild_id` = '"+@guild_id+"' AND `name` = '"+escape_sql(@hl_name$)+"'",@char_id;
  656. if(!@char_id) {
  657. mes .@n$;
  658. mes "The name you have put is wrong.";
  659. close;
  660. }
  661. query_sql "UPDATE `guild_rank_mem` SET `holiday` = '1' WHERE `guild_id` = '"+@guild_id+"' AND `char_id` = '"+@char_id+"'";
  662. mes .@n$;
  663. mes "The member "+@hl_name$+" has been added to the \"Holiday List\".";
  664. close;
  665.  
  666. // **********************************************************************//
  667. // // Removing Member from the Holiday List \\ //
  668. // **********************************************************************//
  669.  
  670. case 2:
  671. mes .@n$;
  672. mes "Select the member from the list";
  673. mes "which you want to remove.";
  674. next;
  675. query_sql "SELECT `char_id` FROM `guild_rank_mem` WHERE `guild_id` = '"+@guild_id+"' AND `holiday` = '1'",@char_id;
  676. if(!@char_id) {
  677. mes .@n$;
  678. mes "There is no member in the list.";
  679. close;
  680. }
  681. query_sql "SELECT `name` FROM `guild_member` WHERE `guild_id` = '"+@guild_id+"' AND `char_id` = '"+@char_id[0]+"'",@char_n$;
  682. set @menu$,"- "+@char_n$[0];
  683. for( set @gm_s,1; @gm_s < getarraysize(@char_id); set @gm_s,@gm_s + 1) {
  684. query_sql "SELECT `name` FROM `guild_member` WHERE `guild_id` = '"+@guild_id+"' AND `char_id` = '"+@char_id[@gm_s]+"'",@char_n$;
  685. set @menu$,@menu$ + ":- "+@char_n$[@gm_s];
  686. }
  687. switch(prompt(@menu$)) {
  688.  
  689. default:
  690. set @h,@menu - 1;
  691.  
  692. mes .@n$;
  693. mes "You have chosen "+ @char_n$[@h];
  694. mes " ";
  695. mes "Wanna remove him/her?";
  696. if(select("- Yes:- No") == 2) close;
  697. next;
  698. query_sql "SELECT `char_id` FROM `guild_member` WHERE `guild_id` = '"+@guild_id+"' AND `name` = '"+escape_sql(@char_n$[@h])+"'",@char_id_n;
  699. query_sql "UPDATE `guild_rank_mem` SET `holiday` = '0' WHERE `guild_id` = '"+@guild_id+"' AND `char_id` = '"+@char_id_n+"'";
  700. mes .@n$;
  701. mes "The member "+@char_n$[@h]+" has been removed from the List.";
  702. close;
  703.  
  704. case 255:
  705. goto G_Quit;
  706. break;
  707. }
  708.  
  709. // **********************************************************************//
  710. // // Showing Holiday List \\ //
  711. // **********************************************************************//
  712.  
  713. case 3:
  714. mes .@n$;
  715. mes "These members has been";
  716. mes "put on the list:";
  717. next;
  718. query_sql "SELECT `char_id` FROM `guild_rank_mem` WHERE `guild_id` = '"+@guild_id+"' AND `holiday` = '1'",@char_id;
  719. if(!@char_id) {
  720. mes .@n$;
  721. mes "There is no member";
  722. mes "in the list.";
  723. close;
  724. }
  725. query_sql "SELECT `name` FROM `guild_member` WHERE `guild_id` = '"+@guild_id+"' AND `char_id` = '"+@char_id[0]+"'",@char_n$;
  726. mes @char_n$[0];
  727. for( set @gm_s,1; @gm_s < getarraysize(@char_id); set @gm_s,@gm_s + 1) {
  728. query_sql "SELECT `name` FROM `guild_member` WHERE `guild_id` = '"+@guild_id+"' AND `char_id` = '"+@char_id[@gm_s]+"'",@char_n$;
  729. mes @char_n$[@gm_s];
  730. }
  731. close;
  732.  
  733. case 4:
  734. goto G_Quit;
  735. break;
  736. }
  737.  
  738. // **********************************************************************//
  739. // // Guild Registering \\ //
  740. // **********************************************************************//
  741.  
  742. G_Register:
  743. mes .@n$;
  744. mes "You want to register your Guild for the our Ranking System?";
  745. mes "^FF0000Note: This ranking will be permanent until you are disbanding the guild.^000000";
  746. if(select("- Yes, please:- No, thanks") - 1) {
  747. close;
  748. } else {
  749. next;
  750. mes .@n$;
  751. mes "What type is your Guild?";
  752. set @type,select("- WoE:- Non-WoE");
  753. query_sql "INSERT INTO `guild_rank_guild` ( `guild_id` , `type` , `rank` , `woe` , `donate` , `donate_min` , `donate_max` ) VALUES ( '"+@guild_id+"' , '"+@type+"' , '0' , '0' , '0' , '0' , '0' )";
  754. query_sql "SELECT `char_id` FROM `guild_member` WHERE `guild_id` = '"+@guild_id+"' ORDER BY `char_id` ASC",@char_id;
  755. for( set @g,0; @g < getarraysize(@char_id); set @g,@g+1) {
  756. query_sql "INSERT INTO `guild_rank_mem` ( `guild_id` , `char_id` , `holiday` ) VALUES ( '"+@guild_id+"' , '"+@char_id[@g]+"' , '0' )";
  757. }
  758. close;
  759. }
  760.  
  761. // **********************************************************************//
  762. // // GM Menu \\ //
  763. // **********************************************************************//
  764.  
  765. G_GM:
  766. next;
  767. mes .@n$;
  768. mes "Hello "+strcharinfo(0)+",";
  769. if($gld_ranker_tbl) {
  770. mes "how can I help you?";
  771. next;
  772. switch(select("- Guild Ranks:- Re-Check Rank List:- Delete Tables")) {
  773.  
  774. case 1:
  775. query_sql "SELECT `guild_id` , `rank` , `woe` FROM `guild_rank_guild` WHERE `rank` > '0' ORDER BY `rank` DESC",.@r_gld,.@r_rank,.@r_woe;
  776. mes .@n$;
  777. mes "Only Guilds with Ranking Points will be displayed!";
  778. if(.@r_gld[0] == 0) {
  779. mes "There is no guild to display.";
  780. close;
  781. }
  782. mes "The format of the list";
  783. mes "will be like this:";
  784. mes " ";
  785. mes " Guild Name: Points";
  786. mes "===== Emp Breaks: ===";
  787. mes "x";
  788. mes "*******************";
  789. for( set @r,0; @r < getarraysize(.@r_gld); set @r,@r + 1) {
  790. next;
  791. mes getguildname(.@r_gld[@r])+": "+.@r_rank;
  792. mes "===== Emp Breaks: ===";
  793. mes .@r_woe[@r];
  794. mes "*******************";
  795. }
  796. close;
  797.  
  798. case 2:
  799. mes .@n$;
  800. mes "I will now re-check the Ranking Status for all guilds.";
  801. close2;
  802. doevent "GuildRanks#Events::OnRankCheck";
  803. end;
  804.  
  805. case 3:
  806. mes .@n$;
  807. mes "Are you sure to delete everything?";
  808. next;
  809. if(select("- Delete:- Nevermind") - 1) {
  810. close;
  811. } else {
  812. close2;
  813. query_sql "DROP TABLE IF EXISTS `guild_rank_guild`";
  814. query_sql "DROP TABLE IF EXISTS `guild_rank_mem`";
  815. disablenpc "GuildRanks#Events";
  816. announce "The Guild Ranking System is offline.",0,0xFF0000;
  817. set $gld_ranker_tbl,0;
  818. end;
  819. }
  820. }
  821. } else {
  822. mes "I'm sorry, but the ranking has not been activated yet,";
  823. mes "but it's also necessary to install the required entries in";
  824. mes "your database.";
  825. next;
  826. mes .@n$;
  827. mes "First I will check if you installed it through the entries at the top of the script file.";
  828. mes "Then I will activate it.";
  829. mes "If that is not the case, I will install and activate the system for you if you want.";
  830. next;
  831. query_sql "SHOW TABLES LIKE 'guild_rank_guild'",.@c_tbl$;
  832. if(.@c_tbl$[0] == "") {
  833. mes .@n$;
  834. mes "Result:";
  835. mes "The entries are not yet installed wanna install them?";
  836. next;
  837. if(select("- Install it~:- Na, it would fail!") - 1) {
  838. mes .@n$;
  839. mes "How do you wanna know without installing it!!";
  840. emotion e_bzz;
  841. percentheal -99,-99;
  842. close2;
  843. sleep2 2000;
  844. percentheal 100,100;
  845. end;
  846.  
  847. } else {
  848. mes .@n$;
  849. mes "Here we go~";
  850. //= Member Table:
  851. query_sql "CREATE TABLE `guild_rank_mem` ( `char_id` int(10) , `guild_id` smallint(5) , `rank` smallint(5) , `woe` smallint(5) , `donate` int(11) , `donate_am` int(11) , `holiday` smallint(5) )";
  852. //= Guild Table:
  853. query_sql "CREATE TABLE `guild_rank_guild` ( `guild_id` smallint(5) , `type` smallint(5) , `rank` smallint(5) , `woe` smallint(5) , `donate` int(11) , `donate_min` int(11) , `donate_max` int(11) )";
  854.  
  855. enablenpc "GuildRanks#Events";
  856. announce "The Guild Ranking System is online.",0,0x00FF00;
  857. set $gld_ranker_tbl,1;
  858. close;
  859. }
  860. } else {
  861. mes .@n$;
  862. mes "It seems like the entries has been installed,";
  863. mes "then I will activate the system if you want.";
  864. if(select("- Please proceed~:- Stop please") - 1) {
  865. close;
  866. } else {
  867. enablenpc "GuildRanks#Events";
  868. announce "The Guild Ranking System is online.",0,0x00FF00;
  869. set $gld_ranker_tbl,1;
  870. close;
  871. }
  872. }
  873. }
  874. // **********************************************************************//
  875. // // Closing Message \\ //
  876. // **********************************************************************//
  877. G_Quit:
  878. mes .@n$;
  879. mes "See ya again.";
  880. close;
  881.  
  882. G_Array:
  883. set @r_menu$,"";
  884. set .@rew_it_list$,"";
  885. deletearray .@c_tbl$[0],getarraysize(.@c_tbl$);
  886. deletearray @gld_mem$[0],getarraysize(@gld_mem$);
  887. deletearray @char_id[0],getarraysize(@char_id);
  888. deletearray @donate[0],getarraysize(@donate);
  889. deletearray @donate_am[0],getarraysize(@donate_am);
  890. deletearray @woe[0],getarraysize(@woe);
  891. deletearray @rank[0],getarraysize(@rank);
  892. deletearray .@r_gld[0],getarraysize(.@r_gld);
  893. deletearray .@r_rank[0],getarraysize(.@r_rank);
  894. deletearray .@r_woe[0],getarraysize(.@r_woe);
  895. return;
  896.  
  897. OnInit:
  898. // Guild Rewards:
  899. // .rew_woe: Item ID, when you put 1 it will give Zeny as Reward.
  900. // .rew_woe_am: Amount of the Items or Zeny.
  901. // .rew_woe_need: The points needed
  902. // For Emp Breaking
  903. setarray .rew_woe[0],1,969;
  904. setarray .rew_woe_am[0],50000,10;
  905. setarray .rew_woe_need[0],1,5;
  906. // Maximum Zeny for Donation Account
  907. set .don_limit,2000000000; // 2b Zeny
  908. // Attaching Items To the Shop
  909. npcshopdelitem "GUILD_SHOP",512;
  910. setarray .gshop_id[0],7619,7620;
  911. setarray .gshop_cost[0],200000,200000;
  912.  
  913. for ( set .@s,0; .@s < getarraysize(.gshop_id); set .@s,.@s + 1 ) {
  914. npcshopadditem "GUILD_SHOP",.gshop_id[.@s],.gshop_cost[.@s];
  915. }
  916. end;
  917. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement