David_1507 Posted November 28, 2012 Share Posted November 28, 2012 Basically, I am re-coding my V2 attack script (currently have a 1 click attack system in place) and instead of it listing every attack (sometimes it ends up in the tens of thousands as a HP battle), I want it to list say hit 1-4 and then skip to the last 4? I.e. My attack Their attack my attack their attack continued my attack their attack my attack their attack They won, gaining them XX EXP and $XX,XXX If you need me to elaborate more then I will try. I am not asking for you to code it, but give me a hint into the right direction. Quote Link to comment Share on other sites More sharing options...
sniko Posted November 28, 2012 Share Posted November 28, 2012 Are you saying missing out some of the events that are displayed? Quote Link to comment Share on other sites More sharing options...
David_1507 Posted November 28, 2012 Author Share Posted November 28, 2012 Yes Sir. Basically when it comes to a HP battle there can be thousands of "hits" causing players phones etc. to crash. Quote Link to comment Share on other sites More sharing options...
sniko Posted November 28, 2012 Share Posted November 28, 2012 Yes Sir. Basically when it comes to a HP battle there can be thousands of "hits" causing players phones etc. to crash. I understand. I'm not entirely sure if this will help with optimization, but you could just do the processing that's needed to take the health, and then display random results? Quote Link to comment Share on other sites More sharing options...
Octarine Posted November 28, 2012 Share Posted November 28, 2012 Assuming you store the outcome of each round into an array (the individual elements need not concern us here), then array_slice() would appear a handy starting point... $result = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); if (count($result) > 8) { $first_four = array_slice($result, 0, 4); $last_four = array_slice($result, -4, 4); $result = array_merge($first_four, array('...'), $last_four); } print_r($result); Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => ... [5] => 9 [6] => 10 [7] => 11 [8] => 12 ) Though as with most PHP, there are multiple solutions. Which you choose, will be dependant on a number of things, I suspect most notably being the number of anticipated rounds. If this becomes too high, then the combat system may have to be reworked to reduce the load on the server. Quote Link to comment Share on other sites More sharing options...
newttster Posted November 29, 2012 Share Posted November 29, 2012 OR ... you could have it stalemate at 100 hits. Just a thought. Quote Link to comment Share on other sites More sharing options...
Uridium Posted November 29, 2012 Share Posted November 29, 2012 something on the lines of.... if($_GET['nextstep'] > 50) { print"<center><h1><font color='red'><span class="highlight">STALEMATE</span>!</h1> <h2>You both get bored and go home!</h2><a href="http://index.php" target="_blank">> Back</a></center>"; $h->endpage();event_add($odata['userid'],"<a href="http://viewuser.php?u=$userid" target="_blank">{$youdata['username']}</a> Tried to Attack you but ended in a stalemate.",$c); $db->query("UPDATE users SET attacking=0 WHERE userid=$userid AND userid=$odata"); exit; } Will set the attack so when the total is 50 you can go no further.... Quote Link to comment Share on other sites More sharing options...
Uridium Posted November 29, 2012 Share Posted November 29, 2012 Double post Quote Link to comment 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.