Saturday, July 17, 2010

penjelasan tentang bot yang belum bisa berjalan (kebanyakan karena masalah key ato nomor togel didalam function.pl)

memang dalam bot sekarang key ato biasa disebut ma orang2 itu nomor togel selalu berubah2, jadi tiap kita DC bila nomor togel melewati masa expire maka kita harus ganti nomor togel lg. nomor togel terletak didalam folder src didalam file function.pl.


contoh nomor togel : 52 95 47 57 F4 7B E2 DD CB 59 3D DC 19 37 09 22 D4 06 83 9C FA 62 EC 99 1C 9B 8E 89 B0 63 67 84 B3 18 A2 DA CA D7 64 4B C9 ED 1B 86 5B 9F 0A 12 31 B9 F9 6A E9 C4 C5 5A 05 68 EB 35 E1 5F B1 8F 96 2C 6C 45 E7 BE 2B 6D 70 EA 90 08 7A AF 7D FC 73 0E D8 2E CE F5 BF A8 B8 36 74 53 5D 26 51 DF FD 50 F7 65 7E B4 F1 D9 AC EF BD 43 6F 28 69 60 56 9A 01 B5 C2 8A C0 A9 F6 1D 32 78 14 48 AA 44 BC 6E 82 A0 24 85 79 00 25 C8 02 E5 23 4E 3C 58 A6 71 E3 2A B7 D0 5E 46 DE AB 66 4A E4 CC 15 87 41 A5 38 03 34 0D E6 D3 1A F2 2F 97 8C 72 29 54 61 77 4C C6 8D AE F0 CD 13 75 BB 04 3F 33 A4 4F 3E F8 B6 80 1F 0B 5C D2 88 E0 E8 42 B2 11 40 2D 3A 6B FE 9E 20 1E 10 7C 81 17 D6 A7 8B FF 91 92 A3 FB AD 93 98 27 EE C3 0C F3 49 9D DB D5 30 BA 21 C1 16 39 76 A1 7F CF 3B 94 55 C7 07 4D 0F D1

ne tak kaseh function.pl yang udah siap pake, tp nomor togel tetap harus up to date. tinggal di copy trus di paste aja di dalam file function.pl di folder src kamu.

#########################################################################
# This software is open source, licensed under the GNU General Public
# License, version 2.
# Basically, this means that you're allowed to modify and distribute
# this software. However, if you distribute modified versions, you MUST
# also distribute the source code.
# See http://www.gnu.org/licenses/gpl.html for the full license.
#########################################################################

package main;
use strict;
use Time::HiRes qw(time usleep);
use IO::Socket;
use Text::ParseWords;
use Carp::Assert;
use Config;
use encoding 'utf8';

use Globals;
use Modules;
use Settings qw(%sys %options);
use Log qw(message warning error debug);
use Interface;
use Network::Receive;
use Network::Send ();
use Network::PaddedPackets;
use Network::MessageTokenizer;
use Commands;
use Misc;
use Plugins;
use Utils;
use ChatQueue;
use I18N;
use Utils::Benchmark;
use Utils::HttpReader;


#######################################
# PROGRAM INITIALIZATION
#######################################



use constant {
    STATE_LOAD_PLUGINS          => 0,
    STATE_LOAD_DATA_FILES       => 1,
    STATE_INIT_NETWORKING       => 2,
    STATE_INIT_PORTALS_DATABASE => 3,
    STATE_PROMPT                => 4,
    STATE_FINAL_INIT            => 5,
    STATE_INITIALIZED           => 6
};

our $state;

sub mainLoop {
    Benchmark::begin('mainLoop') if DEBUG;
    $state = STATE_LOAD_PLUGINS if (!defined $state);

    # Parse command input
    my $input;
    if (defined($input = $interface->getInput(0))) {
        Misc::checkValidity("parseInput (pre)");
        parseInput($input);
        Misc::checkValidity("parseInput");
    }


    if ($state == STATE_INITIALIZED) {
        Plugins::callHook('mainLoop_pre');
        mainLoop_initialized();
        Plugins::callHook('mainLoop_post');

    } elsif ($state == STATE_LOAD_PLUGINS) {
        Log::message("$Settings::versionText\n");
        loadPlugins();
        Log::message("\n");
        Plugins::callHook('start');
        $state = STATE_LOAD_DATA_FILES;

    } elsif ($state == STATE_LOAD_DATA_FILES) {
        loadDataFiles();
        $state = STATE_INIT_NETWORKING;

    } elsif ($state == STATE_INIT_NETWORKING) {
        initNetworking();
        $state = STATE_INIT_PORTALS_DATABASE;

    } elsif ($state == STATE_INIT_PORTALS_DATABASE) {
        initPortalsDatabase();
        $state = STATE_PROMPT;

    } elsif ($state == STATE_PROMPT) {
        promptFirstTimeInformation();
        $state = STATE_FINAL_INIT;

    } elsif ($state == STATE_FINAL_INIT) {
        finalInitialization();
        $state = STATE_INITIALIZED;

    } else {
        die "Unknown state $state.";
    }

    Benchmark::end('mainLoop') if DEBUG;
    # Reload any modules that requested to be reloaded
    Modules::reloadAllInQueue();
}

sub loadPlugins {
    eval {
        Plugins::loadAll();
    };
    if (my $e = caught('Plugin::LoadException')) {
        $interface->errorDialog(TF("This plugin cannot be loaded because of a problem in the plugin. " .
            "Please notify the plugin's author about this problem, " .
            "or remove the plugin so %s can start.\n\n" .
            "The error message is:\n" .
            "%s",
            $Settings::NAME, $e->message));
        exit 1;
    } elsif (my $e = caught('Plugin::DeniedException')) {
        $interface->errorDialog($e->message);
        exit 1;
    } elsif ($@) {
        die $@;
    }
}

sub loadDataFiles {
    # These pragmas are necessary in order to support non-ASCII filenames.
    # If we use UTF-8 strings then Perl will think the file doesn't exist,
    # if $Settings::control_folder or $Settings::tables_folder contains
    # non-ASCII characters.
    no encoding 'utf8';

    # Add loading of Control files
    Settings::addControlFile(Settings::getConfigFilename(),
        loader => [\&parseConfigFile, \%config],
        internalName => 'config.txt',
        autoSearch => 0);
    Settings::addControlFile(Settings::getMonControlFilename(),
        loader => [\&parseMonControl, \%mon_control],
        internalName => 'mon_control.txt',
        autoSearch => 0);
    Settings::addControlFile(Settings::getItemsControlFilename(),
        loader => [\&parseItemsControl, \%items_control],
        internalName => 'items_control.txt',
        autoSearch => 0);
    Settings::addControlFile(Settings::getShopFilename(),
        loader => [\&parseShopControl, \%shop],
        internalName => 'shop.txt',
        autoSearch => 0);
    Settings::addControlFile('overallAuth.txt',
        loader => [\&parseDataFile, \%overallAuth]);
    Settings::addControlFile('pickupitems.txt',
        loader => [\&parseDataFile_lc, \%pickupitems]);
    Settings::addControlFile('responses.txt',
        loader => [\&parseResponses, \%responses]);
    Settings::addControlFile('timeouts.txt',
        loader => [\&parseTimeouts, \%timeout]);
    Settings::addControlFile('chat_resp.txt',
        loader => [\&parseChatResp, \@chatResponses]);
    Settings::addControlFile('avoid.txt',
        loader => [\&parseAvoidControl, \%avoid]);
    Settings::addControlFile('priority.txt',
        loader => [\&parsePriority, \%priority]);
    Settings::addControlFile('consolecolors.txt',
        loader => [\&parseSectionedFile, \%consoleColors]);
    Settings::addControlFile('routeweights.txt',
        loader => [\&parseDataFile, \%routeWeights]);
    Settings::addControlFile('arrowcraft.txt',
        loader => [\&parseDataFile_lc, \%arrowcraft_items]);

    # Loading of Table files
    # Load Servers.txt first
    Settings::addTableFile('servers.txt',
        loader => [\&parseSectionedFile, \%masterServers],
        onLoaded => \&processServerSettings );
    # Load RecvPackets.txt second
     Settings::addTableFile(Settings::getRecvPacketsFilename(),
         loader => [\&parseDataFile2, \%rpackets]);

    # Add 'Old' table pack, if user set
    if ( $sys{locale_compat} == 1) {
        # Holder for new path
        my @new_tables;
        my $pathDelimiter = ($^O eq 'MSWin32') ? ';' : ':';
        if ($options{tables}) {
            foreach my $dir ( split($pathDelimiter, $options{tables}) ) {
                push @new_tables, $dir . '/Old';
            }
        } else {
            push @new_tables, 'tables/Old';
        }
        # now set up new path to table folder
        Settings::setTablesFolders(@new_tables, Settings::getTablesFolders());
    }

    # Load all other tables
    Settings::addTableFile('cities.txt',
        loader => [\&parseROLUT, \%cities_lut]);
    Settings::addTableFile('commanddescriptions.txt',
        loader => [\&parseCommandsDescription, \%descriptions]);
    Settings::addTableFile('directions.txt',
        loader => [\&parseDataFile2, \%directions_lut]);
    Settings::addTableFile('elements.txt',
        loader => [\&parseROLUT, \%elements_lut]);
    Settings::addTableFile('emotions.txt',
        loader => [\&parseEmotionsFile, \%emotions_lut]);
    Settings::addTableFile('equiptypes.txt',
        loader => [\&parseDataFile2, \%equipTypes_lut]);
    Settings::addTableFile('haircolors.txt',
        loader => [\&parseDataFile2, \%haircolors]);
    Settings::addTableFile('headgears.txt',
        loader => [\&parseArrayFile, \@headgears_lut]);
    Settings::addTableFile('items.txt',
        loader => [\&parseROLUT, \%items_lut]);
    Settings::addTableFile('itemsdescriptions.txt',
        loader => [\&parseRODescLUT, \%itemsDesc_lut]);
    Settings::addTableFile('itemslots.txt',
        loader => [\&parseROSlotsLUT, \%itemSlots_lut]);
    Settings::addTableFile('itemslotcounttable.txt',
        loader => [\&parseROLUT, \%itemSlotCount_lut]);
    Settings::addTableFile('itemtypes.txt',
        loader => [\&parseDataFile2, \%itemTypes_lut]);
    Settings::addTableFile('resnametable.txt',
        loader => [\&parseROLUT, \%mapAlias_lut, 1, ".gat"]);
    Settings::addTableFile('maps.txt',
        loader => [\&parseROLUT, \%maps_lut]);
    Settings::addTableFile('monsters.txt',
        loader => [\&parseDataFile2, \%monsters_lut]);
    Settings::addTableFile('npcs.txt',
        loader => [\&parseNPCs, \%npcs_lut]);
    Settings::addTableFile('packetdescriptions.txt',
        loader => [\&parseSectionedFile, \%packetDescriptions]);
    Settings::addTableFile('portals.txt',
        loader => [\&parsePortals, \%portals_lut]);
    Settings::addTableFile('portalsLOS.txt',
        loader => [\&parsePortalsLOS, \%portals_los]);
    Settings::addTableFile('sex.txt',
        loader => [\&parseDataFile2, \%sex_lut]);
    Settings::addTableFile('SKILL_id_handle.txt',
        loader => \&Skill::StaticInfo::parseSkillsDatabase_id2handle);
    Settings::addTableFile('skillnametable.txt',
        loader => \&Skill::StaticInfo::parseSkillsDatabase_handle2name);
    Settings::addTableFile('spells.txt',
        loader => [\&parseDataFile2, \%spells_lut]);
    Settings::addTableFile('skillsdescriptions.txt',
        loader => [\&parseRODescLUT, \%skillsDesc_lut]);
    Settings::addTableFile('skillssp.txt',
        loader => \&Skill::StaticInfo::parseSPDatabase);
    Settings::addTableFile('STATUS_id_handle.txt',
        loader => [\&parseDataFile2, \%statusHandle]);
    Settings::addTableFile('STATE_id_handle.txt',
        loader => [\&parseDataFile2, \%stateHandle]);
    Settings::addTableFile('LOOK_id_handle.txt',
        loader => [\&parseDataFile2, \%lookHandle]);
    Settings::addTableFile('AILMENT_id_handle.txt',
        loader => [\&parseDataFile2, \%ailmentHandle]);
    Settings::addTableFile('statusnametable.txt',
        loader => [\&parseDataFile2, \%statusName]);
    Settings::addTableFile('skillsarea.txt',
        loader => [\&parseDataFile2, \%skillsArea]);
    Settings::addTableFile('skillsencore.txt',
        loader => [\&parseList, \%skillsEncore]);
    Settings::addTableFile('quests.txt',
        loader => [\&parseROQuestsLUT, \%quests_lut],
        mustExist => 0);

    use encoding 'utf8';

    Plugins::callHook('start2');
    eval {
        my $progressHandler = sub {
            my ($filename) = @_;
            message TF("Loading %s...\n", $filename);
        };
        Settings::loadAll($progressHandler);
    };
    if (my $e = caught('UTF8MalformedException')) {
        $interface->errorDialog(TF(
            "The file %s must be valid UTF-8 encoded, which it is \n" .
            "currently not. To solve this prolem, please use Notepad\n" .
            "to save that file as valid UTF-8.",
            $e->textfile));
        exit 1;
    } elsif (my $e = caught('FileNotFoundException')) {
        $interface->errorDialog(TF("Unable to load the file %s.", $e->filename));
        exit 1;
    } elsif ($@) {
        die $@;
    }
    Plugins::callHook('start3');

    if ($config{'adminPassword'} eq 'x' x 10) {
        Log::message(T("\nAuto-generating Admin Password due to default...\n"));
        configModify("adminPassword", vocalString(8));
    #} elsif ($config{'adminPassword'} eq '') {
    #    # This is where we protect the stupid from having a blank admin password
    #    Log::message(T("\nAuto-generating Admin Password due to blank...\n"));
    #    configModify("adminPassword", vocalString(8));
    } elsif ($config{'secureAdminPassword'} eq '1') {
        # This is where we induldge the paranoid and let them have session generated admin passwords
        Log::message(T("\nGenerating session Admin Password...\n"));
        configModify("adminPassword", vocalString(8));
    }

    Log::message("\n");
}

sub initNetworking {
    our $XKore_dontRedirect = 0;
    my $XKore_version = $config{XKore} ? $config{XKore} : $sys{XKore};
    eval {
        if ($XKore_version eq "1" || $XKore_version eq "inject") {
            # Inject DLL to running Ragnarok process
            require Network::XKore;
            $net = new Network::XKore;
        } elsif ($XKore_version eq "2") {
            # Run as a proxy bot, allowing Ragnarok to connect while botting
            require Network::DirectConnection;
            require Network::XKore2;
            $net = new Network::DirectConnection;
            Network::XKore2::start();
        } elsif ($XKore_version eq "3" || $XKore_version eq "proxy") {
            # Proxy Ragnarok client connection
            require Network::XKoreProxy;
            $net = new Network::XKoreProxy;
        } else {
            # Run as a standalone bot, with no interface to the official RO client
            require Network::DirectConnection;
            $net = new Network::DirectConnection;
        }
    };
    if ($@) {
        # Problem with networking.
        $interface->errorDialog($@);
        exit 1;
    }

    if ($sys{bus}) {
        require Bus::Client;
        require Bus::Handlers;
        my $host = $sys{bus_server_host};
        my $port = $sys{bus_server_port};
        $host = undef if ($host eq '');
        $port = undef if ($port eq '');
        $bus = new Bus::Client(host => $host, port => $port);
        our $busMessageHandler = new Bus::Handlers($bus);
    }
   
    Network::PaddedPackets::init();
}

sub initPortalsDatabase {
    # $config{portalCompile}
    # -1: skip compile
    #  0: ask user
    #  1: auto compile
   
    # TODO: detect when another instance already compiles portals?
   
    return if $config{portalCompile} < 0;
   
    Log::message(T("Checking for new portals... "));
    if (compilePortals_check()) {
        Log::message(T("found new portals!\n"));
        my $choice = $config{portalCompile} ? 0 : $interface->showMenu(
            T("New portals have been added to the portals database. " .
            "The portals database must be compiled before the new portals can be used. " .
            "Would you like to compile portals now?\n"),
            [T("Yes, compile now."), T("No, don't compile it.")],
            title => T("Compile portals?"));
        if ($choice == 0) {
            Log::message(T("compiling portals") . "\n\n");
            compilePortals();
        } else {
            Log::message(T("skipping compile") . "\n\n");
        }
    } else {
        Log::message(T("none found\n\n"));
    }
}

sub promptFirstTimeInformation {
    if ($net->version != 1) {
        my $msg;
        if (!$config{username}) {
            $msg = $interface->query(T("Please enter your Ragnarok Online username."));
            if (!defined($msg)) {
                exit;
            }
            configModify('username', $msg, 1);
        }
        if (!$config{password}) {
            $msg = $interface->query(T("Please enter your Ragnarok Online password."), isPassword => 1);
            if (!defined($msg)) {
                exit;
            }
            configModify('password', $msg, 1);
        }
    }
}

sub processServerSettings {
    my $filename = shift;
    # Select Master server on Demand

    if ($config{master} eq "" || $config{master} =~ /^\d+$/ || !exists $masterServers{$config{master}}) {
        my @servers = sort { lc($a) cmp lc($b) } keys(%masterServers);
        my $choice = $interface->showMenu(
            T("Please choose a master server to connect to."),
            \@servers,
            title => T("Master servers"));
        if ($choice == -1) {
            exit;
        } else {
            configModify('master', $servers[$choice], 1);
        }
    }

    # Parse server settings
    my $master = $masterServer = $masterServers{$config{master}};
    foreach my $serverOption ('serverType', 'chatLangCode', 'storageEncryptKey', 'gameGuard', 'charBlockSize',
                'paddedPackets', 'paddedPackets_attackID', 'paddedPackets_skillUseID',
                'mapServer_ip', 'mapServer_port') {
        if ($master->{$serverOption} ne '' && $config{$serverOption} ne $master->{$serverOption}) {
            # Delete Wite Space
            $master->{$serverOption} =~ s/^\s//;
            $master->{$serverOption} =~ s/\s$//;
            # Set config
            configModify($serverOption, $master->{$serverOption});
        }
    }

    if ($master->{serverEncoding} ne '' && $config{serverEncoding} ne $master->{serverEncoding}) {
        configModify('serverEncoding', $master->{serverEncoding});
    } elsif ($config{serverEncoding} eq '') {
        configModify('serverEncoding', 'Western');
    }

    # Process adding ServerType specific table folders
    my ($st_mode, $st_type, $st_param) = Settings::parseServerType($masterServer->{serverType}) if ($master->{serverType} && $master->{serverType} ne '') ;
    if ($st_mode == 1) {
        # Holder for new path
        my @new_tables;
        # for each table folders path we add our own, whatever it exist or not
        foreach my $dir ( Settings::getTablesFolders() ) {
            # If the ServerType is with sub type
            if (defined($st_param) && $st_param ne '') {
                push @new_tables, $dir . '/' . $st_type . '/' . $st_param;
            }
            push @new_tables, $dir . '/' . $st_type;
            push @new_tables, $dir;
        }
        # now set up new path to table folders
        Settings::setTablesFolders(grep -d, @new_tables);
    }
   
    # Process adding Custom Table folders
    if($masterServer->{addTableFolders}) {
        Settings::addTablesFolders($masterServer->{addTableFolders});
    }
   
    # Process setting custom recvpackets option
    Settings::setRecvPacketsName($masterServer->{recvpackets} && $masterServer->{recvpackets} ne '' ? $masterServer->{recvpackets} : Settings::getRecvPacketsFilename() );
}

sub finalInitialization {
    $incomingMessages = new Network::MessageTokenizer(\%rpackets);
    $outgoingClientMessages = new Network::MessageTokenizer(\%rpackets);

    $KoreStartTime = time;
    $conState = 1;
    our $nextConfChangeTime;
    $bExpSwitch = 2;
    $jExpSwitch = 2;
    $totalBaseExp = 0;
    $totalJobExp = 0;
    $startTime_EXP = time;
    $taskManager = new TaskManager();
    # run 'permanent' tasks
    for (qw/Task::RaiseStat Task::RaiseSkill/) {
        eval "require $_";
        $taskManager->add($_->new);
    }

    # protect actor hashes from autovivification
    require Utils::ActorHashTie;
    tie %items, 'Tie::ActorHash';
    tie %monsters, 'Tie::ActorHash';
    tie %players, 'Tie::ActorHash';
    tie %pets, 'Tie::ActorHash';
    tie %npcs, 'Tie::ActorHash';
    tie %portals, 'Tie::ActorHash';
    tie %slaves, 'Tie::ActorHash';

    $itemsList = new ActorList('Actor::Item');
    $monstersList = new ActorList('Actor::Monster');
    $playersList = new ActorList('Actor::Player');
    $petsList = new ActorList('Actor::Pet');
    $npcsList = new ActorList('Actor::NPC');
    $portalsList = new ActorList('Actor::Portal');
    $slavesList = new ActorList('Actor::Slave');
    foreach my $list ($itemsList, $monstersList, $playersList, $petsList, $npcsList, $portalsList, $slavesList) {
        $list->onAdd()->add(undef, \&actorAdded);
        $list->onRemove()->add(undef, \&actorRemoved);
        $list->onClearBegin()->add(undef, \&actorListClearing);
    }

    StdHttpReader::init();
    initStatVars();
    initRandomRestart();
    initUserSeed();
    initConfChange();
    Log::initLogFiles();
    $timeout{'injectSync'}{'time'} = time;

    Log::message("\n");
   
    Log::message("Initialized, use 'connect' to continue\n") if $Settings::no_connect;

    Plugins::callHook('initialized');
    XSTools::initVersion();
}


#######################################
# VARIABLE INITIALIZATION FUNCTIONS
#######################################

# Calculate next random restart time.
# The restart time will be autoRestartMin + rand(autoRestartSeed)
sub initRandomRestart {
    if ($config{'autoRestart'}) {
        my $autoRestart = $config{'autoRestartMin'} + int(rand $config{'autoRestartSeed'});
        message TF("Next restart in %s\n", timeConvert($autoRestart)), "system";
        configModify("autoRestart", $autoRestart, 1);
    }
}

# Initialize random configuration switching time
sub initConfChange {
    my $i = 0;
    while (exists $ai_v{"autoConfChange_${i}_timeout"}) {
        delete $ai_v{"autoConfChange_${i}_timeout"};
        $i++;
    }

    $i = 0;
    while (exists $config{"autoConfChange_$i"}) {
        $ai_v{"autoConfChange_${i}_timeout"} = $config{"autoConfChange_${i}_minTime"} +
            int(rand($config{"autoConfChange_${i}_varTime"}));
        $i++;
    }
    $lastConfChangeTime = time;
}

# Initialize variables when you start a connection to a map server
sub initConnectVars {
    # we must use $chars[$config{char}] here because $char may not be set
    initMapChangeVars();
    if ($char) {
        $char->{skills} = {};
        delete $char->{mute_period};
        delete $char->{muted};
    }
    undef @skillsID;
    $useArrowCraft = 1;
}

# Initialize variables when you change map (after a teleport or after you walked into a portal)
sub initMapChangeVars {
    # we must use $chars[$config{char}] here because $char may not be set
    @portalsID_old = @portalsID;
    %portals_old = %portals;
    foreach (@portalsID_old) {
        next if (!$_ || !$portals_old{$_});
        $portals_old{$_}{gone_time} = time if (!$portals_old{$_}{gone_time});
    }

    # this is just used for portalRecord (add opposite portal by guessing method)
    if ($char) {
        $char->{old_pos_to} = {%{$char->{pos_to}}} if ($char->{pos_to});
        delete $char->{sitting};
        delete $char->{dead};
        delete $char->{warp};
        delete $char->{casting};
        delete $char->{homunculus}{appear_time} if $char->{homunculus};
        $char->inventory->clear();
    }
    $timeout{play}{time} = time;
    $timeout{ai_sync}{time} = time;
    $timeout{ai_sit_idle}{time} = time;
    $timeout{ai_teleport}{time} = time;
    $timeout{ai_teleport_idle}{time} = time;
    $timeout{ai_teleport_safe_force}{time} = time;

    delete $timeout{ai_teleport_retry}{time};
    delete $timeout{ai_teleport_delay}{time};

    undef %incomingDeal;
    undef %outgoingDeal;
    undef %currentDeal;
    undef $currentChatRoom;
    undef @currentChatRoomUsers;
    undef @itemsID;
    undef @identifyID;
    undef @spellsID;
    undef @arrowCraftID;
    undef %items;
    undef %spells;
    undef %incomingParty;
    undef %talk;
    $ai_v{cart_time} = time + 60;
    $ai_v{inventory_time} = time + 60;
    $ai_v{temp} = {};
    $cart{inventory} = [];
    undef @venderItemList;
    undef $venderID;
    undef $venderCID;
    undef @venderListsID;
    undef %venderLists;
    undef %incomingGuild;
    undef @chatRoomsID;
    undef %chatRooms;
    undef %createdChatRoom;
    undef @lastpm;
    undef %incomingFriend;
    undef $repairList;
    undef $devotionList;
    undef $cookingList;
    $captcha_state = 0;

    $itemsList->clear();
    $monstersList->clear();
    $playersList->clear();
    $petsList->clear();
    $portalsList->clear();
    $npcsList->clear();
    $slavesList->clear();

    @unknownPlayers = ();
    @unknownNPCs = ();
    @sellList = ();

    $shopstarted = 0;
    $timeout{ai_shop}{time} = time;
    $timeout{ai_storageAuto}{time} = time + 5;
    $timeout{ai_buyAuto}{time} = time + 5;
    $timeout{ai_shop}{time} = time;

    AI::clear("attack", "move");
    AI::SlaveManager::clear("attack", "route", "move");
    ChatQueue::clear;

    Plugins::callHook('packet_mapChange');

    $logAppend = ($config{logAppendUsername}) ? "_$config{username}_$config{char}" : '';
    if ($config{logAppendUsername} && index($Settings::storage_log_file, $logAppend) == -1) {
        $Settings::chat_log_file     = substr($Settings::chat_log_file,    0, length($Settings::chat_log_file)    - 4) . "$logAppend.txt";
        $Settings::storage_log_file  = substr($Settings::storage_log_file, 0, length($Settings::storage_log_file) - 4) . "$logAppend.txt";
        $Settings::shop_log_file     = substr($Settings::shop_log_file,    0, length($Settings::shop_log_file)    - 4) . "$logAppend.txt";
        $Settings::monster_log_file  = substr($Settings::monster_log_file, 0, length($Settings::monster_log_log)  - 4) . "$logAppend.txt";
        $Settings::item_log_file     = substr($Settings::item_log_file,    0, length($Settings::item_log_file)    - 4) . "$logAppend.txt";
    }
}

# Initialize variables when your character logs in
sub initStatVars {
    $totaldmg = 0;
    $dmgpsec = 0;
    $startedattack = 0;
    $monstarttime = 0;
    $monkilltime = 0;
    $elasped = 0;
    $totalelasped = 0;
}


#####################################################
# MISC. MAIN LOOP FUNCTIONS
#####################################################


# This function is called every time in the main loop, when OpenKore has been
# fully initialized.
sub mainLoop_initialized {
    Benchmark::begin("mainLoop_part1") if DEBUG;

    # Handle connection states
    $net->checkConnection();

    # Receive and handle data from the RO server
    my $data = $net->serverRecv;
    if (defined($data) && length($data) > 0) {
    if ($net->getState() < 2){
             $data = idro_decrypt($data);
          }

        Benchmark::begin("parseMsg") if DEBUG;

        my $type;
        $incomingMessages->add($data);
        while ($data = $incomingMessages->readNext(\$type)) {
            if ($type == Network::MessageTokenizer::KNOWN_MESSAGE) {
                parseIncomingMessage($data);
            } else {
                if ($type == Network::MessageTokenizer::UNKNOWN_MESSAGE) {
                    # Unknown message - ignore it
                    my $messageID = Network::MessageTokenizer::getMessageID($data);
                    if (!existsInList($config{debugPacket_exclude}, $messageID)) {
                        warning TF("Packet Tokenizer: Unknown switch: %s\n", $messageID), "connection";
                        visualDump($data, "<< Received unknown packet") if ($config{debugPacket_unparsed});
                    }
                } elsif ($config{debugPacket_received}) {
                    debug "Received account ID\n", "parseMsg", 0 ;
                }
                # Pass it along to the client, whatever it is
                $net->clientSend($data);
            }
        }
        $net->clientFlush() if (UNIVERSAL::isa($net, 'Network::XKoreProxy'));
        Benchmark::end("parseMsg") if DEBUG;
    }

    # Receive and handle data from the RO client
    $data = $net->clientRecv;
    if (defined($data) && length($data) > 0) {
      if ($net->getState() < 2){
         $data = idro_decrypt($data);
      }
        my $type;
        $outgoingClientMessages->add($data);
        while ($data = $outgoingClientMessages->readNext(\$type)) {
            parseOutgoingClientMessage($data);
        }
    }

    # GameGuard support
    if ($config{gameGuard} && ($net->version != 1 || ($net->version == 1 && $config{gameGuard} eq '2'))) {
        my $result = Poseidon::Client::getInstance()->getResult();
        if (defined($result)) {
            debug "Received Poseidon result.\n", "poseidon";
            $messageSender->encryptMessageID(\$result);
            $net->serverSend($result);
        }
    }

    Benchmark::end("mainLoop_part1") if DEBUG;
    Benchmark::begin("mainLoop_part2") if DEBUG;

    # Process AI
    if ($net->getState() == Network::IN_GAME && timeOut($timeout{ai}) && $net->serverAlive()) {
        Misc::checkValidity("AI (pre)");
        Benchmark::begin("ai") if DEBUG;
        AI::CoreLogic::iterate();
        Benchmark::end("ai") if DEBUG;
        Benchmark::begin("ai_homunculus") if DEBUG;
        AI::SlaveManager::iterate();
        Benchmark::end("ai_homunculus") if DEBUG;
        Misc::checkValidity("AI");
        return if $quit;
    }
    Misc::checkValidity("mainLoop_part2.1");
    $taskManager->iterate();

    Benchmark::end("mainLoop_part2") if DEBUG;
    Benchmark::begin("mainLoop_part3") if DEBUG;

    # Process bus events.
    $bus->iterate() if ($bus);
    Misc::checkValidity("mainLoop_part2.2");


    ###### Other stuff that's run in the main loop #####

    if ($config{'autoRestart'} && time - $KoreStartTime > $config{'autoRestart'}
     && $net->getState() == Network::IN_GAME && !AI::inQueue(qw/attack take items_take/)) {
        message T("\nAuto-restarting!!\n"), "system";

        if ($config{'autoRestartSleep'}) {
            my $sleeptime = $config{'autoSleepMin'} + int(rand $config{'autoSleepSeed'});
            $timeout_ex{'master'}{'timeout'} = $sleeptime;
            $sleeptime = $timeout{'reconnect'}{'timeout'} if ($sleeptime < $timeout{'reconnect'}{'timeout'});
            message TF("Sleeping for %s\n", timeConvert($sleeptime)), "system";
        } else {
            $timeout_ex{'master'}{'timeout'} = $timeout{'reconnect'}{'timeout'};
        }

        $timeout_ex{'master'}{'time'} = time;
        $KoreStartTime = time + $timeout_ex{'master'}{'timeout'};
        AI::clear();
        AI::SlaveManager::clear();
        undef %ai_v;
        $net->serverDisconnect;
        $net->setState(Network::NOT_CONNECTED);
        undef $conState_tries;
        initRandomRestart();
    }
   
    Misc::checkValidity("mainLoop_part2.3");

    # Automatically switch to a different config file
    # based on certain conditions
    if ($net->getState() == Network::IN_GAME && timeOut($AI::Timeouts::autoConfChangeTime, 0.5)
     && !AI::inQueue(qw/attack take items_take/)) {
        my $selected;
        my $i = 0;
        while (exists $config{"autoConfChange_$i"}) {
            if ($config{"autoConfChange_$i"}
             && ( !$config{"autoConfChange_${i}_minTime"} || timeOut($lastConfChangeTime, $ai_v{"autoConfChange_${i}_timeout"}) )
             && inRange($char->{lv}, $config{"autoConfChange_${i}_lvl"})
             && inRange($char->{lv_job}, $config{"autoConfChange_${i}_joblvl"})
             && ( !$config{"autoConfChange_${i}_isJob"} || $jobs_lut{$char->{jobID}} eq $config{"autoConfChange_${i}_isJob"} )
            ) {
                $selected = $config{"autoConfChange_$i"};
                last;
            }
            $i++;
        }

        if ($selected) {
            # Choose a random configuration file
            my @files = split(/,+/, $selected);
            my $file = $files[rand(@files)];
            message TF("Changing configuration file (from \"%s\" to \"%s\")...\n", $Settings::config_file, $file), "system";

            # A relogin is necessary if the server host/port, username
            # or char is different.
            my $oldMaster = $masterServer;
            my $oldUsername = $config{'username'};
            my $oldChar = $config{'char'};

            switchConfigFile($file);

            my $master = $masterServer = $masterServers{$config{'master'}};
            if ($net->version != 1
             && $oldMaster->{ip} ne $master->{ip}
             || $oldMaster->{port} ne $master->{port}
             || $oldMaster->{master_version} ne $master->{master_version}
             || $oldMaster->{version} ne $master->{version}
             || $oldUsername ne $config{'username'}
             || $oldChar ne $config{'char'}) {
                AI::clear;
                AI::SlaveManager::clear();
                relog();
            } else {
                AI::clear("move", "route", "mapRoute");
                AI::SlaveManager::clear("move", "route", "mapRoute");
            }

            initConfChange();
        }

        $AI::Timeouts::autoConfChangeTime = time;
    }

    #processStatisticsReporting() unless ($sys{sendAnonymousStatisticReport} eq "0");

    Misc::checkValidity("mainLoop_part2.4");
   
    # Set interface title
    my $charName;
    my $title;
    $charName = "$char->{name}: " if ($char);
    if ($net->getState() == Network::IN_GAME) {
        my ($basePercent, $jobPercent, $weight, $pos);

        assert(defined $char);
        $basePercent = sprintf("%.2f", $char->{exp} / $char->{exp_max} * 100) if ($char->{exp_max});
        $jobPercent = sprintf("%.2f", $char->{exp_job} / $char->{exp_job_max} * 100) if ($char->{exp_job_max});
        $weight = int($char->{weight} / $char->{weight_max} * 100) . "%" if ($char->{weight_max});
        $pos = " : $char->{pos_to}{x},$char->{pos_to}{y} " . $field->name() if ($char->{pos_to} && $field);

        # Translation Comment: Interface Title with character status
        $title = TF("%s B%s (%s), J%s (%s) : w%s%s - %s",
            $charName, $char->{lv}, $basePercent . '%',
            $char->{lv_job}, $jobPercent . '%',
            $weight, $pos, $Settings::NAME);

    } elsif ($net->getState() == Network::NOT_CONNECTED) {
        # Translation Comment: Interface Title
        $title = TF("%sNot connected - %s", $charName, $Settings::NAME);
    } else {
        # Translation Comment: Interface Title
        $title = TF("%sConnecting - %s", $charName, $Settings::NAME);
    }
    my %args = (return => $title);
    Plugins::callHook('mainLoop::setTitle',\%args);
    $interface->title($args{return});

    Misc::checkValidity("mainLoop_part3");
    Benchmark::end("mainLoop_part3") if DEBUG;
}

=pod
# Anonymous statistics reporting. This gives us insight about
# servers that our users bot on.
sub processStatisticsReporting {
    our %statisticsReporting;
    if (!$statisticsReporting{reported} && $config{master} && $config{username}) {
        if (!$statisticsReporting{http}) {
            use Utils qw(urlencode);
            import Utils::Whirlpool qw(whirlpool_hex);

            # Note that ABSOLUTELY NO SENSITIVE INFORMATION about the
            # user is sent. The username is filtered through an
            # irreversible hashing algorithm before it is sent to the
            # server. It is impossible to deduce the user's username
            # from the data sent to the server.
            #
            # If you're still not convinced about the security of this,
            # please read the following web pages for more details and explanation:
            #   http://www.openkore.com/statistics.php
            # -and-
            #   http://forums.openkore.com/viewtopic.php?t=28044
            my $url = "http://www.openkore.com/statistics.php";
            my $post = "server=" . urlencode($config{master});
            $post .= "&product=" . urlencode($Settings::NAME);
            $post .= "&version=" . urlencode($Settings::VERSION);
            $post .= "&uid=" . urlencode(whirlpool_hex($config{master} . $config{username} . $userSeed));
            $statisticsReporting{http} = new StdHttpReader($url, $post);
            debug "Posting anonymous usage statistics to $url\n", "statisticsReporting";
        }

        my $http = $statisticsReporting{http};
        if ($http->getStatus() == HttpReader::DONE) {
            $statisticsReporting{reported} = 1;
            delete $statisticsReporting{http};
            debug "Statistics posting completed.\n", "statisticsReporting";

        } elsif ($http->getStatus() == HttpReader::ERROR) {
            $statisticsReporting{reported} = 1;
            delete $statisticsReporting{http};
            debug "Statistics posting failed: " . $http->getError() . "\n", "statisticsReporting";
        }

    } elsif (!$statisticsReporting{infoPosted} && $masterServer && $masterServer->{ip}
          && $config{master} && $net && $net->getState() == Network::IN_GAME && $monstarttime) {
        if (!$statisticsReporting{http}) {
            my $url = "http://www.openkore.com/server-info.php";
            my $serverData = "";
            foreach my $key (sort keys %{$masterServer}) {
                $serverData .= "$key $masterServer->{$key}\n";
            }
            my $post = "server=" . urlencode($config{master}) . "&data=" . urlencode($serverData);
            $statisticsReporting{http} = new StdHttpReader($url, $post);
            debug "Posting server info to $url\n", "statisticsReporting";
        }

        my $http = $statisticsReporting{http};
        if ($http->getStatus() == HttpReader::DONE) {
            $statisticsReporting{infoPosted} = 1;
            delete $statisticsReporting{http};
            debug "Server info posting completed.\n", "statisticsReporting";

        } elsif ($http->getStatus() == HttpReader::ERROR) {
            $statisticsReporting{infoPosted} = 1;
            delete $statisticsReporting{http};
            debug "Server info posting failed: " . $http->getError() . "\n", "statisticsReporting";
        }
    }
}
=cut

sub parseInput {
    my $input = shift;
    my $printType;
    my ($hook, $msg);
    $printType = shift if ($net && $net->clientAlive);

    debug("Input: $input\n", "parseInput", 2);

    if ($printType) {
        my $hookOutput = sub {
            my ($type, $domain, $level, $globalVerbosity, $message, $user_data) = @_;
            $msg .= $message if ($type ne 'debug' && $level <= $globalVerbosity);
        };
        $hook = Log::addHook($hookOutput);
        $interface->writeOutput("console", "$input\n");
    }
    $XKore_dontRedirect = 1;

    Commands::run($input);

    if ($printType) {
        Log::delHook($hook);
        if (defined $msg && $net->getState() == Network::IN_GAME && $config{XKore_silent}) {
            $msg =~ s/\n*$//s;
            $msg =~ s/\n/\\n/g;
            sendMessage($messageSender, "k", $msg);
        }
    }
    $XKore_dontRedirect = 0;
}


#######################################
#######################################
# Parse RO Client Send Message
#######################################
#######################################

sub parseOutgoingClientMessage {
    use bytes;
    no encoding 'utf8';
    my ($msg) = @_;

    my $sendMsg = $msg;
    if (length($msg) >= 4 && $net->getState() >= 4 && length($msg) >= unpack("v1", substr($msg, 0, 2))) {
        Network::Receive->decrypt(\$msg, $msg);
    }
    my $switch = Network::MessageTokenizer::getMessageID($msg);
    if ($config{'debugPacket_ro_sent'} && !existsInList($config{'debugPacket_exclude'}, $switch) ||
        $config{'debugPacket_include_dumpMethod'} && existsInList($config{'debugPacket_include'}, $switch))
    {
        my $label = $packetDescriptions{Send}{$switch} ?
            " - $packetDescriptions{Send}{$switch}" : '';
       
        if ($config{'debugPacket_ro_sent'} == 1) {
            debug sprintf("Sent by RO client packet: %-4s    [%2d bytes]  %s\n", $switch, length($msg), $label), "parseMsg", 0;
        } elsif ($config{'debugPacket_ro_sent'} == 2) {
            visualDump($sendMsg, "<< Received packet (RO): $switch  $label");
        }
        if ($config{'debugPacket_include_dumpMethod'} == 1) {
            debug "Packet: $switch$label\n", "parseMsg", 0;
        } elsif ($config{'debugPacket_include_dumpMethod'} == 2) {
            visualDump($sendMsg, $switch . $label);
        } elsif ($config{'debugPacket_include_dumpMethod'} == 3) {
            dumpData($msg,1);
        } elsif ($config{'debugPacket_include_dumpMethod'} == 4) {
            open DUMP, ">> DUMP_lines.txt";
            print DUMP sprintf(unpack('H*', $msg) . "\n");
            close DUMP;
        }
    }

    Plugins::callHook('RO_sendMsg_pre', {switch => $switch, msg => $msg, realMsg => \$sendMsg});
    my $serverType = $masterServer->{serverType};

    # If the player tries to manually do something in the RO client, disable AI for a small period
    # of time using ai_clientSuspend().

# sendSync
    if ($masterServer->{syncID} && $switch eq sprintf('%04X', hex($masterServer->{syncID}))) {
        #syncSync support for XKore 1 mode
        $syncSync = substr($msg, $masterServer->{syncTickOffset}, 4);

# sendGameLogin
    } elsif ($switch eq "0065") {
        # Login to character server
        $incomingMessages->nextMessageMightBeAccountID();

# sendCharLogin
    } elsif ($switch eq "0066") {
        # Login character selected
        configModify("char", unpack("C*",substr($msg, 2, 1)));

# sendMapLogin
    } elsif (
        ($switch eq "0072" && ($serverType == 0 || $serverType == 21 || $serverType == 22)) ||
        ($switch eq "00F3" && $serverType == 18)
    ) {
        # Map login
        $incomingMessages->nextMessageMightBeAccountID();
        if ($serverType == 0 && $config{sex} ne "") {
            $sendMsg = substr($sendMsg, 0, 18) . pack("C",$config{'sex'});
        }

# sendSync
    } elsif ($switch eq "00A7") {
        if($masterServer && $masterServer->{paddedPackets}) {
            $syncSync = substr($msg, 8, 4);
        }

# sendSync
    } elsif ($switch eq "007E") {
        if ($masterServer && $masterServer->{paddedPackets}) {
            $syncSync = substr($msg, 4, 4);
        }

# sendMapLoaded
    } elsif ($switch eq "007D") {
        # Map loaded
        $packetParser->changeToInGameState();
        AI::clear("clientSuspend");
        $timeout{ai}{time} = time;
        if ($firstLoginMap) {
            undef $sentWelcomeMessage;
            undef $firstLoginMap;
        }
        $timeout{'welcomeText'}{'time'} = time;
        $ai_v{portalTrace_mapChanged} = time;
        # syncSync support for XKore 1 mode
        if($masterServer->{serverType} == 11) {
            $syncSync = substr($msg, 8, 4);
        } else {
            # formula: MapLoaded_len + Sync_len - 4 - Sync_packet_last_junk
            $syncSync = substr($msg, $masterServer->{mapLoadedTickOffset}, 4);
        }
        message T("Map loaded\n"), "connection";
       
        Plugins::callHook('map_loaded');

# sendMove
    } elsif ($switch eq "0085") {
        #if ($masterServer->{serverType} == 0 || $masterServer->{serverType} == 1 || $masterServer->{serverType} == 2) {
        #    #Move
        #    AI::clear("clientSuspend");
        #    makeCoordsDir(\%coords, substr($msg, 2, 3));
        #    ai_clientSuspend($switch, (distance($char->{'pos'}, \%coords) * $char->{walk_speed}) + 4);
        #}

# sendAction
    } elsif ($switch eq "0089") {
        if ($masterServer->{serverType} == 0) {
            # Attack
            if (!$config{'tankMode'} && !AI::inQueue("attack")) {
                AI::clear("clientSuspend");
                ai_clientSuspend($switch, 2, unpack("C*",substr($msg,6,1)), substr($msg,2,4));
            } else {
                undef $sendMsg;
            }
        }

# sendChat
    } elsif (($switch eq "008C" && ($masterServer->{serverType} == 0 || $masterServer->{serverType} == 1 || $masterServer->{serverType} == 2 || $masterServer->{serverType} == 6 || $masterServer->{serverType} == 7 || $masterServer->{serverType} == 10 || $masterServer->{serverType} == 11 || $masterServer->{serverType} == 21 || $masterServer->{serverType} == 22)) ||
        ($switch eq "00F3" && ($masterServer->{serverType} == 3 || $masterServer->{serverType} == 5 || $masterServer->{serverType} == 8 || $masterServer->{serverType} == 9 || $masterServer->{serverType} == 15)) ||
        ($switch eq "009F" && $masterServer->{serverType} == 4) ||
        ($switch eq "007E" && $masterServer->{serverType} == 12) ||
        ($switch eq "0190" && ($masterServer->{serverType} == 13 || $masterServer->{serverType} == 18)) ||
        ($switch eq "0085" && $masterServer->{serverType} == 14) ||    # Public chat

# sendPartyChat
        $switch eq "0108" ||    # Party chat

# sendGuildChat
        $switch eq "017E") {    # Guild chat

        my $length = unpack("v",substr($msg,2,2));
        my $message = substr($msg, 4, $length - 4);
        my ($chat) = $message =~ /^[\s\S]*? : ([\s\S]*)\000?/;
        $chat =~ s/^\s*//;

        stripLanguageCode(\$chat);

        my $prefix = quotemeta $config{'commandPrefix'};
        if ($chat =~ /^$prefix/) {
            $chat =~ s/^$prefix//;
            $chat =~ s/^\s*//;
            $chat =~ s/\s*$//;
            $chat =~ s/\000*$//;
            parseInput($chat, 1);
            undef $sendMsg;
        }

# sendPrivateMsg
    } elsif ($switch eq "0096") {
        # Private message
        my $length = unpack("v",substr($msg,2,2));
        my ($user) = substr($msg, 4, 24) =~ /([\s\S]*?)\000/;
        my $chat = substr($msg, 28, $length - 29);
        $chat =~ s/^\s*//;

        # Ensures: $user and $chat are String
        $user = I18N::bytesToString($user);
        $chat = I18N::bytesToString($chat);
        stripLanguageCode(\$chat);

        my $prefix = quotemeta $config{commandPrefix};
        if ($chat =~ /^$prefix/) {
            $chat =~ s/^$prefix//;
            $chat =~ s/^\s*//;
            $chat =~ s/\s*$//;
            parseInput($chat, 1);
            undef $sendMsg;
        } else {
            undef %lastpm;
            $lastpm{msg} = $chat;
            $lastpm{user} = $user;
            push @lastpm, {%lastpm};
        }

# sendLook
    } elsif (($switch eq "009B" && $masterServer->{serverType} == 0) ||
        ($switch eq "009B" && $masterServer->{serverType} == 1) ||
        ($switch eq "009B" && $masterServer->{serverType} == 2) ||
        ($switch eq "0085" && $masterServer->{serverType} == 3) ||
        ($switch eq "00F3" && $masterServer->{serverType} == 4) ||
        ($switch eq "0085" && $masterServer->{serverType} == 5) ||
        #($switch eq "009B" && $masterServer->{serverType} == 6) || serverType 6 uses what?
        ($switch eq "009B" && $masterServer->{serverType} == 7) ||
        ($switch eq "0072" && $masterServer->{serverType} == 13)) { # rRO
        # Look
       
        if ($char) {
            if ($masterServer->{serverType} == 0) {
                $char->{look}{head} = unpack("C", substr($msg, 2, 1));
                $char->{look}{body} = unpack("C", substr($msg, 4, 1));
            } elsif ($masterServer->{serverType} == 1 ||
                $masterServer->{serverType} == 2 ||
                $masterServer->{serverType} == 4 ||
                $masterServer->{serverType} == 7) {
                $char->{look}{head} = unpack("C", substr($msg, 6, 1));
                $char->{look}{body} = unpack("C", substr($msg, 14, 1));
            } elsif ($masterServer->{serverType} == 3) {
                $char->{look}{head} = unpack("C", substr($msg, 12, 1));
                $char->{look}{body} = unpack("C", substr($msg, 22, 1));
            } elsif ($masterServer->{serverType} == 5) {
                $char->{look}{head} = unpack("C", substr($msg, 8, 1));
                $char->{look}{body} = unpack("C", substr($msg, 16, 1));
            } elsif ($masterServer->{serverType} == 13) { # rRO
                $char->{look}{head} = unpack("C", substr($msg, 2, 1));
                $char->{look}{body} = unpack("C", substr($msg, 4, 1));
            }
        }

# sendTake
    } elsif ($switch eq "009F") {
        if ($masterServer->{serverType} == 0) {
            # Take
            AI::clear("clientSuspend");
            ai_clientSuspend($switch, 2, substr($msg,2,4));
        }

# sendRestart
    } elsif ($switch eq "00B2") {
        # Trying to exit (respawn)
        AI::clear("clientSuspend");
        ai_clientSuspend($switch, 10);

# sendQuit
    } elsif ($switch eq "018A") {
        # Trying to exit
        AI::clear("clientSuspend");
        ai_clientSuspend($switch, 10);

# sendAlignment (makes no sense since this is a GM sent packet?)
    } elsif ($switch eq "0149") {
        # Chat/skill mute
        undef $sendMsg;

# sendOpenShop
    } elsif ($switch eq "01B2") {
        # client started a shop manually
        $shopstarted = 1;

# sendCloseShop
    } elsif ($switch eq "012E") {
        # client stopped shop manually
        $shopstarted = 0;
    }

    if ($sendMsg ne "") {
        $messageSender->encryptMessageID(\$sendMsg);
        $net->serverSend($sendMsg);
    }

    # This should be changed to packets that haven't been parsed yet, in a similar manner
    # as parseMsg
    return "";
}


#######################################
#######################################
#Parse Message
#######################################
#######################################


##
# void parseIncomingMessage(Bytes msg)
# msg: The data to parse, as received from the socket.
#
# Parse network data sent by the RO server.
sub parseIncomingMessage {
    my ($msg) = @_;

    # Determine packet switch
    my $switch = Network::MessageTokenizer::getMessageID($msg);
    if (length($msg) >= 4 && substr($msg, 0, 4) ne $accountID && $net->getState() >= Network::CONNECTED_TO_CHAR_SERVER
     && $lastswitch ne $switch && length($msg) >= unpack("v1", substr($msg, 0, 2))) {
        # The decrypt below casued annoying unparsed errors (at least in serverType  2)
        if ($masterServer->{serverType} != 2) {
            Network::Receive->decrypt(\$msg, $msg);
            $switch = Network::MessageTokenizer::getMessageID($msg);
        }
    }

    # The user is running in X-Kore mode and wants to switch character or gameGuard type 2 after 0259 tag 02.
    # We're now expecting an accountID, unless the server has replicated packet 0259 (server-side bug).
    if ($net->getState() == 2.5 && (!$config{gameGuard} || ($switch ne '0259' && $config{gameGuard} eq "2"))) {
        if (length($msg) >= 4) {
            $net->setState(Network::CONNECTED_TO_MASTER_SERVER);
            $accountID = substr($msg, 0, 4);
            debug "Selecting character, new accountID: ".unpack("V", $accountID)."\n", "connection";
            $net->clientSend($accountID);
            return substr($msg, 4);
        } else {
            return $msg;
        }
    }

    $lastswitch = $switch;
    if ($config{'debugPacket_received'} && !existsInList($config{'debugPacket_exclude'}, $switch) ||
        $config{'debugPacket_include_dumpMethod'} && existsInList($config{'debugPacket_include'}, $switch))
    {
        my $label = $packetDescriptions{Recv}{$switch} ?
            "[$packetDescriptions{Recv}{$switch}]" : '';

        if ($config{'debugPacket_received'} == 1) {
            debug sprintf("Received packet: %-4s    [%2d bytes]  %s\n", $switch, length($msg), $label), "parseMsg", 0;
        } elsif ($config{'debugPacket_received'} == 2) {
            visualDump($msg, "<< Received packet (server): $switch  $label");
        }
        if ($config{'debugPacket_include_dumpMethod'} == 1) {
            debug "Packet: $switch$label\n", "parseMsg", 0;
        } elsif ($config{'debugPacket_include_dumpMethod'} == 2) {
            visualDump($msg, "$switch$label");
        } elsif ($config{'debugPacket_include_dumpMethod'} == 3) {
            dumpData($msg,1);
        } elsif ($config{'debugPacket_include_dumpMethod'} == 4) {
            open DUMP, ">> DUMP_lines.txt";
            print DUMP sprintf(unpack('H*', $msg) . "\n");
            close DUMP;
        }
    }

    Plugins::callHook('parseMsg/pre', {switch => $switch, msg => $msg, msg_size => length($msg)});

    if (!$packetParser->willMangle($switch)) {
        # If we're running in X-Kore mode, pass the message back to the RO client.
        $net->clientSend($msg);
    }

    $lastPacketTime = time;
    if ($packetParser &&
        (my $args = $packetParser->parse($msg))) {
        # Use the new object-oriented packet parser
        if ($config{debugPacket_received} == 3 &&
            existsInList($config{'debugPacket_include'}, $switch)) {
            my $switch = $args->{switch};
            my $packet = $packetParser->{packet_list}{$switch};
            my ($name, $packString, $varNames) = @{$packet};

            my @vars = ();
            for my $varName (@{$varNames}) {
                message "$varName = $args->{$varName}\n";
            }
        }

        if ($packetParser->willMangle($switch)) {
            my $ret = $packetParser->mangle($args);
            if (!$ret) {
                # Packet was not mangled
                $net->clientSend($args->{RAW_MSG});
            } elsif ($ret == 1) {
                # Packet was mangled
                $net->clientSend($packetParser->reconstruct($args));
            } else {
                # Packet was suppressed
            }
        }
    }
sub idro_decrypt {
   my $data = shift;
   my $data2 = "";
   my @tabel  = split / *\ + */,"52 95 47 57 F4 7B E2 DD CB 59 3D DC 19 37 09 22 D4 06 83 9C FA 62 EC 99 1C 9B 8E 89 B0 63 67 84 B3 18 A2 DA CA D7 64 4B C9 ED 1B 86 5B 9F 0A 12 31 B9 F9 6A E9 C4 C5 5A 05 68 EB 35 E1 5F B1 8F 96 2C 6C 45 E7 BE 2B 6D 70 EA 90 08 7A AF 7D FC 73 0E D8 2E CE F5 BF A8 B8 36 74 53 5D 26 51 DF FD 50 F7 65 7E B4 F1 D9 AC EF BD 43 6F 28 69 60 56 9A 01 B5 C2 8A C0 A9 F6 1D 32 78 14 48 AA 44 BC 6E 82 A0 24 85 79 00 25 C8 02 E5 23 4E 3C 58 A6 71 E3 2A B7 D0 5E 46 DE AB 66 4A E4 CC 15 87 41 A5 38 03 34 0D E6 D3 1A F2 2F 97 8C 72 29 54 61 77 4C C6 8D AE F0 CD 13 75 BB 04 3F 33 A4 4F 3E F8 B6 80 1F 0B 5C D2 88 E0 E8 42 B2 11 40 2D 3A 6B FE 9E 20 1E 10 7C 81 17 D6 A7 8B FF 91 92 A3 FB AD 93 98 27 EE C3 0C F3 49 9D DB D5 30 BA 21 C1 16 39 76 A1 7F CF 3B 94 55 C7 07 4D 0F D1";
   my @hex  = split / *\ + */,getHex($data);
   for (my $i=0;$i < @hex; $i++) {
      $data2 .= giveHex($tabel[hex($hex[$i])]);
   }
   return $data2;
}
}

return 1;

18 comments:

  1. alo mas,, mau tanya donk..
    koq pass saya jalanin erornya bilang
    "Paket Tokenizer: Unknown Switch: C953" kenapa ya???
    tolong penyelesaiannya>....

    ReplyDelete
  2. itu berarti key di function.pl ato biasa disebut ma orang2 nomor togel minta di ganti karena dah expire.

    ne contoh nomor togel dan expire datenya

    Expired 23 Juli 2010, ± jam 12:18

    D3 E8 13 B3 D8 CE 12 AC 69 9C 7E DF EF 94 92 89 0A CA 33 96 5F 74 47 C9 7A 9B 84 EA 44 F0 10 4B 8A 0D 31 03 63 4C 32 9F 01 CC DD 42 2B C2 65 AA C5 FF F9 72 16 AB 20 9E 55 F8 98 C0 EB 08 51 29 64 79 ED 27 E0 FA 4A 30 F2 B0 40 6C B4 A7 A5 BA D9 39 85 1C F4 8E E3 70 26 B2 99 DC 0F FC F5 E9 77 25 35 90 C8 45 68 3D E5 71 8B CD 34 6D A8 6E F1 B6 56 EC 88 5B 86 D6 C1 7B BD 7D BF C6 8C 93 A9 DA 06 81 78 61 23 48 75 F3 46 58 C3 50 7F E1 9D 8F CB D2 3B 41 EE 52 5C 67 E6 73 22 5D FB 4E E2 04 17 49 28 D4 11 2A 05 B1 E7 02 C4 A0 15 4D AF 91 2D 82 57 24 36 0B 9A DE B5 00 53 21 C7 A3 95 FD 87 1D A2 CF 76 AE F7 0E 6B 6A 7C 8D D1 3E A6 BB 97 A4 4F 19 59 2F 1A 83 B7 3F FE 43 2C D0 0C 2E B8 37 E4 07 18 60 DB 80 14 5A 3A BE BC 1F 1E 1B 38 62 A1 D7 B9 D5 66 54 09 F6 5E 6F 3C AD

    t4 nomor togelnya yg perlu diganti itu ada diatas komenmu. tiap jam nomor togel kudu ganti bila botmu DC

    ReplyDelete
  3. kakak..ini punya saya botnya kok masih blom bisa ya?bisa tolong bantu gak?

    ReplyDelete
  4. blm bisa gmn? g bisa masuk ato gmn?

    ReplyDelete
  5. udah tapi ada error
    the error messages is:
    "%options" is not exported by the Setting module
    can't continue after import errors at src/function.pl line 21
    BEGIN Failed--compilation aborted at src/function.pl line 21
    compilation failed in require at openkore.pl line 51

    ReplyDelete
  6. coba download function.pl ini trus km ganti punya km yg ada di folder src
    http://www.4shared.com/file/mt9zyfkr/functions.html

    ReplyDelete
  7. trus ntar tinggal ganti togelnya yg blm expire

    ReplyDelete
  8. masih...

    OpenKore version 2.0.7 (Release Candidate)
    SVN revision: 6803
    No loaded plugins.

    Error message:
    "%options" is not exported by the Settings module
    Can't continue after import errors at src/functions.pl line 21
    BEGIN failed--compilation aborted at src/functions.pl line 21.
    Compilation failed in require at openkore.pl line 51.

    Stack trace:
    "%options" is not exported by the Settings module
    Can't continue after import errors at src/functions.pl line 21
    BEGIN failed--compilation aborted at src/functions.pl line 21.
    Compilation failed in require at openkore.pl line 51.
    at perlapp.pl line 1431
    PerlApp::my_require('functions.pl') called at openkore.pl line 51
    main::__start() called at start.pl line 119

    Died at this line:
    require Utils::Win32 if ($^O eq 'MSWin32');
    * require 'functions.pl';

    ReplyDelete
  9. udah bisa...
    tapi masih tokenizer
    padahal udah pake nomer togel yg sekarang tuh...

    ReplyDelete
  10. cara masangnya yg bener harus didalam tanda petik >>> "B3 C3 D5 52 29 CB 41 BE C0 AB D1 99 E0 98 10 D4 F6 24 DC C2 F3 F2 E7 96 E6 7A EB 5B 16 2E 81 38 F4 79 8A FC 2B 8C 6B AC 03 73 ED E2 54 53 DE C9 BC 62 1D BA AF 1C C1 E9 A5 8F 9B 66 5C CF B6 B1 A4 FA A0 B9 94 A1 6F 65 D8 B4 AE CD 7B BB B8 5A F5 CC CE D2 6D 5D 69 74 19 02 92 32 3F 0B EC 51 9E 88 3E 57 6E D0 9C A8 3B 45 1A 77 3C 95 C6 20 D7 06 DD AA 0F 84 15 87 31 C8 FD F9 C4 60 11 7C 55 09 2D 3D 35 1E 14 F0 8E A3 F1 9D 49 CA A7 B2 DA BD 85 DB 80 63 E5 58 9A E4 8B E3 46 00 7F 71 40 C7 89 AD 2F 7D 43 4F B7 0E 82 D9 39 6A 67 8D B5 47 1F FB 44 28 36 A2 4A 0C B0 70 59 4D EE 4E 91 08 9F FF 50 FE 07 D6 5F 1B 30 3A EA 5E 13 0A 78 34 23 E1 D3 48 37 86 7E 93 18 17 68 21 2C A9 76 C5 83 90 05 61 25 01 EF 42 26 33 BF 4B 04 27 2A 56 0D F7 F8 75 64 22 A6 E8 4C DF 72 97 12 6C"

    ReplyDelete
  11. kl gini gmn kk??

    Melakukan koneksi ke Account Server...
    Koneksi terhubung (202.43.167.67:6900)... Telah connect
    Login Keamanan...
    Potongan Packet: Switch tidak diketahui: A89B
    Terputus dari Account Server, Berusaha untuk terhubung ulang...
    Mengakhiri koneksi (202.43.167.67:6900)...Telah disconnect

    ReplyDelete
  12. radith: itu kudu rubah key di function plnya, key itu tiap jam berubah2

    ReplyDelete
  13. masi error ne...mnt table yg terbaru donk...

    ReplyDelete
  14. kk....kl pake yg 2.0.6 jg ckp ubah functionnya???
    trus di mn dpt table terbaru???
    aku da coba punya kk n kejadiannya keq
    OpenKore version 2.0.7 (Release Candidate)
    SVN revision: 6803
    No loaded plugins.

    Error message:
    "%options" is not exported by the Settings module
    Can't continue after import errors at src/functions.pl line 21
    BEGIN failed--compilation aborted at src/functions.pl line 21.
    Compilation failed in require at openkore.pl line 51.

    Stack trace:
    "%options" is not exported by the Settings module
    Can't continue after import errors at src/functions.pl line 21
    BEGIN failed--compilation aborted at src/functions.pl line 21.
    Compilation failed in require at openkore.pl line 51.
    at perlapp.pl line 1431
    PerlApp::my_require('functions.pl') called at openkore.pl line 51
    main::__start() called at start.pl line 119

    Died at this line:
    require Utils::Win32 if ($^O eq 'MSWin32');
    * require 'functions.pl';

    ne caranya cmn y kk???

    ReplyDelete
  15. kk...punyaku keluar
    unknown error ne napa y kk??
    pdhl aku da ikutin ganti function nya n da ganti nmr togelnya

    ReplyDelete
  16. om cara bikin togel gmana? kasih tahu donk

    ReplyDelete
  17. kk ko bot aq unouck own eror ya,
    pas abis maintanance Skil2 Scrocerer dan lain2,
    bingung
    aaa

    ReplyDelete
  18. klo gini gmn,,?

    udah selese DL openkore,, dah ngejalanin,, trus servernya ketik "4" yaak (katanya seh gabungan...
    pas masukin username ada tulisannya "connected" trus dibawahnya lagi "not connected" gto klo gak salah....
    itu kenapa yaaakk...

    ReplyDelete

Meningkatkan Subscriber Channel YouTube Kalian

Free YouTube Subscribers

Post Populer