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.
Display All
Archivo recruit.php
Display All
Actualizacion de ShowRecruitPage.class.php
Display All
Actualizacion de page.recruit.tpl
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.
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
- <?php
- // mercenarios
- $LNG ['recruitment'] = 'Mercenarios' ;
- $LNG ['rec_buy'] = 'Comprar por ' ;
- $LNG ['rec_purchased'] = 'Comprado' ;
- $LNG ['rec_error'] = 'No hay suficientes recursos' ;
- $LNG ['first' ] = [
- 'name' => 'Título 1',
- 'description' => 'Descripción 1'
- ];
- $LNG ['first' ] = [
- 'name' => 'Título 1',
- 'description' => 'Descripción 1'
- ];
- $LNG ['second' ] = [
- 'name' => 'Título 2',
- 'description' => 'Descripción 2'
- ];
- $LNG ['third' ] = [
- 'name' => 'Título 3',
- 'description' => 'Descripción 3'
- ];
- #Agregar todos los nombres y descripciones que se deseen
Archivo recruit.php
PHP Source Code: includes/recruit.php
- <?php
- $recruit['first'] = [
- 'cost' => 500,
- 'fleetArray' => [
- 204 => 50,
- 205 => 55,
- ],
- 'defendArray' => [
- 401 => 50,
- 402 => 55
- ],
- 'resourcesArray' => [
- 901 => 30000,
- 903 => 200
- ]
- ];
- $recruit['second'] = [
- 'cost' => 1000,
- 'fleetArray' => [
- 219 => 50,
- 206 => 55
- ],
- 'defendArray' => [
- 405 => 50,
- 404 => 55
- ],
- 'techArray' => [
- 110 => 3,
- 114 => 1
- ]
- ];
- $recruit['third'] = [
- 'cost' => 200,
- 'fleetArray' => [
- 220 => 50
- ],
- 'defendArray' => [
- 405 => 50
- ],
- 'buildArray' => [
- 6 => 2
- ]
- ];
- ?>
Actualizacion de ShowRecruitPage.class.php
PHP Source Code: ShowRecruitPage.class.php
- <?php
- class ShowRecruitPage extends AbstractGamePage
- {
- public static $requireModule = 0;
- function __construct(){
- parent::__construct();
- }
- function buy(){
- global $PLANET, $USER, $resource, $LNG;
- include('includes/recruit.php');
- $type = HTTP::_GP('type', '');
- $cost = $recruit[$type]['cost']; //цена
- $db = Database::get();
- $sql = 'UPDATE %%PLANETS%% SET';
- if(isset($recruit[$type]['fleetArray'])){ #Naves
- foreach($recruit[$type]['fleetArray'] as $shipId => $amount){
- $sql .= ' `'.$resource[$shipId].'` = `'.$resource[$shipId].'` + '.floattostring($amount).', ';
- }
- }
- if(isset($recruit[$type]['defendArray'])){ #Defensas
- foreach($recruit[$type]['defendArray'] as $shipId => $amount){
- $sql .= '`'.$resource[$shipId].'` = `'.$resource[$shipId].'` + '.floattostring($amount).', ';
- }
- }
- if(isset($recruit[$type]['buildArray'])){ #Construcciones
- foreach($recruit[$type]['buildArray'] as $buildId => $amount){
- $sql .= '`'.$resource[$buildId].'` = `'.$resource[$buildId].'` + '.floattostring($amount).', ';
- }
- }
- if(isset($recruit[$type]['resourcesArray'])){ #Recursos
- foreach($recruit[$type]['resourcesArray'] as $resourceId => $amount){
- $sql .= '`'.$resource[$resourceId].'` = `'.$resource[$resourceId].'` + '.floattostring($amount).', ';
- }
- }
- $sql .= 'WHERE `id` = :planetid';
- if($USER[$resource[921]] < $cost )
- {
- $this->printMessage($LNG['rec_error'], array(array(
- 'label' => $LNG['sys_back'],
- 'url' => '?page=recruit'
- )));
- }
- $USER[$resource[921]] -= $cost;
- $db->update($sql, array(
- ':planetid' => $PLANET['id']
- ));
- if(isset($recruit[$type]['techArray'])){ #Tecnologias
- $rsql = 'UPDATE %%USERS%% SET';
- foreach($recruit[$type]['techArray'] as $techId => $amount){
- $sql .= '`'.$resource[$techId].'` = `'.$resource[$techId].'` + '.floattostring($amount).', ';
- }
- }
- $this->printMessage($LNG['rec_purchased'], array(array(
- 'label' => $LNG['sys_back'],
- 'url' => '?page=recruit'
- )));
- }
- function show()
- {
- global $LNG;
- include('includes/recruit.php');
- $this->tplObj->assign_vars(array(
- 'recruits' => $recruit,
- ));
- $this->display('page.recruit.tpl');
- }
- }
- ?>
Actualizacion de page.recruit.tpl
HTML Source Code: page.recruit.tpl
- {block name="title" prepend}{$LNG.recruitment}{/block}
- {block name="content"}
- <div class="content_page">
- <div class="title">
- {$LNG.recruitment}
- </div>
- {foreach $recruits as $id => $recruit}
- <div class="main_construct">
- <div class="block_construct">
- <div class="title" style="margin: 5px 0 0 -5px; text-align: left;" >
- {$LNG.$id.name}
- <div class="clear"></div>
- </div>
- <div class="block_construct_desc">
- {$LNG.$id.description}
- <div class="block_construct_desc_list">
- {if isset($recruit['fleetArray'])}
- {foreach $recruit['fleetArray'] as $shipId => $amount}
- <img src="{$dpath}gebaeude/{$shipId}.gif" alt="{$LNG.tech.{$shipId}}" width="30" height="30">
- {$LNG.tech.{$shipId}}
- {$amount|number}</br>
- {/foreach}
- {/if}
- {if isset($recruit['defendArray'])}
- {foreach $recruit['defendArray'] as $shipId => $amount}
- <img src="{$dpath}gebaeude/{$shipId}.gif" alt="{$LNG.tech.{$shipId}}" width="30" height="30">
- {$LNG.tech.{$shipId}}
- {$amount|number}</br>
- {/foreach}
- {/if}
- {if isset($recruit['buildArray'])}
- {foreach $recruit['buildArray'] as $shipId => $amount}
- <img src="{$dpath}gebaeude/{$shipId}.gif" alt="{$LNG.tech.{$shipId}}" width="30" height="30">
- {$LNG.tech.{$shipId}}
- {$amount|number}</br>
- {/foreach}
- {/if}
- {if isset($recruit['techArray'])}
- {foreach $recruit['techArray'] as $shipId => $amount}
- <img src="{$dpath}gebaeude/{$shipId}.gif" alt="{$LNG.tech.{$shipId}}" width="30" height="30">
- {$LNG.tech.{$shipId}}
- {$amount|number}</br>
- {/foreach}
- {/if}
- {if isset($recruit['resourcesArray'])}
- {foreach $recruit['resourcesArray'] as $shipId => $amount}
- <img src="{$dpath}images/{$shipId}.gif" alt="{$LNG.tech.{$shipId}}" width="30" height="30">
- {$LNG.tech.{$shipId}}
- {$amount|number}</br>
- {/foreach}
- {/if}
- </div>
- <div>
- <form action="?page=recruit&mode=buy" method="post" class="build_form">
- <input type="hidden" name="type" value="{$id}">
- <button type="submit" class="build_submit construct_button">{$LNG.rec_buy}{$recruit['cost']|number} {$LNG.tech.921}</button>
- </form>
- </div>
- </div>
- </div>
- </div>
- {/foreach}
- <div class="clear"></div>
- </div>
- {/block}
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.
The post was edited 2 times, last by Jekill ().