Jump to content

Recommended Posts

Ok so I am not using a traditional array here is what I have:

 

 

FUNCTION assignOnSloppyCheeseBall($train, $mar, $maur, $irt, $pt, $esp, $st, $ft, $r, $b, $iron, $plat, $energy, $citizen, $planetID){
if($train == 1){
// Get Mar Prices.
if($mar>=1){
$price["mar"]["p1"] = (120250 * $mar);
$price["mar"]["p2"] = (90670 * $mar);
$price["mar"]["p3"] = (500 * $mar);
$price["mar"]["p4"] = (2 * $mar);
}else{
$price["mar"]["p1"] = 0;
$price["mar"]["p2"] = 0;
$price["mar"]["p3"] = 0;
$price["mar"]["p4"] = 0;
}
if($maur>=1){
$price["maur"]["p1"] = (445620 * $maur);
$price["maur"]["p2"] = (180645 * $maur);
$price["maur"]["p3"] = (1000 * $maur);
$price["maur"]["p4"] = (4 * $maur);
}else{
$price["maur"]["p1"] = 0;
$price["maur"]["p2"] = 0;
$price["maur"]["p3"] = 0;
$price["maur"]["p4"] = 0;
}
if($irt>=1){
$price["irt"]["p1"] = (25160 * $irt);
$price["irt"]["p2"] = (13690 * $irt);
$price["irt"]["p3"] = (120 * $irt);
$price["irt"]["p4"] = (1 * $irt);
}else{
$price["irt"]["p1"] = 0;
$price["irt"]["p2"] = 0;
$price["irt"]["p3"] = 0;
$price["irt"]["p4"] = 0;
}
if($pt>=1){
$price["pt"]["p1"] = (25160 * $pt);
$price["pt"]["p2"] = (13690 * $pt);
$price["pt"]["p3"] = (120 * $pt);
$price["pt"]["p4"] = (1 * $pt);
}else{
$price["pt"]["p1"] = 0;
$price["pt"]["p2"] = 0;
$price["pt"]["p3"] = 0;
$price["pt"]["p4"] = 0;
}
if($esp>=1){
$price["esp"]["p1"] = (162324 * $esp);
$price["esp"]["p2"] = (67670 * $esp);
$price["esp"]["p3"] = (300 *  $esp);
$price["esp"]["p4"] = (6 *  $esp);
}else{
$price["esp"]["p1"] = 0;
$price["esp"]["p2"] = 0;
$price["esp"]["p3"] = 0;
$price["esp"]["p4"] = 0;
}
if($st>=1){
$price["st"]["p1"] = (25160 * $st);
$price["st"]["p2"] = (13690 * $st);
$price["st"]["p3"] = (150 * $st);
$price["st"]["p4"] = (1 * $st);
}else{
$price["st"]["p1"] = 0;
$price["st"]["p2"] = 0;
$price["st"]["p3"] = 0;
$price["st"]["p4"] = 0;
}
if($ft>=1){
$price["ft"]["p1"] = (55190 * $ft);
$price["ft"]["p2"] = (26050 * $ft);
$price["ft"]["p3"] = (300 * $ft);
$price["ft"]["p3"] = (2 * $ft);
}else{
$price["ft"]["p1"] = 0;
$price["ft"]["p2"] = 0;
$price["ft"]["p3"] = 0;
$price["ft"]["p4"] = 0;
}
if($r>=1){
$price["r"]["p1"] = (6550 * $r);
$price["r"]["p2"] = (4670 * $r);
$price["r"]["p3"] = (50 * $r);
$price["r"]["p4"] = (2 * $r);
}else{
$price["r"]["p1"] = 0;
$price["r"]["p2"] = 0;
$price["r"]["p3"] = 0;
$price["r"]["p4"] = 0;
}
if($b>=1){
$price["b"]["p1"] = (20250 * $B);
$price["b"]["p2"] = (19670 * $B);
$price["b"]["p3"] = (38 * $B);
$price["b"]["p4"] = (8 * $B);
}else{
$price["b"]["p1"] = 0;
$price["b"]["p2"] = 0;
$price["b"]["p3"] = 0;
$price["b"]["p4"] = 0;
}
$totalIron = ($price["b"]["p1"]+$price["r"]["p1"]+$price["ft"]["p1"]+$price["st"]["p1"]+$price["esp"]["p1"]+$price["irt"]["p1"]+$price["maur"]["p1"]+$price["mar"]["p1"]);
$totalPlat = ($price["b"]["p2"]+$price["r"]["p2"]+$price["ft"]["p2"]+$price["st"]["p2"]+$price["esp"]["p2"]+$price["irt"]["p2"]+$price["maur"]["p2"]+$price["mar"]["p2"]);
$totalEnergy = ($price["b"]["p3"]+$price["r"]["p3"]+$price["ft"]["p3"]+$price["st"]["p3"]+$price["esp"]["p3"]+$price["irt"]["p3"]+$price["maur"]["p3"]+$price["mar"]["p3"]);
$totalCitizen = ($price["b"]["p4"]+$price["r"]["p4"]+$price["ft"]["p4"]+$price["st"]["p4"]+$price["esp"]["p4"]+$price["irt"]["p4"]+$price["maur"]["p4"]+$price["mar"]["p4"]);
if($iron >= $totalIron){
 if($plat>=$totalPlat){

    if($energy>=$totalEnergy){

	    if($citizen>=$totalCitizen){


	    $q="UPDATE `population` SET marines_res = marines_res+'$mar', mauraders_res = mauraders_res+'$maur', espmerc_res = espmerc_res+'$esp', irontech_res = irontech_res+'$irt', platinumtech_res = platinumtech_res+'$pt', solartech_res = solartech_res+'$st', fusiontech_res = fusiontech_res+'$ft', recruiters_res = recruiters_res+'$r', builders_res = builders_res+'$b' WHERE `planetID` = '$planetID'";
	    $q2="UPDATE `planets` SET `Iron_Res` = `Iron_Res`-'$totalIron', `Plat_Res` = `Plat_Res`-'$totalPlat', `Energy_Res` = `Energy_Res`-'$totalEnergy', `Citizens_Res` = `Citizens_Res`-'$totalCitizen' WHERE `planetID` = '$planetID'";
  $res = mysql_query($q) or die(mysql_error());
  $res2 = mysql_query($q2) or die(mysql_error());

  if(isset($res)){

  if(isset($res2)){

  return "s_1";
  }

  }

  }else{
  return "e_1";
  }

 }else{
  return "e_2";
  }


 }else{
  return "e_3";
  }
}else{
  return "e_4";
  }

}
}

 

So for some reason they arent holding any information when they should.

 

Thanks,

greenbman

Link to comment
https://forums.phpfreaks.com/topic/274657-array-not-holding-a-value/
Share on other sites

Ok I have no clue why I used that way of doing it so I though hey well I guess I could change it to regular variables so that is what I did:

 

<?php
// Get Mar Prices.
if($mar>=1){
$marprice1 = (120250 * $mar);
$marprice2 = (90670 * $mar);
$marprice3=(500 * $mar);
$marprice4=(2 * $mar);
}else{
$marprice2 = 0;
$marprice3 = 0;
$marprice4 = 0;
}
if($maur>=1){
$maurprice1 = (445620 * $maur);
$maurprice2 = (180645 * $maur);
$maurprice3 = (1000 * $maur);
$maurprice4 = (4 * $maur);
}else{
$maurprice1 = 0;
$maurprice2 = 0;
$maurprice3 = 0;
$maurprice4 = 0;
}
if($irt>=1){
$irtprice1 = (25160 * $irt);
$irtprice2 = (13690 * $irt);
$irtprice3 = (120 * $irt);
$irtprice4 = (1 * $irt);
}else{
$irtprice1 = 0;
$irtprice2 = 0;
$irtprice3 = 0;
$irtprice4 = 0;
}
if($pt>=1){
$ptprice1 = (25160 * $pt);
$ptprice2 = (13690 * $pt);
$ptprice3 = (120 * $pt);
$ptprice4 = (1 * $pt);
}else{
$ptprice1 = 0;
$ptprice2 = 0;
$ptprice3 = 0;
$ptprice4 = 0;
}
if($esp>=1){
$espprice1 = (162324 * $esp);
$espprice2 = (67670 * $esp);
$espprice3 = (300 * $esp);
$espprice4 = (6 * $esp);
}else{
$espprice1 = 0;
$espprice2 = 0;
$espprice2 = 0;
$espprice4 = 0;
}
if($st>=1){
$stprice1 = (25160 * $st);
$stprice2 = (13690 * $st);
$stprice3 = (150 * $st);
$stprice4 = (1 * $st);
}else{
$stprice1 = 0;
$stprice2 = 0;
$stprice2 = 0;
$stprice3 = 0;
}
if($ft>=1){
$ftprice1 = (55190 * $ft);
$ftprice2 = (26050 * $ft);
$ftprice3 = (300 * $ft);
$ftprice4 = (2 * $ft);
}else{
$ftprice1 = 0;
$ftprice2 = 0;
$ftprice3 = 0;
$ftprice4 = 0;
}
if($r>=1){
$rprice1 = (6550 * $r);
$rprice2 = (4670 * $r);
$rprice3 = (50 * $r);
$rprice4 = (2 * $r);
}else{
$rprice1 = 0;
$rprice1 = 0;
$rprice3 = 0;
$rprice4 = 0;
}
if($b>=1){
$bprice1 = (20250 * $B);
$bprice2 = (19670 * $B);
$bprice3 = (38 * $B);
$bprice4 = (8 * $B);
}else{
$bprice1 = 0;
$bprice2 = 0;
$bprice3 = 0;
$bprice4 = 0;
}
$totalIron = ($marprice1+$maurprice1+$bprice1+$rprice1+$ftprice1+$stprice1+$espprice1+$ptprice1+$irtprice1);
$totalPlat = ($marprice2+$maurprice2+$bprice2+$rprice2+$ftprice2+$stprice2+$espprice2+$ptprice2+$irtprice2);
$totalEnergy = ($marprice3+$maurprice3+$bprice3+$rprice3+$ftprice3+$stprice3+$espprice3+$ptprice3+$irtprice3);
$totalCitizen = ($marprice4+$maurprice4+$bprice4+$rprice4+$ftprice4+$stprice4+$espprice4+$ptprice4+$irtprice4);
?>

 

And still it is like the Variable Holds no Information at all but when I die the $mar variable the information is there.

 

Please help,

greenbman

Edited by greenbman

Ok so I figured it out:

 

// Get Mar Prices.
$marp1 = "120250";
$marp2 = "90670";
$marp3 = "500";
$marp4 = "2";
$marprice1 =  bcmul($mar, $marp1);
$marprice2 = bcmul($mar, $marp2);
$marprice3 = bcmul($mar, $marp3);
$marprice4 = bcmul($mar, $marp4);
$maurprice1 = bcmul(445620, $maur);
$maurprice2 = bcmul(180645, $maur);
$maurprice3 = bcmul(1000, $maur);
$maurprice4 = bcmul(4, $maur);
$irtprice1 = bcmul(25160, $irt);
$irtprice2 = bcmul(13690, $irt);
$irtprice3 = bcmul(120, $irt);
$irtprice4 = bcmul(1, $irt);

$ptprice1 = bcmul(25160, $pt);
$ptprice2 = bcmul(13690, $pt);
$ptprice3 = bcmul(120, $pt);
$ptprice4 = bcmul(1, $pt);

$espprice1 = bcmul(162324, $esp);
$espprice2 = bcmul(67670, $esp);
$espprice3 = bcmul(300, $esp);
$espprice4 = bcmul(6, $esp);

$stprice1 = bcmul(25160, $st);
$stprice2 = bcmul(13690, $st);
$stprice3 = bcmul(150, $st);
$stprice4 = bcmul(1, $st);
$ftprice1 = bcmul(55190, $ft);
$ftprice2 = bcmul(26050, $ft);
$ftprice3 = bcmul(300, $ft);
$ftprice4 = bcmul(2, $ft);
$rprice1 = bcmul(6550, $r);
$rprice2 = bcmul(4670, $r);
$rprice3 = bcmul(50, $r);
$rprice4 = bcmul(2, $r);
$bprice1 = bcmul(20250, $B);
$bprice2 = bcmul(19670, $B);
$bprice3 = bcmul(38, $B);
$bprice4 = bcmul(8, $B);

So Evidently

bcmul(parameter, parameter) is what PHP is more likely to accept. This basically multiplys one parameter by another. My script is working now thanks for the views,

 

greenbman

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.