Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Example
- echo changeRace($_POST['guid'],$_POST['newrace']);
- // The main function
- function changeRace($guid,$newrace) {
- // Data Base Settings
- $db_ip="127.0.0.1";
- $db_port="3306";
- $db_user="trinity";
- $db_password="trinity";
- mysql_connect($db_ip . ":" . $db_port,$db_user,$db_password);
- mysql_select_db("characters");
- $guid = (int)$guid;
- $newrace = (int)$newrace;
- $result=mysql_fetch_array(mysql_query("select * from characters where guid=" . $guid));
- if (mysql_affected_rows() > 0) {
- $oldrace=(int)$result['race'];
- $class=(int)$result['class'];
- if ((int)$result['online'] == 0) {
- if ($newrace > 0 && $newrace < 12 && $newrace != 9) {
- if ($newrace != $oldrace) {
- if ((isAlliance($newrace) && isAlliance($oldrace)) || (!isAlliance($newrace) && !isAlliance($oldrace))) {
- if (isGood($newrace,$class)) {
- delMounts($guid,$oldrace);
- addMounts($guid,$newrace);
- $result=mysql_fetch_array(mysql_query("select * from character_reputation where guid=" . $guid . " and faction=" . rep($oldrace))) or die(mysql_error());
- $oldRep = $result['standing'];
- $result=mysql_fetch_array(mysql_query("select * from character_reputation where guid=" . $guid . " and faction=" . rep($newrace))) or die(mysql_error());
- $newRep = $result['standing'];
- if (isAlliance($oldrace)) {
- 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());
- } else {
- 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());
- }
- mysql_query("update character_reputation set standing=". $oldRep . " where guid=" . $guid . " and faction=" . rep($newrace)) or die(mysql_error());
- mysql_query("update character_reputation set standing=". $newRep . " where guid=" . $guid . " and faction=" . rep($oldrace)) or die(mysql_error());
- mysql_query("update characters set race=". $newrace . " ,at_login=8 ,playerBytes=1 where guid=" . $guid) or die(mysql_error());
- return "Race successfully changed";
- } else { return "Your class cant be the chosen race"; }
- } else { return "You can't chage between enemies"; }
- } else { return "The new race and the original race are the same"; }
- } else { return "Race code invalid"; }
- } else { return "Please disconnect from your game account"; }
- } else { return "Error GUID is invalid"; }
- }
- function isAlliance($race) {
- if ($race == 1 || $race == 3 || $race == 4 || $race == 7 || $race == 11) {
- return true;
- }
- return false;
- }
- function isGood($race,$class) {
- switch ($race) {
- case 1:
- if ($class == 1 || $class == 2 || $class == 4 || $class == 5 || $class == 6 || $class == 8 || $class == 9) { return true; }
- break;
- case 2:
- if ($class == 1 || $class == 3 || $class == 4 || $class == 6 || $class == 7 || $class == 8 || $class == 9) { return true; }
- break;
- case 3:
- if ($class == 1 || $class == 2 || $class == 3 || $class == 4 || $class == 5 || $class == 6) { return true; }
- break;
- case 4:
- if ($class == 1 || $class == 3 || $class == 4 || $class == 5 || $class == 6 || $class == 11) { return true; }
- break;
- case 5:
- if ($class == 1 || $class == 4 || $class == 5 || $class == 6 || $class == 8 || $class == 9) { return true; }
- break;
- case 6:
- if ($class == 1 || $class == 3 || $class == 6 || $class == 7 || $class == 11) { return true; }
- break;
- case 7:
- if ($class == 1 || $class == 4 || $class == 6 || $class == 8 || $class == 9) { return true; }
- break;
- case 8:
- if ($class == 1 || $class == 3 || $class == 4 || $class == 5 || $class == 6 || $class == 7 || $class == Menő { return true; }
- break;
- case 10:
- if ($class == 2 || $class == 3 || $class == 4 || $class == 5 || $class == 6 || $class == 8 || $class == 9) { return true; }
- break;
- case 11:
- if ($class == 1 || $class == 2 || $class == 3 || $class == 5 || $class == 6 || $class == 7 || $class == Menő { return true; }
- break;
- }
- return false;
- }
- function rep($race) {
- switch ($race) {
- case 1:
- return 72;
- break;
- case 2:
- return 76;
- break;
- case 3:
- return 47;
- break;
- case 4:
- return 69;
- break;
- case 5:
- return 68;
- break;
- case 6:
- return 81;
- break;
- case 7:
- return 54;
- break;
- case 8:
- return 530;
- break;
- case 10:
- return 911;
- break;
- case 11:
- return 930;
- break;
- }
- }
- function delMounts($guid,$race) {
- switch ($race) {
- case 1:
- 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());
- 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());
- 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());
- break;
- case 2:
- 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());
- 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());
- 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());
- break;
- case 3:
- 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());
- 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());
- 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());
- break;
- case 4:
- 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());
- 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());
- 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());
- break;
- case 5:
- 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());
- 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());
- 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());
- break;
- case 6:
- 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());
- 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());
- 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());
- break;
- case 7:
- 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());
- 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());
- 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());
- break;
- case 8:
- 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());
- 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());
- 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());
- break;
- case 10:
- 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());
- 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());
- 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());
- break;
- case 11:
- 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());
- 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());
- 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());
- break;
- }
- }
- function addMounts($guid,$race) {
- switch ($race) {
- case 1:
- $mount1 = 472;
- $mount2 = 23229;
- case 2:
- $mount1 = 580;
- $mount2 = 23250;
- break;
- case 3:
- $mount1 = 6777;
- $mount2 = 23239;
- break;
- case 4:
- $mount1 = 8394;
- $mount2 = 23338;
- break;
- case 5:
- $mount1 = 64977;
- $mount2 = 23246;
- break;
- case 6:
- $mount1 = 18990;
- $mount2 = 23249;
- break;
- case 7:
- $mount1 = 10969;
- $mount2 = 23225;
- break;
- case 8:
- $mount1 = 8395;
- $mount2 = 23241;
- break;
- case 10:
- $mount1 = 35022;
- $mount2 = 35025;
- break;
- case 11:
- $mount1 = 34406;
- $mount2 = 35713;
- break;
- }
- $result=mysql_fetch_array(mysql_query("select * from character_spell where guid=" . $guid . " and spell=33388"));
- if (mysql_affected_rows() == 1) {
- mysql_query("insert into character_spell (guid,spell) values (" . $guid . "," . $mount1 . ")");
- }
- $result=mysql_fetch_array(mysql_query("select * from character_spell where guid=" . $guid . " and (spell=33391 or spell=34090 or spell=34091)"));
- if (mysql_affected_rows() == 1) {
- mysql_query("insert into character_spell (guid,spell) values (" . $guid . "," . $mount1 . ")");
- mysql_query("insert into character_spell (guid,spell) values (" . $guid . "," . $mount2 . ")");
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement