[MOD] Attack indicators for version 1.8

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • [MOD] Attack indicators for version 1.8

      Make some indicators for version 1.8 :)
    • This is from my game, you have to adapt to yours, eventually.

      It's very simple to do it.

      PHP Source Code: AbstractGamePage.class.php

      1. <?php
      2. [...]
      3. $AttackSQL = "SELECT COUNT(*) as count FROM %%FLEETS%% WHERE fleet_target_owner = :id AND (fleet_mission = 1 OR fleet_mission = 2 OR fleet_mission = 9) AND fleet_start_time > :timestamp; ";
      4. $AttackCount = Database::get()->selectSingle($AttackSQL, array(
      5. ':id' => $USER['id'],
      6. ':timestamp' => TIMESTAMP,
      7. ), 'count');
      8. $this->assign(array(
      9. [...]
      10. 'AttackCount' => $AttackCount,
      Display All

      HTML Source Code

      1. <a href="game.php?page=fleetActivity" class="hidden-xs nav-link dropdown-toggle arrow-none waves-light waves-effect" onclick="return Dialog.open(this.href, 600, 400);" data-toggle="dropdown" href="#" role="button"
      2. aria-haspopup="false" aria-expanded="false">
      3. {if $AttackCount > 0}<i class="fa fa-exclamation-triangle noti-icon fleet-warning" style="color: orange;"></i>{else}<i class="fa fa-plane noti-icon" style="color: lime;"></i>{/if}
      4. <script type="text/javascript">(function blink() { $('.fleet-warning').fadeOut(500).fadeIn(500, blink); })();</script>
      5. </a>
    • longpolls are also possible, make a request from the browser,
      then in php ask db every second for new fleets.
      if your client(browser) makes a request every 10 sec you would have some kind of a push-system
      i would prefer sockets, but this is easy and working (just do the loop if original dbrequestresult was same client already has and change 'if (isset($db_erg[0]))' to your needs)

      PHP Source Code

      1. do {
      2. session_write_close();
      3. if(connection_aborted()){
      4. die();
      5. }
      6. sleep(1);
      7. $sql = = "SELECT COUNT(*) as count FROM %%FLEETS%% WHERE fleet_target_owner = :id AND (fleet_mission = 1 OR fleet_mission = 2 OR fleet_mission = 9) AND fleet_start_time > :timestamp; ";
      8. $AttackCount = Database::get()->selectSingle($AttackSQL, array(
      9. ':id' => $USER['id'],
      10. ':timestamp' => TIMESTAMP,
      11. ), 'count');
      12. $db_erg = $db->select($sql);
      13. if (isset($db_erg[0])) {
      14. $i = 10;
      15. }
      16. $i++;
      17. } while ($i < 10);
      Display All