Advertisement
Guest User

Untitled

a guest
Jul 31st, 2014
474
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.21 KB | None | 0 0
  1. CREATE TABLE `groups` (
  2. `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  3. `name` VARCHAR(255) NOT NULL COMMENT 'group name',
  4. `flags` BIGINT UNSIGNED NOT NULL DEFAULT 0,
  5. `access` INT NOT NULL,
  6. `maxdepotitems` INT NOT NULL,
  7. `maxviplist` INT NOT NULL,
  8. PRIMARY KEY (`id`)
  9. ) ENGINE = InnoDB;
  10.  
  11. CREATE TABLE `accounts` (
  12. `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  13. `password` VARCHAR(255) NOT NULL/* VARCHAR(32) NOT NULL COMMENT 'MD5'*//* VARCHAR(40) NOT NULL COMMENT 'SHA1'*/,
  14. `email` VARCHAR(255) NOT NULL DEFAULT '',
  15. `premend` INT UNSIGNED NOT NULL DEFAULT 0,
  16. `blocked` TINYINT(1) NOT NULL DEFAULT FALSE,
  17. `deleted` TINYINT(1) NOT NULL DEFAULT FALSE,
  18. `warned` TINYINT(1) NOT NULL DEFAULT FALSE,
  19. `warnings` INT NOT NULL DEFAULT 0,
  20. PRIMARY KEY (`id`)
  21. ) ENGINE = InnoDB;
  22.  
  23. CREATE TABLE `players` (
  24. `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  25. `name` VARCHAR(255) NOT NULL,
  26. `account_id` INT UNSIGNED NOT NULL,
  27. `group_id` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'users group',
  28. `sex` INT UNSIGNED NOT NULL DEFAULT 0,
  29. `vocation` INT UNSIGNED NOT NULL DEFAULT 0,
  30. `experience` BIGINT UNSIGNED NOT NULL DEFAULT 0,
  31. `level` INT UNSIGNED NOT NULL DEFAULT 1,
  32. `maglevel` INT UNSIGNED NOT NULL DEFAULT 0,
  33. `health` INT UNSIGNED NOT NULL DEFAULT 100,
  34. `healthmax` INT UNSIGNED NOT NULL DEFAULT 100,
  35. `mana` INT UNSIGNED NOT NULL DEFAULT 100,
  36. `manamax` INT UNSIGNED NOT NULL DEFAULT 100,
  37. `manaspent` INT UNSIGNED NOT NULL DEFAULT 0,
  38. `soul` INT UNSIGNED NOT NULL DEFAULT 0,
  39. `direction` INT UNSIGNED NOT NULL DEFAULT 0,
  40. `lookbody` INT UNSIGNED NOT NULL DEFAULT 10,
  41. `lookfeet` INT UNSIGNED NOT NULL DEFAULT 10,
  42. `lookhead` INT UNSIGNED NOT NULL DEFAULT 10,
  43. `looklegs` INT UNSIGNED NOT NULL DEFAULT 10,
  44. `looktype` INT UNSIGNED NOT NULL DEFAULT 136,
  45. `posx` INT NOT NULL DEFAULT 0,
  46. `posy` INT NOT NULL DEFAULT 0,
  47. `posz` INT NOT NULL DEFAULT 0,
  48. `cap` INT NOT NULL DEFAULT 0,
  49. `lastlogin` INT UNSIGNED NOT NULL DEFAULT 0,
  50. `lastip` INT UNSIGNED NOT NULL DEFAULT 0,
  51. `save` TINYINT(1) NOT NULL DEFAULT TRUE,
  52. `conditions` BLOB NOT NULL COMMENT 'drunk, poisoned etc (maybe also food and redskull)',
  53. `redskulltime` INT UNSIGNED NOT NULL DEFAULT 0,
  54. `redskull` TINYINT(1) NOT NULL DEFAULT FALSE,
  55. `guildnick` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'additional nick in guild - mostly for web interfaces i think',
  56. `loss_experience` INT NOT NULL DEFAULT 10,
  57. `loss_mana` INT NOT NULL DEFAULT 10,
  58. `loss_skills` INT NOT NULL DEFAULT 10,
  59. `loss_items` INT NOT NULL DEFAULT 10,
  60. `rank_id` INT UNSIGNED NOT NULL COMMENT 'by this field everything with guilds is done - player has a rank which belongs to certain guild',
  61. `town_id` INT NOT NULL COMMENT 'old masterpos, temple spawn point position',
  62. `balance` INT NOT NULL DEFAULT 0 COMMENT 'money balance of the player for houses paying',
  63. `status` TINYINT(1) NOT NULL DEFAULT FALSE,
  64. PRIMARY KEY (`id`),
  65. UNIQUE (`name`),
  66. FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE,
  67. FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`)
  68. ) ENGINE = InnoDB;
  69.  
  70. CREATE TABLE `guilds` (
  71. `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  72. `name` VARCHAR(255) NOT NULL COMMENT 'guild name - nothing else needed here',
  73. `ownerid` INT NOT NULL,
  74. `creationdata` INT NOT NULL,
  75. PRIMARY KEY (`id`)
  76. ) ENGINE = InnoDB;
  77.  
  78. CREATE TABLE `guild_ranks` (
  79. `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  80. `guild_id` INT UNSIGNED NOT NULL COMMENT 'guild',
  81. `name` VARCHAR(255) NOT NULL COMMENT 'rank name',
  82. `level` INT NOT NULL COMMENT 'rank level - leader, vice, member, maybe something else',
  83. PRIMARY KEY (`id`),
  84. FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE
  85. ) ENGINE = InnoDB;
  86.  
  87. CREATE TABLE `player_viplist` (
  88. `player_id` INT UNSIGNED NOT NULL COMMENT 'id of player whose viplist entry it is',
  89. `vip_id` INT UNSIGNED NOT NULL COMMENT 'id of target player of viplist entry',
  90. FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE,
  91. FOREIGN KEY (`vip_id`) REFERENCES `players` (`id`) ON DELETE CASCADE
  92. ) ENGINE = InnoDB;
  93.  
  94. CREATE TABLE `player_spells` (
  95. `player_id` INT UNSIGNED NOT NULL,
  96. `name` VARCHAR(255) NOT NULL,
  97. FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE
  98. ) ENGINE = InnoDB;
  99.  
  100. CREATE TABLE `server_record` (
  101. `record` INT UNSIGNED NOT NULL,
  102. PRIMARY KEY(`record`)
  103. ) ENGINE = InnoDB;
  104.  
  105. INSERT INTO `server_record` VALUES (0);
  106.  
  107. CREATE TABLE `player_storage` (
  108. `player_id` INT UNSIGNED NOT NULL,
  109. `key` INT NOT NULL,
  110. `value` INT NOT NULL,
  111. FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE
  112. ) ENGINE = InnoDB;
  113.  
  114. CREATE TABLE `player_skills` (
  115. `player_id` INT UNSIGNED NOT NULL,
  116. `skillid` INT UNSIGNED NOT NULL,
  117. `value` INT UNSIGNED NOT NULL DEFAULT 0,
  118. `count` INT UNSIGNED NOT NULL DEFAULT 0,
  119. FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE
  120. ) ENGINE = InnoDB;
  121.  
  122. CREATE TABLE `player_items` (
  123. `player_id` INT UNSIGNED NOT NULL,
  124. `sid` INT NOT NULL,
  125. `pid` INT NOT NULL DEFAULT 0,
  126. `itemtype` INT NOT NULL,
  127. `count` INT NOT NULL DEFAULT 0,
  128. `attributes` BLOB COMMENT 'replaces unique_id, action_id, text, special_desc',
  129. FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE,
  130. UNIQUE (`player_id`, `sid`)
  131. ) ENGINE = InnoDB;
  132.  
  133. CREATE TABLE `houses` (
  134. `id` INT UNSIGNED NOT NULL,
  135. `owner` INT NOT NULL,
  136. `paid` INT UNSIGNED NOT NULL DEFAULT 0,
  137. `warnings` INT NOT NULL DEFAULT 0,
  138. `lastwarning` INT UNSIGNED NOT NULL DEFAULT 0,
  139. PRIMARY KEY (`id`)
  140. ) ENGINE = InnoDB;
  141.  
  142. CREATE TABLE `house_lists` (
  143. `house_id` INT UNSIGNED NOT NULL,
  144. `listid` INT NOT NULL,
  145. `list` TEXT NOT NULL,
  146. FOREIGN KEY (`house_id`) REFERENCES `houses` (`id`) ON DELETE CASCADE
  147. ) ENGINE = InnoDB;
  148.  
  149. CREATE TABLE `bans` (
  150. `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  151. `type` INT NOT NULL COMMENT 'this field defines if its ip, account, player, or any else ban',
  152. `value` INT UNSIGNED NOT NULL COMMENT 'ip, player guid, account number',
  153. `param` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'mask',
  154. `active` TINYINT(1) NOT NULL DEFAULT TRUE,
  155. `expires` INT UNSIGNED NOT NULL,
  156. `added` INT UNSIGNED NOT NULL,
  157. `admin_id` INT UNSIGNED NOT NULL DEFAULT 0,
  158. `reason` VARCHAR(255) NOT NULL DEFAULT '',
  159. `comment` VARCHAR(255) NOT NULL DEFAULT '',
  160. PRIMARY KEY (`id`),
  161. KEY (`type`, `value`),
  162. KEY (`expires`)
  163. ) ENGINE = InnoDB;
  164.  
  165. CREATE TABLE `tiles` (
  166. `id` INT UNSIGNED NOT NULL,
  167. `x` INT NOT NULL,
  168. `y` INT NOT NULL,
  169. `z` INT NOT NULL,
  170. PRIMARY KEY(`id`)
  171. ) ENGINE = InnoDB;
  172.  
  173. CREATE TABLE `tile_items` (
  174. `tile_id` INT UNSIGNED NOT NULL,
  175. `sid` INT NOT NULL,
  176. `pid` INT NOT NULL DEFAULT 0,
  177. `itemtype` INT NOT NULL,
  178. `count` INT NOT NULL DEFAULT 0,
  179. `attributes` BLOB NOT NULL,
  180. FOREIGN KEY (`tile_id`) REFERENCES `tiles` (`id`) ON DELETE CASCADE,
  181. INDEX (`sid`)
  182. ) ENGINE = InnoDB;
  183.  
  184. CREATE TABLE `map_store` (
  185. `house_id` INT UNSIGNED NOT NULL,
  186. `data` BLOB NOT NULL,
  187. KEY(`house_id`)
  188. ) ENGINE = InnoDB;
  189.  
  190. CREATE TABLE `player_depotitems` (
  191. `player_id` INT UNSIGNED NOT NULL,
  192. `depot_id` INT NOT NULL DEFAULT 0,
  193. `sid` INT NOT NULL COMMENT 'any given range eg 0-100 will be reserved for depot lockers and all > 100 will be then normal items inside depots',
  194. `pid` INT NOT NULL DEFAULT 0,
  195. `itemtype` INT NOT NULL,
  196. `count` INT NOT NULL DEFAULT 0,
  197. `attributes` BLOB NOT NULL,
  198. FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE,
  199. INDEX (`player_id`, `depot_id`),
  200. UNIQUE (`player_id`, `sid`)
  201. ) ENGINE = InnoDB;
  202.  
  203. CREATE TABLE `player_deaths` (
  204. `player_id` INT UNSIGNED NOT NULL,
  205. `time` BIGINT UNSIGNED NOT NULL DEFAULT 0,
  206. `level` INT UNSIGNED NOT NULL DEFAULT 1,
  207. `lasthit_killer` VARCHAR(255) NOT NULL,
  208. `mostdamage_killer` VARCHAR(255) NOT NULL,
  209. KEY (`player_id`),
  210. FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE
  211. ) ENGINE = InnoDB;
  212.  
  213. CREATE TABLE `global_storage` (
  214. `key` INT UNSIGNED NOT NULL,
  215. `value` INT NOT NULL,
  216. PRIMARY KEY(`key`)
  217. ) ENGINE = InnoDB;
  218.  
  219. CREATE TABLE `schema_info` (
  220. `version` INT UNSIGNED NOT NULL
  221. ) ENGINE = InnoDB;
  222.  
  223. INSERT INTO `schema_info` (`version`) VALUES (2);
  224.  
  225. DELIMITER |
  226.  
  227. CREATE TRIGGER `ondelete_accounts`
  228. BEFORE DELETE
  229. ON `accounts`
  230. FOR EACH ROW
  231. BEGIN
  232. DELETE FROM `bans` WHERE `type` = 3 AND `value` = OLD.`id`;
  233. END|
  234.  
  235. CREATE TRIGGER `ondelete_guilds`
  236. BEFORE DELETE
  237. ON `guilds`
  238. FOR EACH ROW
  239. BEGIN
  240. UPDATE `players` SET `guildnick` = '', `rank_id` = 0 WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = OLD.`id`);
  241. DELETE FROM `guild_ranks` WHERE `guild_id` = OLD.`id`;
  242. END|
  243.  
  244. CREATE TRIGGER `ondelete_players`
  245. BEFORE DELETE
  246. ON `players`
  247. FOR EACH ROW
  248. BEGIN
  249. DELETE FROM `bans` WHERE `type` = 2 AND `value` = OLD.`id`;
  250. UPDATE `houses` SET `owner` = 0 WHERE `owner` = OLD.`id`;
  251. END|
  252.  
  253. CREATE TRIGGER `oncreate_guilds`
  254. AFTER INSERT
  255. ON `guilds`
  256. FOR EACH ROW
  257. BEGIN
  258. INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('Leader', 3, NEW.`id`);
  259. INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('Vice-Leader', 2, NEW.`id`);
  260. INSERT INTO `guild_ranks` (`name`, `level`, `guild_id`) VALUES ('Member', 1, NEW.`id`);
  261. END|
  262.  
  263. CREATE TRIGGER `oncreate_players`
  264. AFTER INSERT
  265. ON `players`
  266. FOR EACH ROW
  267. BEGIN
  268. INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 0, 10);
  269. INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 1, 10);
  270. INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 2, 10);
  271. INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 3, 10);
  272. INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 4, 10);
  273. INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 5, 10);
  274. INSERT INTO `player_skills` (`player_id`, `skillid`, `value`) VALUES (NEW.`id`, 6, 10);
  275. END|
  276.  
  277. DELIMITER ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement