Here is my problem. In my game I am trying to implement this leveling system where once you reached a certain amount of experience that you advance to a higher level. I am using php 5.0 and the Latest MYSQL. My problem is that i cannot get my scripts to execute properly.
SO here are some dummy stats followed by my code Any information that would help me solve my problems would be greatly appreciated
$playerNAME = "Bozo";
$playerClASS = "Warrior";
$playerLEVEL = 13;
$playerSTR = 5;
$playerDEF = 2;
$playerDEX = 3;
$playerMAG = 2;
$playerEXPERIENCE = 99999;
when I go to levelup from 13 to 14 none of the stats are updated with a new value and the level dosnt update... Yes all my connections from the connect.php to the DB server are working properly and yes i am using the correct table names in my code
function levelUPSTATS () { global $playerNAME; global $playerClASS; global $playerLEVEL; global $playerSTR; global $playerDEF; global $playerDEX; global $playerMAG;
if ($playerCLASS === "Warrior") {
$playerSTR = $playerSTR + 3;
$playerDEF = $playerDEF + 2;
$playerDEX = $playerDEX + 3;
$playerMAG = $playerMAG + 2;
$playerBASE_DAMAGE = ceil($playerSTR*$playerDEX);
$playerSPELL_BASE_DAMAGE = ceil($playerMAG * $playerDEX);
$playerMAX_HEALTH_POINTS = ceil($playerSTR * $playerDEF * $playerDEX);
$playerMAX_MANA_POINTS = ceil($playerMAG * $playerDEF * $playerDEX / $playerSTR);
$statusplayerSTR = "update players set strength=strength+'$playerSTR' where username='$playerNAME'";
mysql_query($statusplayerSTR) or die("Could not update player");
$statusplayerDEF = "update players set defence=defence+'$playerDEF' where username='$playerNAME'";
mysql_query($statusplayerDEF) or die("Could not update player");
$statusplayerDEX = "update players set dexterity=dexterity+'$playerDEX' where username='$playerNAME'";
mysql_query($statusplayerDEX) or die("Could not update player");
$statusplayerMAG = "update players set magic=magic+'$playerMAG' where username='$playerNAME'";
mysql_query($statusplayerMAG) or die("Could not update player");
$statusplayerBASE_DAMAGE = "update players set basedamage=basedamage+'$playerBASE_DAMAGE' where username='$playerNAME'";
mysql_query($statusplayerBASE_DAMAGE) or die("Could not update player");
$statusplayerSPELL_BASE_DAMAGE = "update players set spellbasedamage=spellbasedamage+'$playerSPELL_BASE_DAMAGE' where username='$playerNAME'";
mysql_query($statusplayerSPELL_BASE_DAMAGE) or die("Could not update player");
$statusplayerHealthPOINTS = "update players set healthpoints='$playerMAX_HEALTH_POINTS' where username='$playerNAME'";
mysql_query($statusplayerHealthPOINTS) or die("Could not update player");
$statusplayerMaxHealthPOINTS = "update players set maxhealthpoints='$playerMAX_HEALTH_POINTS' where username='$playerNAME'";
mysql_query($statusplayerMaxHealthPOINTS) or die("Could not update player");
$statusplayerManaPOINTS = "update players set manapoints='$playerMAX_MANA_POINTS' where username='$playerNAME'";
mysql_query($statusplayerManaPOINTS) or die("Could not update player");
$statusplayerMaxManaPOINTS = "update players set maxmanapoints='$playerMAX_MANA_POINTS' where username='$playerNAME'";
mysql_query($statusplayerMaxManaPOINTS) or die("Could not update player");
} elseif ($playerCLASS === "Mage") {
$playerSTR = $playerSTR + 2;
$playerDEF = $playerDEF + 2;
$playerDEX = $playerDEX + 3;
$playerMAG = $playerMAG + 3;
$playerBASE_DAMAGE = ceil($playerSTR * $playerDEF);
$playerSPELL_BASE_DAMAGE = ceil($playerMAG * $playerDEX);
$playerMAX_HEALTH_POINTS = ceil($playerDEF * $playerDEX * $playerMAG);
$playerMAX_MANA_POINTS = ceil($playerMAG * $playerDEF * $playerDEX / $playerSTR);
} else {
}
}
if ($playerEXPERIENCE < 100) {
if (!$playerLEVEL ==1) {
$playerLEVEL = 1;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 100;
}
} elseif ($playerEXPERIENCE >= 100 && $playerEXPERIENCE <= 200) {
if (!$playerLEVEL ==2) {
levelUPSTATS ();
$playerLEVEL = 2;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 200;
}
} elseif ($playerEXPERIENCE >= 200 && $playerEXPERIENCE <= 400) {
if (!$playerLEVEL ==3) {
levelUPSTATS ();
$playerLEVEL = 3;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 400;
}
} elseif ($playerEXPERIENCE >= 400 && $playerEXPERIENCE <= 800) {
if (!$playerLEVEL ==4) {
levelUPSTATS ();
$playerLEVEL = 4;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 800;
}
} elseif ($playerEXPERIENCE >= 800 && $playerEXPERIENCE <= 1600) {
if (!$playerLEVEL ==5) {
levelUPSTATS ();
$playerLEVEL = 5;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 1600;
}
} elseif ($playerEXPERIENCE >= 1600 && $playerEXPERIENCE <= 3200) {
if (!$playerLEVEL ==6) {
levelUPSTATS ();
$playerLEVEL = 6;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 3200;
}
} elseif ($playerEXPERIENCE >= 3200 && $playerEXPERIENCE <= 6400) {
if (!$playerLEVEL ==7) {
levelUPSTATS ();
$playerLEVEL = 7;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 6400;
}
} elseif ($playerEXPERIENCE >= 6400 && $playerEXPERIENCE <= 12800) {
if (!$playerLEVEL ==8) {
levelUPSTATS ();
$playerLEVEL = 8;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 12800;
}
} elseif ($playerEXPERIENCE >= 12800 && $playerEXPERIENCE <= 25000) {
if (!$playerLEVEL ==9) {
levelUPSTATS ();
$playerLEVEL = 9;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 25000;
}
} elseif ($playerEXPERIENCE >= 25000 && $playerEXPERIENCE <= 35000) {
if (!$playerLEVEL ==10) {
levelUPSTATS ();
$playerLEVEL = 10;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 35000;
}
} elseif ($playerEXPERIENCE >= 35000 && $playerEXPERIENCE <= 50000) {
if (!$playerLEVEL ==11) {
levelUPSTATS ();
$playerLEVEL = 11;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 50000;
}
} elseif ($playerEXPERIENCE >= 50000 && $playerEXPERIENCE <= 75000) {
if (!$playerLEVEL ==12) {
levelUPSTATS ();
$playerLEVEL = 12;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 75000;
}
} elseif ($playerEXPERIENCE >= 75000 && $playerEXPERIENCE <= 100000) {
if (!$playerLEVEL ==13) {
levelUPSTATS ();
$playerLEVEL = 13;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 100000;
}
} elseif ($playerEXPERIENCE >= 100000 && $playerEXPERIENCE <= 135000) {
if (!$playerLEVEL == 14) {
levelUPSTATS ();
$playerLEVEL = 14;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 135000;
}
} elseif ($playerEXPERIENCE >= 135000 && $playerEXPERIENCE <= 200000) {
if (!$playerLEVEL ==15) {
levelUPSTATS ();
$playerLEVEL = 15;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 200000;
}
} elseif ($playerEXPERIENCE >= 200000 && $playerEXPERIENCE <= 300000) {
if (!$playerLEVEL ==16) {
levelUPSTATS ();
$playerLEVEL = 16;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 300000;
}
} elseif ($playerEXPERIENCE >= 300000 && $playerEXPERIENCE <= 420000) {
if (!$playerLEVEL ==17) {
levelUPSTATS ();
$playerLEVEL = 17;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 420000;
}
} elseif ($playerEXPERIENCE >= 420000 && $playerEXPERIENCE <= 600000) {
if (!$playerLEVEL ==18) {
levelUPSTATS ();
$playerLEVEL = 18;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 600000;
}
} elseif ($playerEXPERIENCE >= 600000 && $playerEXPERIENCE <= 800000) {
if (!$playerLEVEL ==19) {
levelUPSTATS ();
$playerLEVEL = 19;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 800000;
}
} elseif ($playerEXPERIENCE >= 800000 && $playerEXPERIENCE <= 1000000) {
if (!$playerLEVEL ==20) {
levelUPSTATS ();
$playerLEVEL = 20;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
} else {
$playerNEXT_LEVEL = 1000000;
}
} elseif ($playerEXPERIENCE >= 1000000) {
if (!$playerLEVEL ==21) {
levelUPSTATS ();
$playerLEVEL = 21;
$statusplayerLEVELUPDATE = "update players set level='$playerLEVEL' where username='$playerNAME'";
mysql_query($statusplayerLEVELUPDATE ) or die("Could not update player");
}
} else {
print "N/A";
}
problem is that it isn't display any error message.
It wont update the stats properly the level doesn't update.