Advertisement
Guest User

Untitled

a guest
May 21st, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.68 KB | None | 0 0
  1. <?php
  2. // Example
  3. echo changeRace($_POST['guid'],$_POST['newrace']);
  4.  
  5. // The main function
  6. function changeRace($guid,$newrace) {
  7. // Data Base Settings
  8. $db_ip="127.0.0.1";
  9. $db_port="3306";
  10. $db_user="trinity";
  11. $db_password="trinity";
  12.  
  13. mysql_connect($db_ip . ":" . $db_port,$db_user,$db_password);
  14. mysql_select_db("characters");
  15. $guid = (int)$guid;
  16. $newrace = (int)$newrace;
  17. $result=mysql_fetch_array(mysql_query("select * from characters where guid=" . $guid));
  18. if (mysql_affected_rows() > 0) {
  19. $oldrace=(int)$result['race'];
  20. $class=(int)$result['class'];
  21. if ((int)$result['online'] == 0) {
  22. if ($newrace > 0 && $newrace < 12 && $newrace != 9) {
  23. if ($newrace != $oldrace) {
  24. if ((isAlliance($newrace) && isAlliance($oldrace)) || (!isAlliance($newrace) && !isAlliance($oldrace))) {
  25. if (isGood($newrace,$class)) {
  26. delMounts($guid,$oldrace);
  27. addMounts($guid,$newrace);
  28. $result=mysql_fetch_array(mysql_query("select * from character_reputation where guid=" . $guid . " and faction=" . rep($oldrace))) or die(mysql_error());
  29. $oldRep = $result['standing'];
  30. $result=mysql_fetch_array(mysql_query("select * from character_reputation where guid=" . $guid . " and faction=" . rep($newrace))) or die(mysql_error());
  31. $newRep = $result['standing'];
  32. if (isAlliance($oldrace)) {
  33. mysql_query("update character_achievement_progress set counter=10500 where guid=" . $guid . " and (criteria=2030 or criteria=2031 or criteria=2032 or criteria=2033 or criteria=2034)") or die(mysql_error());
  34. } else {
  35. mysql_query("update character_achievement_progress set counter=10500 where guid=" . $guid . " and (criteria=992 or criteria=993 or criteria=994 or criteria=995 or criteria=996)") or die(mysql_error());
  36. }
  37. mysql_query("update character_reputation set standing=". $oldRep . " where guid=" . $guid . " and faction=" . rep($newrace)) or die(mysql_error());
  38. mysql_query("update character_reputation set standing=". $newRep . " where guid=" . $guid . " and faction=" . rep($oldrace)) or die(mysql_error());
  39. mysql_query("update characters set race=". $newrace . " ,at_login=8 ,playerBytes=1 where guid=" . $guid) or die(mysql_error());
  40. return "Race successfully changed";
  41. } else { return "Your class cant be the chosen race"; }
  42. } else { return "You can't chage between enemies"; }
  43. } else { return "The new race and the original race are the same"; }
  44. } else { return "Race code invalid"; }
  45. } else { return "Please disconnect from your game account"; }
  46. } else { return "Error GUID is invalid"; }
  47. }
  48.  
  49.  
  50. function isAlliance($race) {
  51. if ($race == 1 || $race == 3 || $race == 4 || $race == 7 || $race == 11) {
  52. return true;
  53. }
  54. return false;
  55. }
  56. function isGood($race,$class) {
  57. switch ($race) {
  58. case 1:
  59. if ($class == 1 || $class == 2 || $class == 4 || $class == 5 || $class == 6 || $class == 8 || $class == 9) { return true; }
  60. break;
  61. case 2:
  62. if ($class == 1 || $class == 3 || $class == 4 || $class == 6 || $class == 7 || $class == 8 || $class == 9) { return true; }
  63. break;
  64. case 3:
  65. if ($class == 1 || $class == 2 || $class == 3 || $class == 4 || $class == 5 || $class == 6) { return true; }
  66. break;
  67. case 4:
  68. if ($class == 1 || $class == 3 || $class == 4 || $class == 5 || $class == 6 || $class == 11) { return true; }
  69. break;
  70. case 5:
  71. if ($class == 1 || $class == 4 || $class == 5 || $class == 6 || $class == 8 || $class == 9) { return true; }
  72. break;
  73. case 6:
  74. if ($class == 1 || $class == 3 || $class == 6 || $class == 7 || $class == 11) { return true; }
  75. break;
  76. case 7:
  77. if ($class == 1 || $class == 4 || $class == 6 || $class == 8 || $class == 9) { return true; }
  78. break;
  79. case 8:
  80. if ($class == 1 || $class == 3 || $class == 4 || $class == 5 || $class == 6 || $class == 7 || $class == 8) { return true; }
  81. break;
  82. case 10:
  83. if ($class == 2 || $class == 3 || $class == 4 || $class == 5 || $class == 6 || $class == 8 || $class == 9) { return true; }
  84. break;
  85. case 11:
  86. if ($class == 1 || $class == 2 || $class == 3 || $class == 5 || $class == 6 || $class == 7 || $class == 8) { return true; }
  87. break;
  88. }
  89. return false;
  90.  
  91. }
  92. function rep($race) {
  93. switch ($race) {
  94. case 1:
  95. return 72;
  96. break;
  97. case 2:
  98. return 76;
  99. break;
  100. case 3:
  101. return 47;
  102. break;
  103. case 4:
  104. return 69;
  105. break;
  106. case 5:
  107. return 68;
  108. break;
  109. case 6:
  110. return 81;
  111. break;
  112. case 7:
  113. return 54;
  114. break;
  115. case 8:
  116. return 530;
  117. break;
  118. case 10:
  119. return 911;
  120. break;
  121. case 11:
  122. return 930;
  123. break;
  124. }
  125. }
  126. function delMounts($guid,$race) {
  127. switch ($race) {
  128. case 1:
  129. mysql_query("delete from character_spell where guid=" . $guid . " and (spell=472 or spell=6648 or spell=458 or spell=470 or spell=23229 or spell=23228 or spell=23227 or spell=63232 or spell=65640)") or die(mysql_error());
  130. mysql_query("delete from character_aura where guid=" . $guid . " and (spell=472 or spell=6648 or spell=458 or spell=470 or spell=23229 or spell=23228 or spell=23227 or spell=63232 or spell=65640)") or die(mysql_error());
  131. mysql_query("delete from character_inventory where guid=" . $guid . " and (item_template=2414 or item_template=5655 or item_template=5656 or item_template=2411 or item_template=18777 or item_template=18778 or item_template=18776 or item_template=45125 or item_template=46752)") or die(mysql_error());
  132. break;
  133. case 2:
  134. mysql_query("delete from character_spell where guid=" . $guid . " and (spell=580 or spell=6653 or spell=6654 or spell=64658 or spell=23250 or spell=23252 or spell=23251 or spell=63640 or spell=65646)") or die(mysql_error());
  135. mysql_query("delete from character_aura where guid=" . $guid . " and (spell=580 or spell=6653 or spell=6654 or spell=64658 or spell=23250 or spell=23252 or spell=23251 or spell=63640 or spell=65646)") or die(mysql_error());
  136. mysql_query("delete from character_inventory where guid=" . $guid . " and (item_template=1132 or item_template=5665 or item_template=5668 or item_template=46099 or item_template=18796 or item_template=18798 or item_template=18797 or item_template=45595 or item_template=46749)") or die(mysql_error());
  137. break;
  138. case 3:
  139. mysql_query("delete from character_spell where guid=" . $guid . " and (spell=6777 or spell=6898 or spell=6899 or spell=23239 or spell=23240 or spell=23238 or spell=63636 or spell=65643)") or die(mysql_error());
  140. mysql_query("delete from character_aura where guid=" . $guid . " and (spell=6777 or spell=6898 or spell=6899 or spell=23239 or spell=23240 or spell=23238 or spell=63636 or spell=65643)") or die(mysql_error());
  141. mysql_query("delete from character_inventory where guid=" . $guid . " and (item_template=5864 or item_template=5873 or item_template=5872 or item_template=18787 or item_template=18785 or item_template=18786 or item_template=45586 or item_template=46748)") or die(mysql_error());
  142. break;
  143. case 4:
  144. mysql_query("delete from character_spell where guid=" . $guid . " and (spell=8394 or spell=10789 or spell=10793 or spell=66847 or spell=23338 or spell=23219 or spell=23221 or spell=63637 or spell=65638)") or die(mysql_error());
  145. mysql_query("delete from character_aura where guid=" . $guid . " and (spell=8394 or spell=10789 or spell=10793 or spell=66847 or spell=23338 or spell=23219 or spell=23221 or spell=63637 or spell=65638)") or die(mysql_error());
  146. mysql_query("delete from character_inventory where guid=" . $guid . " and (item_template=8631 or item_template=8632 or item_template=8629 or item_template=47100 or item_template=18902 or item_template=18767 or item_template=18766 or item_template=45591 or item_template=46744)") or die(mysql_error());
  147. break;
  148. case 5:
  149. mysql_query("delete from character_spell where guid=" . $guid . " and (spell=64977 or spell=17464 or spell=17463 or spell=17462 or spell=17465 or spell=23246 or spell=66846 or spell=63643 or spell=65645)") or die(mysql_error());
  150. mysql_query("delete from character_aura where guid=" . $guid . " and (spell=64977 or spell=17464 or spell=17463 or spell=17462 or spell=17465 or spell=23246 or spell=66846 or spell=63643 or spell=65645)") or die(mysql_error());
  151. mysql_query("delete from character_inventory where guid=" . $guid . " and (item_template=46308 or item_template=13333 or item_template=13332 or item_template=13331 or item_template=13334 or item_template=18791 or item_template=47101 or item_template=45597 or item_template=46746)") or die(mysql_error());
  152. break;
  153. case 6:
  154. mysql_query("delete from character_spell where guid=" . $guid . " and (spell=18990 or spell=18989 or spell=64657 or spell=23249 or spell=23248 or spell=23247 or spell=63641 or spell=65641)") or die(mysql_error());
  155. mysql_query("delete from character_aura where guid=" . $guid . " and (spell=18990 or spell=18989 or spell=64657 or spell=23249 or spell=23248 or spell=23247 or spell=63641 or spell=65641)") or die(mysql_error());
  156. mysql_query("delete from character_inventory where guid=" . $guid . " and (item_template=15290 or item_template=15277 or item_template=46100 or item_template=18794 or item_template=18795 or item_template=18793 or item_template=45592 or item_template=46750)") or die(mysql_error());
  157. break;
  158. case 7:
  159. mysql_query("delete from character_spell where guid=" . $guid . " and (spell=10969 or spell=17453 or spell=10873 or spell=17454 or spell=23225 or spell=23223 or spell=23222 or spell=63638 or spell=65642)") or die(mysql_error());
  160. mysql_query("delete from character_aura where guid=" . $guid . " and (spell=10969 or spell=17453 or spell=10873 or spell=17454 or spell=23225 or spell=23223 or spell=23222 or spell=63638 or spell=65642)") or die(mysql_error());
  161. mysql_query("delete from character_inventory where guid=" . $guid . " and (item_template=8595 or item_template=13321 or item_template=8563 or item_template=13322 or item_template=18772 or item_template=18773 or item_template=18774 or item_template=45589 or item_template=46747)") or die(mysql_error());
  162. break;
  163. case 8:
  164. mysql_query("delete from character_spell where guid=" . $guid . " and (spell=8395 or spell=10796 or spell=10799 or spell=23241 or spell=23242 or spell=23243 or spell=63635 or spell=65644)") or die(mysql_error());
  165. mysql_query("delete from character_aura where guid=" . $guid . " and (spell=8395 or spell=10796 or spell=10799 or spell=23241 or spell=23242 or spell=23243 or spell=63635 or spell=65644)") or die(mysql_error());
  166. mysql_query("delete from character_inventory where guid=" . $guid . " and (item_template=8588 or item_template=8591 or item_template=8592 or item_template=18788 or item_template=18789 or item_template=18790 or item_template=45593 or item_template=46743)") or die(mysql_error());
  167. break;
  168. case 10:
  169. mysql_query("delete from character_spell where guid=" . $guid . " and (spell=35022 or spell=35020 or spell=34795 or spell=35018 or spell=35025 or spell=35027 or spell=33660 or spell=63642 or spell=65639)") or die(mysql_error());
  170. mysql_query("delete from character_aura where guid=" . $guid . " and (spell=35022 or spell=35020 or spell=34795 or spell=35018 or spell=35025 or spell=35027 or spell=33660 or spell=63642 or spell=65639)") or die(mysql_error());
  171. mysql_query("delete from character_inventory where guid=" . $guid . " and (item_template=29221 or item_template=29220 or item_template=28927 or item_template=29222 or item_template=29223 or item_template=29224 or item_template=28936 or item_template=45596 or item_template=46751)") or die(mysql_error());
  172. break;
  173. case 11:
  174. mysql_query("delete from character_spell where guid=" . $guid . " and (spell=34406 or spell=35710 or spell=35711 or spell=35713 or spell=35712 or spell=35714 or spell=63639 or spell=65637)") or die(mysql_error());
  175. mysql_query("delete from character_aura where guid=" . $guid . " and (spell=34406 or spell=35710 or spell=35711 or spell=35713 or spell=35712 or spell=35714 or spell=63639 or spell=65637)") or die(mysql_error());
  176. mysql_query("delete from character_inventory where guid=" . $guid . " and (item_template=28481 or item_template=29744 or item_template=29743 or item_template=29745 or item_template=29746 or item_template=29747 or item_template=45590 or item_template=46745)") or die(mysql_error());
  177. break;
  178. }
  179. }
  180. function addMounts($guid,$race) {
  181. switch ($race) {
  182. case 1:
  183. $mount1 = 472;
  184. $mount2 = 23229;
  185. case 2:
  186. $mount1 = 580;
  187. $mount2 = 23250;
  188. break;
  189. case 3:
  190. $mount1 = 6777;
  191. $mount2 = 23239;
  192. break;
  193. case 4:
  194. $mount1 = 8394;
  195. $mount2 = 23338;
  196. break;
  197. case 5:
  198. $mount1 = 64977;
  199. $mount2 = 23246;
  200. break;
  201. case 6:
  202. $mount1 = 18990;
  203. $mount2 = 23249;
  204. break;
  205. case 7:
  206. $mount1 = 10969;
  207. $mount2 = 23225;
  208. break;
  209. case 8:
  210. $mount1 = 8395;
  211. $mount2 = 23241;
  212. break;
  213. case 10:
  214. $mount1 = 35022;
  215. $mount2 = 35025;
  216. break;
  217. case 11:
  218. $mount1 = 34406;
  219. $mount2 = 35713;
  220. break;
  221. }
  222. $result=mysql_fetch_array(mysql_query("select * from character_spell where guid=" . $guid . " and spell=33388"));
  223. if (mysql_affected_rows() == 1) {
  224. mysql_query("insert into character_spell (guid,spell) values (" . $guid . "," . $mount1 . ")");
  225. }
  226. $result=mysql_fetch_array(mysql_query("select * from character_spell where guid=" . $guid . " and (spell=33391 or spell=34090 or spell=34091)"));
  227. if (mysql_affected_rows() == 1) {
  228. mysql_query("insert into character_spell (guid,spell) values (" . $guid . "," . $mount1 . ")");
  229. mysql_query("insert into character_spell (guid,spell) values (" . $guid . "," . $mount2 . ")");
  230. }
  231. }
  232. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement