Thread denkfehler in schleife (12 answers)
Opened by FlorianL at 2007-06-28 11:20

FlorianL
 2007-06-28 12:08
#77935 #77935
User since
2007-05-18
142 Artikel
BenutzerIn
[default_avatar]
Morgen renee, hatte schon befürchtet du bist vieleicht im urlaub ;)

Also trotz deiner änderungen nimmt er sich nur die letze id die er auf der seite findet, vieleicht hab ich sonst nen fehler drin?!

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
sub attack {
        $agent->follow_link (n => 1 );
        $agent->follow_link (text => "Einstellungen", n => 1);
        $agent->follow_link (text => "Battle Home", n => 1);
        $agent->follow_link (text => "Targets", n => 1);
        if ($DEBUG == '1') { print("DEBUG: Getting Targets...\n");}
        my @targetsite = $agent->content;
        if ($DEBUG == '1') { print("DEBUG: Parsing Victims...\n");}
        my @targets;
        foreach (@targetsite) {
               
 push @targets, $_ =~ m/.+act=attack&m=(\d+)/;
        }
        if ($DEBUG == '1') { print ("DEBUG: Found Target: @targets\n");}
        if ($DEBUG == '1') { print("DEBUG: Attacking...\n");}
        foreach (@targets) {
               
 my $target = $_;
               
 $agent->get("http://$url/index.php?act=attack&m=$target");
               
 if ($DEBUG == '1') { print("DEBUG: Choosing best Weapon...\n");}
               
 my @weaponlist = $agent->content =~ m/.+&w=(\d)/;
               
 my @weapons = sort(@weaponlist);
               
 my $count = '1';
               
 if (defined $weapons[0]) {
               
         if ($DEBUG == '1') { print("DEBUG: Attack \#$count\n");}
               
         $agent->get("http://$url/index.php?act=attack&m=$target&w=$weapons[0]");
               
         print("\#$count $username Attacked Target id $target with Weapon $weapons[0]\n");
               
         $count++;
               
 } else {
               
         print("Cant attack $_, moving on to next Victim\n")
               
 }
               
 if ($count == '4') {
               
         print("Attacked 4 Targets, stopping...");
               
         exit 0;
               
 }
        }
        if ($DEBUG == '1') { print("DEBUG: Attack finished\n");}
}

View full thread denkfehler in schleife