Dethman Posted December 20, 2008 Share Posted December 20, 2008 Hey a friend of mine gave me a function to help me make a new one can someone Add some comments and or make it better in the coding part, Heres the Function: <?php function getStrikeAction($user){ global $conf; $num=0; $trainedCount=$user->trainedAttackSold+$user->trainedAttackMerc; $untrainedCount=$user->untrainedMerc+$user->untrainedSold; $weaponA1=getUserWeapon($user); if (!count($weaponA1)&&!$trainedCount) return 0; /*$k=0; for ($i=0;$i<count($weaponA1);$i++){ for ($j=0; $j<$weaponA1[$i]->weaponCount ;$j++){ $weaponA[$k]=$weaponA1[$i]; $k++; } }*/ $weaponA=getWeaponArray($weaponA1); if ($weaponA){ $wepAlloc=getWeaponAllocation($user,$weaponA,$trainedCount,$untrainedCount); $wI=0; for ($i=0; $i<$wepAlloc["trainedW"];$i++,$wI++){ $num+=$weaponA[$wI]->weaponStrength*5; } for ($i=0; $i<$wepAlloc["untrainedW"];$i++,$wI++){ $num+=$weaponA[$wI]->weaponStrength*4; } }else{ $wepAlloc["trainedUnW"]=$trainedCount; $wepAlloc["untrainedUnW"]=$untrainedCount; } $num+=$wepAlloc["trainedUnW"]*5; $num+=$wepAlloc["untrainedUnW"]*4; for ($i=0; $i<=$user->siegeLevel;$i++){ if ($conf["race"][$user->race]["siege"][$i]["attack"]){ $num+=round(($num*$conf["race"][$user->race]["siege"][$i]["attack"])/100); } } if ($conf["race"][$user->race]["attack"]){ $num+=round(($num*$conf["race"][$user->race]["attack"])/100); } return $num; }?> Thanx ~Dethman Quote Link to comment https://forums.phpfreaks.com/topic/137774-can-someone-make-this-function-better-please/ Share on other sites More sharing options...
.josh Posted December 20, 2008 Share Posted December 20, 2008 We'd need to see the script as a whole to really give an honest effort into making it "better." (Please don't post your whole script here). If you're really serious about making it "better," I suggest hiring someone. That way they can take a look at your setup/files/code as a whole and evaluate the situation. Quote Link to comment https://forums.phpfreaks.com/topic/137774-can-someone-make-this-function-better-please/#findComment-720086 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.