[MOD] Recruitment (Наемники) для 2moons 2.0

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

    • Hola a todos.

      Aunque veo que este mod, por su nombre, es para reclutamiento de mercenarios con Naves y defensas, atendiendo a la pregunta de @yamilrh he actualizado el codigo. Ahora permite Naves, Defensas, Tecnologias y Edificaciones.

      PHP Source Code: INGAME.php

      1. <?php
      2. // mercenarios
      3. $LNG ['recruitment'] = 'Mercenarios' ;
      4. $LNG ['rec_buy'] = 'Comprar por ' ;
      5. $LNG ['rec_purchased'] = 'Comprado' ;
      6. $LNG ['rec_error'] = 'No hay suficientes recursos' ;
      7. $LNG ['first' ] = [
      8. 'name' => 'Título 1',
      9. 'description' => 'Descripción 1'
      10. ];
      11. $LNG ['first' ] = [
      12. 'name' => 'Título 1',
      13. 'description' => 'Descripción 1'
      14. ];
      15. $LNG ['second' ] = [
      16. 'name' => 'Título 2',
      17. 'description' => 'Descripción 2'
      18. ];
      19. $LNG ['third' ] = [
      20. 'name' => 'Título 3',
      21. 'description' => 'Descripción 3'
      22. ];
      23. #Agregar todos los nombres y descripciones que se deseen
      Display All



      Archivo recruit.php


      PHP Source Code: includes/recruit.php

      1. <?php
      2. $recruit['first'] = [
      3. 'cost' => 500,
      4. 'fleetArray' => [
      5. 204 => 50,
      6. 205 => 55,
      7. ],
      8. 'defendArray' => [
      9. 401 => 50,
      10. 402 => 55
      11. ],
      12. 'resourcesArray' => [
      13. 901 => 30000,
      14. 903 => 200
      15. ]
      16. ];
      17. $recruit['second'] = [
      18. 'cost' => 1000,
      19. 'fleetArray' => [
      20. 219 => 50,
      21. 206 => 55
      22. ],
      23. 'defendArray' => [
      24. 405 => 50,
      25. 404 => 55
      26. ],
      27. 'techArray' => [
      28. 110 => 3,
      29. 114 => 1
      30. ]
      31. ];
      32. $recruit['third'] = [
      33. 'cost' => 200,
      34. 'fleetArray' => [
      35. 220 => 50
      36. ],
      37. 'defendArray' => [
      38. 405 => 50
      39. ],
      40. 'buildArray' => [
      41. 6 => 2
      42. ]
      43. ];
      44. ?>
      Display All


      Actualizacion de ShowRecruitPage.class.php

      PHP Source Code: ShowRecruitPage.class.php

      1. <?php
      2. class ShowRecruitPage extends AbstractGamePage
      3. {
      4. public static $requireModule = 0;
      5. function __construct(){
      6. parent::__construct();
      7. }
      8. function buy(){
      9. global $PLANET, $USER, $resource, $LNG;
      10. include('includes/recruit.php');
      11. $type = HTTP::_GP('type', '');
      12. $cost = $recruit[$type]['cost']; //цена
      13. $db = Database::get();
      14. $sql = 'UPDATE %%PLANETS%% SET';
      15. if(isset($recruit[$type]['fleetArray'])){ #Naves
      16. foreach($recruit[$type]['fleetArray'] as $shipId => $amount){
      17. $sql .= ' `'.$resource[$shipId].'` = `'.$resource[$shipId].'` + '.floattostring($amount).', ';
      18. }
      19. }
      20. if(isset($recruit[$type]['defendArray'])){ #Defensas
      21. foreach($recruit[$type]['defendArray'] as $shipId => $amount){
      22. $sql .= '`'.$resource[$shipId].'` = `'.$resource[$shipId].'` + '.floattostring($amount).', ';
      23. }
      24. }
      25. if(isset($recruit[$type]['buildArray'])){ #Construcciones
      26. foreach($recruit[$type]['buildArray'] as $buildId => $amount){
      27. $sql .= '`'.$resource[$buildId].'` = `'.$resource[$buildId].'` + '.floattostring($amount).', ';
      28. }
      29. }
      30. if(isset($recruit[$type]['resourcesArray'])){ #Recursos
      31. foreach($recruit[$type]['resourcesArray'] as $resourceId => $amount){
      32. $sql .= '`'.$resource[$resourceId].'` = `'.$resource[$resourceId].'` + '.floattostring($amount).', ';
      33. }
      34. }
      35. $sql .= 'WHERE `id` = :planetid';
      36. if($USER[$resource[921]] < $cost )
      37. {
      38. $this->printMessage($LNG['rec_error'], array(array(
      39. 'label' => $LNG['sys_back'],
      40. 'url' => '?page=recruit'
      41. )));
      42. }
      43. $USER[$resource[921]] -= $cost;
      44. $db->update($sql, array(
      45. ':planetid' => $PLANET['id']
      46. ));
      47. if(isset($recruit[$type]['techArray'])){ #Tecnologias
      48. $rsql = 'UPDATE %%USERS%% SET';
      49. foreach($recruit[$type]['techArray'] as $techId => $amount){
      50. $sql .= '`'.$resource[$techId].'` = `'.$resource[$techId].'` + '.floattostring($amount).', ';
      51. }
      52. }
      53. $this->printMessage($LNG['rec_purchased'], array(array(
      54. 'label' => $LNG['sys_back'],
      55. 'url' => '?page=recruit'
      56. )));
      57. }
      58. function show()
      59. {
      60. global $LNG;
      61. include('includes/recruit.php');
      62. $this->tplObj->assign_vars(array(
      63. 'recruits' => $recruit,
      64. ));
      65. $this->display('page.recruit.tpl');
      66. }
      67. }
      68. ?>
      Display All


      Actualizacion de page.recruit.tpl


      HTML Source Code: page.recruit.tpl

      1. {block name="title" prepend}{$LNG.recruitment}{/block}
      2. {block name="content"}
      3. <div class="content_page">
      4. <div class="title">
      5. {$LNG.recruitment}
      6. </div>
      7. {foreach $recruits as $id => $recruit}
      8. <div class="main_construct">
      9. <div class="block_construct">
      10. <div class="title" style="margin: 5px 0 0 -5px; text-align: left;" >
      11. {$LNG.$id.name}
      12. <div class="clear"></div>
      13. </div>
      14. <div class="block_construct_desc">
      15. {$LNG.$id.description}
      16. <div class="block_construct_desc_list">
      17. {if isset($recruit['fleetArray'])}
      18. {foreach $recruit['fleetArray'] as $shipId => $amount}
      19. <img src="{$dpath}gebaeude/{$shipId}.gif" alt="{$LNG.tech.{$shipId}}" width="30" height="30">
      20. {$LNG.tech.{$shipId}}
      21. {$amount|number}</br>
      22. {/foreach}
      23. {/if}
      24. {if isset($recruit['defendArray'])}
      25. {foreach $recruit['defendArray'] as $shipId => $amount}
      26. <img src="{$dpath}gebaeude/{$shipId}.gif" alt="{$LNG.tech.{$shipId}}" width="30" height="30">
      27. {$LNG.tech.{$shipId}}
      28. {$amount|number}</br>
      29. {/foreach}
      30. {/if}
      31. {if isset($recruit['buildArray'])}
      32. {foreach $recruit['buildArray'] as $shipId => $amount}
      33. <img src="{$dpath}gebaeude/{$shipId}.gif" alt="{$LNG.tech.{$shipId}}" width="30" height="30">
      34. {$LNG.tech.{$shipId}}
      35. {$amount|number}</br>
      36. {/foreach}
      37. {/if}
      38. {if isset($recruit['techArray'])}
      39. {foreach $recruit['techArray'] as $shipId => $amount}
      40. <img src="{$dpath}gebaeude/{$shipId}.gif" alt="{$LNG.tech.{$shipId}}" width="30" height="30">
      41. {$LNG.tech.{$shipId}}
      42. {$amount|number}</br>
      43. {/foreach}
      44. {/if}
      45. {if isset($recruit['resourcesArray'])}
      46. {foreach $recruit['resourcesArray'] as $shipId => $amount}
      47. <img src="{$dpath}images/{$shipId}.gif" alt="{$LNG.tech.{$shipId}}" width="30" height="30">
      48. {$LNG.tech.{$shipId}}
      49. {$amount|number}</br>
      50. {/foreach}
      51. {/if}
      52. </div>
      53. <div>
      54. <form action="?page=recruit&mode=buy" method="post" class="build_form">
      55. <input type="hidden" name="type" value="{$id}">
      56. <button type="submit" class="build_submit construct_button">{$LNG.rec_buy}{$recruit['cost']|number} {$LNG.tech.921}</button>
      57. </form>
      58. </div>
      59. </div>
      60. </div>
      61. </div>
      62. {/foreach}
      63. <div class="clear"></div>
      64. </div>
      65. {/block}
      Display All



      Agregar al main.navigation.tpl

      <a href="game.php?page=recruit">{$LNG.recruitment}</a>

      [Blocked Image: https://ibb.co/1vghv6q]


      Nota: No es necesario agregar los arrays de segundo nivel se encuentran vacios

      Igualmente debajo dejo un comprimido que es solo descomprimir dentro de su proyecto 2Moons, solo hay que agregar el idioma y el link del menu manualmente.

      Saludos a todos.
      Files
      • Recruit.zip

        (3.4 kB, downloaded 37 times, last: )
      Gestor de proyectos para xampp
      Cardinal System for XAMPP

      The post was edited 2 times, last by Jekill ().