Posts: 3'166
Threads: 47
Joined: Dec 2008
Reputation:
205
(This post was last modified: 08.05.2013, 14:00 by SlimShady95 .)
06.05.2013, 18:18
Hab ich grad auf der Platte gefunden, vielleicht hat ja jemand ne Verwendung für ^^
Code:
Source Code
PHP Code:
<?php
// Copyright by SlimShady95 < manuel_mannhardt@web.de >
// reload_ress() by milos
// Geklaut vom milos Bot :D
function reload_ress ( $vid )
{
global $arr_maxstorage , $arr_production , $config , $db ;
$sql = 'SELECT * FROM `villages` WHERE `id` = ' . $vid ;
$res = $db -> query ( $sql );
$village = $db -> fetch ( $res );
$time = time ();
$wood = $village [ 'r_wood' ] + $arr_production [ $village [ 'wood' ]] * $config [ 'speed' ] / 60 / 60 * ( $time - $village [ 'last_prod_aktu' ]);
$stone = $village [ 'r_stone' ] + $arr_production [ $village [ 'stone' ]] * $config [ 'speed' ] / 60 / 60 * ( $time - $village [ 'last_prod_aktu' ]);
$iron = $village [ 'r_iron' ] + $arr_production [ $village [ 'iron' ]] * $config [ 'speed' ] / 60 / 60 * ( $time - $village [ 'last_prod_aktu' ]);
if( $arr_maxstorage [ $village [ 'storage' ]] < $wood )
{
$wood = $arr_maxstorage [ $village [ 'storage' ]];
}
if ( $arr_maxstorage [ $village [ 'storage' ]] < $stone )
{
$stone = $arr_maxstorage [ $village [ 'storage' ]];
}
if ( $arr_maxstorage [ $village [ 'storage' ]] < $iron )
{
$iron = $arr_maxstorage [ $village [ 'storage' ]];
}
$sql = 'UPDATE `villages` SET `r_wood` = \'' . $wood . '\', `r_stone` = \'' . $stone . '\', `r_iron` = \'' . $iron . '\', last_prod_aktu = \'' . $time . '\' WHERE `id` = \'' . $vid . '\'' ;
$db -> query ( $sql );
}
// Improvisation pur -.-'
$query = $db -> query ( 'SELECT * FROM `build` WHERE `end_time` < ' . time ());
while( $row = $db -> fetch ( $query ))
{
$db -> query ( 'UPDATE `villages` SET `' . $row [ 'building' ] . '` = `' . $row [ 'building' ] . '` + 1 WHERE `id` = ' . $row [ 'villageid' ]);
$db -> query ( 'DELETE FROM `build` WHERE `id` = ' . $row [ 'id' ]);
}
// Alle Dörfer holen, die weniger als die maximalen Punkte haben
$query = $db -> query ( 'SELECT * FROM `villages` WHERE `userid` = \'-1\' AND `points` < ' . $config [ 'bb_max_points' ]);
while( $row = $db -> fetch ( $query ))
{
// Baut da schon was?
$query2 = $db -> query ( 'SELECT * FROM `build` WHERE `villageid` = ' . $row [ 'id' ]);
if( $db -> numrows ( $query2 ) == 0 )
{
// Nein? Dann Gebäude auswählen
$builds = $cl_builds -> get_array ( 'dbname' );
$build_village = array();
$id_array = array_flip ( $cl_builds -> get_array ( 'dbname' ));
foreach( $builds as $key => $value )
{
$build_village [ $value ] = $row [ $value ];
}
// Zufälliges Gebäude
$rand = rand ( 0 , count ( $builds )- 1 );
$build = $builds [ $rand ];
// Bauen
$cl_builds -> build ( $row , $id_array [ $build ], $build_village , 1 );
#print $cl_builds->get_build_error2() . '<br />';
// Kein Fehler -> Rohstoffe abziehen und son Zeug halt
if( $cl_builds -> get_build_error2 () == 'no_error' )
{
// Rohstoffe abziehen
$wood = $cl_builds -> get_wood ( $build , $row [ $build ] + 1 );
$stone = $cl_builds -> get_stone ( $build , $row [ $build ] + 1 );
$iron = $cl_builds -> get_iron ( $build , $row [ $build ] + 1 );
$bh = $cl_builds -> get_bh ( $build , $row [ $build ] + 1 );
$time = $cl_builds -> get_time ( $row [ 'main' ], $build , $row [ $build ] + 1 ) + time ();
$onlytime = $cl_builds -> get_time ( $row [ 'main' ], $build , $row [ $build ] + 1 );
$db -> query ( 'UPDATE `villages` SET `r_wood` = `r_wood` - ' . round ( $wood ) . ', `r_stone` = `r_stone` - ' . round ( $stone ) . ', `r_iron` = `r_iron` - ' . round ( $iron ) . ', `r_bh` = `r_bh` + ' . $bh . ' WHERE `id` = ' . $row [ 'id' ]);
$db -> query ( 'INSERT INTO `build` (`building`, `villageid`, `end_time`, `build_time`) VALUES (\'' . $build . '\',' . $row [ 'id' ] . ',' . $time . ', ' . $onlytime . ')' );
}
}
reload_ress ( $row [ 'id' ]);
}
Installation Deutsch
Installtion:
- Speichert den Code oben ^ in einer Datei direkt in htdocs (nennen wir sie mal "barbar.php") oder ladet die Datei [
hier ] runter, entpackt sie und speichert sie in "htdocs"
- Benennt die Datei "include.inc.php" in "include2.inc.php" um (sie ist in "htdocs")
- Erstellt eine neue Datei namens "include.inc.php" mit folgendem Inhalt:
PHP Code:
<?php
require_once( 'include2.inc.php' );
require_once( 'barbar.php' );
- Danach öffnet ihr die Config und fügt folgenden Eintrag hinzu:
PHP Code:
$config [ 'bb_max_points' ] = 3000 ;
PS: Der Config-Eintrag lässt euch einstellen, wie weit die Dörfer sich ausbauen
PS2: Rohstoffe werden abgezogen, BH-Plätze werden belegt, ausbauen dauert genauso lange wie bei den Spielern, etc.
PS3:
No support - Keine Hilfe bei der Installation oder bei Fehlern
PS4: Ja, das Script ist ekligt, aber das ist auch schon 2 Jahre alt
MfG Manuel
Posts: 103
Threads: 22
Joined: Feb 2011
Reputation:
0
(This post was last modified: 07.05.2013, 08:18 by parat26 .)
07.05.2013, 08:14
Nice work, but it seems that there is problem with the code?
Everything went good with the installation. After a while barbarians haven't grown up so I checked if there was any errors at localhost/barbar.php.
Here is what I've got:
Parse error: parse error, unexpected ';' in C:\Users\thanos\My Docs\Tribal Wars\TWLan 1.4\htdocs\barbar.php on line 86
Any ideas?
Posts: 1'610
Threads: 14
Joined: Feb 2011
Reputation:
52
have you changed the script? my ZEND say no Error.
Schildkröte: "nichts ist langsamer als ich!"
Schnecke: "ich bin ganz sicher langsamer!"
Und dann kam der Internet Explorer...
Posts: 103
Threads: 22
Joined: Feb 2011
Reputation:
0
Not at all
?
I just downloaded it, put barbar.php in my htdocs, after that I opened the config.php an added the line and finally I included it to the game.php.
I will check again for any mistakes maybe? :/
Posts: 3'166
Threads: 47
Joined: Dec 2008
Reputation:
205
Oh you´re right, thank you parat, updated the script
MfG Manuel
Posts: 103
Threads: 22
Joined: Feb 2011
Reputation:
0
I am sorry to dissapoint you :8 but I had make the same correction as you've done, but now I get this error:
Fatal error: Call to a member function on a non-object in C:\Users\thanos\My Docs\Tribal Wars\TWLan 1.4\htdocs\barbar.php on line 40
Line 40:
$query = $db->query('SELECT * FROM `build` WHERE `end_time` < ' . time());
Any ideas?
Thanos
Posts: 976
Threads: 18
Joined: Jul 2008
Reputation:
34
(This post was last modified: 07.05.2013, 19:00 by Jonsn .)
07.05.2013, 18:27
(06.05.2013, 18:18) SlimShady95 Wrote: - game.php öffnen und nach ?> folgendes einfügen:
PHP Code:
require_once( 'barbar.php' );
Joa das macht viel Sinn
(07.05.2013, 14:19) parat26 Wrote: I am sorry to dissapoint you :8 but I had make the same correction as you've done, but now I get this error:
Fatal error: Call to a member function on a non-object in C:\Users\thanos\My Docs\Tribal Wars\TWLan 1.4\htdocs\barbar.php on line 40
Line 40:
$query = $db->query('SELECT * FROM `build` WHERE `end_time` < ' . time());
Any ideas?
Thanos
PHP Code:
require_once( 'barbar.php' );
Muss ganz nach unten in der game.php, also vor dem
?>
Du suchst ein Tool? Dann sieh doch mal in meine
Toolsammlung !
Posts: 103
Threads: 22
Joined: Feb 2011
Reputation:
0
I saw that I had to include it after ?> but no hope yet
Posts: 976
Threads: 18
Joined: Jul 2008
Reputation:
34
(This post was last modified: 07.05.2013, 19:06 by Jonsn .)
07.05.2013, 19:02
(07.05.2013, 18:56) parat26 Wrote: I saw that I had to include it after ?> but no hope yet
Sorry, in English... Include the code before
?>
Du suchst ein Tool? Dann sieh doch mal in meine
Toolsammlung !
Posts: 103
Threads: 22
Joined: Feb 2011
Reputation:
0
That's what I wanted to say, mispelled it! I checked it right now, and I had put it before ?>.
I believe that putting it after or before doesn't matter however in any away, the real problem is on barbar.php which has no assosiacition with game.php but game.php only includes the code from the file, that's why I believe it's useless to include in before or after (it's the same).
Anyway, maybe Manuel could check the code again
?
Thanos.
Posts: 3'166
Threads: 47
Joined: Dec 2008
Reputation:
205
(This post was last modified: 07.05.2013, 21:47 by SlimShady95 .)
07.05.2013, 21:17
Well, yeah. I will check it now (sorry, slept the whole day
). But it worked on my pc, maybe because I have it very early in the game.php hmm ^^
Wait a few minutes
Ok I fixed it now. It was not my error, hehe. It it because the last line in game.php is exit(); and that means, that nothing after it, will actually be executed.
I found a way to go around this stupid thing.
First post updated!
MfG Manuel
Posts: 103
Threads: 22
Joined: Feb 2011
Reputation:
0
Seems ok so far, however I struggle to figure out how to install it with the "includes.inc.php".
Maybe you could write it in English too
?
Thanos.
Posts: 3'166
Threads: 47
Joined: Dec 2008
Reputation:
205
(This post was last modified: 08.05.2013, 13:58 by SlimShady95 .)
08.05.2013, 13:57
Omg that will be difficult, but I try it for you because I have a very good day
1. [
Download ] and save the file in "htdocs" ("htdocs\barbar.php")
2. Rename your "include.inc.php" to "include2.inc.php"
3. Create a new file named "include.inc.php" in "htdocs" with the following content:
PHP Code:
<?php
require_once( 'include2.inc.php' );
require_once( 'barbar.php' );
4. Open your "config.php" located in "htdocs\include" and add the following thing which controls till how much points the barbars should be build:
PHP Code:
$config [ 'bb_max_points' ] = 3000 ;
5. Maybe restart dslan_start.bat, don't know if this is nessecary
Hope that helps, my English is not the best :/
Have a nice day!
MfG Manuel
Posts: 976
Threads: 18
Joined: Jul 2008
Reputation:
34
(08.05.2013, 13:57) SlimShady95 Wrote: 2. Rename your "include.inc.php" to "include2.inc.php"
3. Create a new file named "include.inc.php" in "htdocs" with the following content:
PHP Code:
<?php
require_once( 'include2.inc.php' );
require_once( 'barbar.php' );
Kannst du mir als PHP Noob das mal erklären?
Was wäre falsch daran, die Datei nicht einfach am Ende der include.inc.php zu includen?
Abgesehen davon hatte ich keine Probleme damit es am ende der game.php zu includen.
Du suchst ein Tool? Dann sieh doch mal in meine
Toolsammlung !
Posts: 3'166
Threads: 47
Joined: Dec 2008
Reputation:
205
Ehrlich gesagt, hatte ich das gar nicht versucht *shame*
Hab das von Molt glaub geklaut, der hatte das mal auf die Art gelöst
Das mit der game.php ist glaub auch erst ab 1.4+ so, bei 1.3 war das noch nicht so.
Muss jetzt leider auch los, Volksfest wartet, sonst würde ich dir das genauer erklären ^^
MfG Manuel
Posts: 618
Threads: 9
Joined: Dec 2010
Reputation:
19
immer diese säufer ich glaub vor der 1.4 wurde das programm noch in dem codierten teil beendet und folglich zählt alles was nach der codierung kommt nicht mehr wenn ich hier irchtig gelesen hab
Falls ich dir helfen konnte
bewerte mich bitte
Posts: 3'166
Threads: 47
Joined: Dec 2008
Reputation:
205
Säufer? Pass auf was du sagst. Ich bin eigentlich seit Halloween letztes Jahr trocken.
Ja scheiß egal wieso, so wie die Anleitung oben is, geht's
MfG Manuel
Posts: 2'493
Threads: 43
Joined: Mar 2010
Reputation:
87
Am Ende der include.inc.php kann man nix anhängen... aus Gründen und so, kein Plan was da wirklich läuft.
Bei allen anderen Dateien geht's aber... ich müsst' eigentlich mal was mit nem Hook für die Events releasen...
Posts: 3'166
Threads: 47
Joined: Dec 2008
Reputation:
205
(This post was last modified: 09.05.2013, 13:57 by SlimShady95 .)
09.05.2013, 13:56
Öhm laut Code sollte das aber funktionieren. Oder wo soll so ne Sperre sein?
Selbst in game.php is nichts, wundert mich, warum das dann nicht geht
MfG Manuel
Posts: 2'493
Threads: 43
Joined: Mar 2010
Reputation:
87
Kein Plan, aber es geht halt nicht... ^^