Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # - Plugin listAllPlayers by KeplerBR (thanks to kLabMouse)
- #
- # Topic about the plugin (recommended to read)
- # * http://forums.openkore.com/viewtopic.php?f=34&t=18879 (in English)
- # * http://forum.xkore.com.br/index.php?/topic/64-plugin-listallplayers/ (in Brazilian Portuguese)
- package listAllPlayers;
- use strict;
- use warnings;
- use Plugins;
- use Log qw(message warning);
- use Settings;
- use Globals;
- use Utils;
- # Register Plugin and Hooks
- Plugins::register("listAllPlayers", "Generate list of all server chars", \&on_unload);
- my $hooks = Plugins::addHooks(
- ['packet/character_name', \&list_player_id_name],
- ['packet/received_sync', \&send_packet],
- );
- # On Unload code
- sub on_unload {
- Plugins::delHook("packet/character_name", $hooks);
- Plugins::delHook("AI_pre/received_sync", $hooks);
- }
- # Global variables
- my $idLoop = 150000; # In which ID will start the loop
- my $limit = 20; # Limit how often will send the package by sync
- # Prepare and send packet asking the nick of character
- sub send_packet {
- warning "Starting sending the packet \n";
- for (my $i = 0; $i < $limit; $i++) {
- $idLoop++;
- # Send packet
- my $idSend = $idLoop;
- $idSend = pack("V", $idSend);
- $idSend = getHex($idSend);
- message "Send ID $idSend ($idLoop)\n";
- $messageSender->sendRaw("68 03 $idSend");
- }
- warning "Completing the packet sent \n";
- }
- # Add the result to text file
- sub list_player_id_name {
- my $hookname = shift;
- my $args = shift;
- # Defining and organizing variables
- my $id = unpack("V1", $args->{ID});
- my $idHex = getHex($args->{ID});
- my $nick = $args->{name};
- # Write
- warning "New player on file: $id - $nick \n";
- open FILE_TXT,">>". 'listAllPlayers.txt' or die "Cannot create file listAllPlayers.txt: $!";
- print FILE_TXT "* $idHex - $id - $nick\n";
- close FILE_TXT;
- }
- 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement