playerRecorder plugin

Other plugins for extending OpenKore's functionality. This forum is only for posting new plugins and commenting on existing plugins. For support, use the Support forum.

Moderator: Moderators

Message
Author
fco2783
Plain Yogurt
Plain Yogurt
Posts: 95
Joined: 05 Apr 2008, 05:15
Noob?: Yes
Location: in place where you cant go
Contact:

playerRecorder plugin

#1 Post by fco2783 »

Code: Select all

######################################################
# This plugin is licensed under the GNU GPL          #
# Copyright 2005 by isieo                            #
# contact : - isieo <AT> *NOSPAM* G*MAIL <DOT> COM   #
# -------------------------------------------------- #
# -------------------------------------------------- #
# playerrecorder.pl                                  #
# Records Player's name together with AIDs           #
# Usefull for players to findout other players' other#
# characters...                                      #
#                                                    #
######################################################

package playerRecord;
use strict;
use Plugins;
use Log qw(message);
use Globals;
use Settings;

Plugins::register("prec", "playerRecord", \&on_unload, \&on_reload);
my $hooks = Plugins::addHooks(
        ['charNameUpdate', \&write_player],
);
my $datadir = $Plugins::current_plugin_folder;

sub on_unload {
        # This plugin is about to be unloaded; remove hooks
        Plugins::delHook("charNameUpdate", $hooks);
}

sub on_reload {
}

sub write_player {
        my $hookname = shift;
        my $args = shift;
        my $targetId = unpack("V1",$args->{ID});
        my $targetName = $args->{name};
        my $file = "$datadir/players.txt";

        my ($uId, $name);
        my $exist=0;
        my $line;

        if ($Settings::VERSION cmp '1.9.1' >= 0) {
                open FILE, "<:utf8", $file;
        } else {
                open FILE, "< $file";
        }

        foreach (<FILE>){
                next if (/^#/);
                s/[\r\n]//g;
                s/\s+$//g;
                $line = $_;
           ($uId, $name ) = $line =~ /^(\d+) (.*)$/;
           if ($uId eq $targetId && $name eq $targetName){
                $exist=1;
           }
        }
        close FILE;

        if (!$exist) {
            message $name.$targetName."\n";
            if ($Settings::VERSION cmp '1.9.1' >= 0) {
                open FILE, ">>:utf8", $file;
            } else {
                open FILE, ">> $file";
            }
            print FILE "$targetId $targetName\n" if ($targetName) ;
            close FILE;
        }
}

1; 
Example
2011675 Mercy
2011737 Forgotten
2012222 TurnUndead
2013374 Guillaume
2013374 Kruseus
2013808 Intrepid
2014260 BotForWhat
2014555 Kara
2015627 Reki no Cappuccino
2015677 CaSeYII
2016421 ikaru valkryie
2016543 NeverSummer
2016623 Locomotion
2016623 MingMing
2016626 CastOut
2016068 Divine Ruination
2016708 star knight
2015670 Vestige
2013971 Arancar
2011436 Merchant XY
110993538 Vanilmirth
2011423 M S N
2016559 Teep
2016433 EnMa
2014830 Lonewolf
2014823 hyadee
2016729 LeShank
2016595 Preet
2015623 Scarlet
2016435 Adamantine
2013656 Beemo
2014366 IKillYou
2013708 Ayami Nanashi
2016212 AbyssGirl
2011590 Raii Slave
2016664 Bayokes
you gonna have players.txt at plugins folder

Motivus
Developers
Developers
Posts: 157
Joined: 04 Apr 2008, 13:33
Noob?: Yes

Re: playerRecorder plugin

#2 Post by Motivus »

Slightly updated, was still too lazy to make it log to logs folder.

It now logs in this format:

players_playerName.txt
[Mon Apr 14 12:17:50 2008] geffen - 1520777 Guiltyon
[Mon Apr 14 12:18:09 2008] geffen - 1498395 jewell*
[Mon Apr 14 12:18:09 2008] geffen - 919658 .Lost.
[Mon Apr 14 12:19:01 2008] mjolnir_07 - 3329062 jsdhfsdfhksd

Code: Select all

######################################################
# This plugin is licensed under the GNU GPL          #
# Copyright 2005 by isieo                            #
# contact : - isieo <AT> *NOSPAM* G*MAIL <DOT> COM   #
# -------------------------------------------------- #
# -------------------------------------------------- #
# playerrecorder.pl                                  #
# Records Player's name together with AIDs           #
# Usefull for players to findout other players' other#
# characters...                                      #
#                                                    #
######################################################

package playerRecord;
use strict;
use Plugins;
use Log qw(message);
use Globals;
use Settings;
use Actor;
use Actor::You;

Plugins::register("prec", "playerRecord", \&on_unload, \&on_reload);
my $hooks = Plugins::addHooks(
        ['charNameUpdate', \&write_player],
);
my $datadir = $Plugins::current_plugin_folder;

sub on_unload {
        # This plugin is about to be unloaded; remove hooks
        Plugins::delHook("charNameUpdate", $hooks);
}

sub on_reload {
}

sub write_player {
	my $hookname = shift;
	my $args = shift;
	my $targetId = unpack("V1",$args->{ID});
	my $targetName = $args->{name};
	my $aYou = Actor::get($accountID);
	my $selfName = $aYou->{name};
	my $file = "$datadir/players_$selfName.txt";

	my ($uId, $name);
	my $exist=0;
	my $line;

	message $name.$targetName."\n";
	if ($Settings::VERSION cmp '1.9.1' >= 0) {
		open FILE, ">>:utf8", $file;
 	} else {
		open FILE, ">> $file";
	}
	my $time=localtime time;
	print FILE "[$time] $field{name} - $targetId $targetName\n";
	close FILE;
}

1;
Oh no.

sli
Perl Monk
Perl Monk
Posts: 810
Joined: 04 Apr 2008, 17:26
Noob?: No

Re: playerRecorder plugin

#3 Post by sli »

Writes to the log dir, now. Also fixed a possible bug and cleaned stuff up a bit and made it speak a little more standardized of a dialect (so to speak). Log file format was changed slightly as well to the following:

Code: Select all

[Thu Aug  7 22:54:10 2008] payon	2017100 Meep
[Thu Aug  7 22:54:11 2008] payon	2017731 HolyRinny
[Thu Aug  7 22:55:18 2008] payon	2011705 Shermie
[Thu Aug  7 22:56:19 2008] payon	2017746 Along79
[Thu Aug  7 22:58:08 2008] pay_dun00	2013158 LokisTears
I thought tabs would make it more readable. And here's the new code:

Code: Select all

########################################################
# This plugin is licensed under the GNU GPL            #
# Copyright 2005 by isieo                              #
# contact : - isieo <AT> *NOSPAM* G*MAIL <DOT> COM     #
#                                                      #
# Modified by sli (signedlongint@gmail.com)            #
# ---------------------------------------------------- #
# ---------------------------------------------------- #
# playerrecorder.pl                                    #
# Records Player's name together with AIDs             #
# Usefull for players to find out other players' other #
# characters...                                        #
########################################################

package playerRecord;

use strict;
use Plugins;
use Log qw(message);
use Globals;
use Settings;
use Actor;

Plugins::register("prec", "playerRecord", \&on_unload, \&on_reload);
my $hook = Plugins::addHook('charNameUpdate', \&write_player, undef);

sub on_unload {
	Plugins::delHook("charNameUpdate", $hook);
}

sub write_player {
	my $hookname = shift;
	my $args = shift;
	my $targetId = unpack("V1",$args->{ID});
	my $targetName = $args->{name};
	my $aYou = Actor::get($accountID);
	my $selfName = $char->name();
	my $file = "$Settings::logs_folder/players_$selfName.txt";

	my ($uId, $name);
	my $exist=0;
	my $line;

	message "Player Exists: $targetName ($targetId)\n";

	open FILE, ">>:utf8", $file;
	my $time=localtime time;
	print FILE "[$time] $field{name}\t$targetId $targetName\n";
	close FILE;
}

1;
cs : ee : realist

Bibian
Perl Monk
Perl Monk
Posts: 416
Joined: 04 Apr 2008, 03:08

Re: playerRecorder plugin

#4 Post by Bibian »

my recorder uses MySQL o.o
also saves a lot more information, like class, level, coords, timestamp seen, guild and party

Motivus
Developers
Developers
Posts: 157
Joined: 04 Apr 2008, 13:33
Noob?: Yes

Re: playerRecorder plugin

#5 Post by Motivus »

Bibian wrote:my recorder uses MySQL o.o
also saves a lot more information, like class, level, coords, timestamp seen, guild and party
this is designed for knowing who your bot saw and where

it really helps with avoiding bans

a more advanced recorder
Oh no.

sli
Perl Monk
Perl Monk
Posts: 810
Joined: 04 Apr 2008, 17:26
Noob?: No

Re: playerRecorder plugin

#6 Post by sli »

Bibian wrote:my recorder uses MySQL o.o
also saves a lot more information, like class, level, coords, timestamp seen, guild and party
You do know there are much, much better, faster and more reliable alternatives to MySQL that were made for things like this, don't you? Just thought I'd ask.
cs : ee : realist

i3h4m
Noob
Noob
Posts: 11
Joined: 01 Jun 2008, 23:50
Noob?: No
Location: Malaysia, negara yang berdaulat.

Re: playerRecorder plugin

#7 Post by i3h4m »

wat more can i say
;) nice
"If I giv u a bot I'll feed u a day, but if I teach u to bot I'll feed u for life time" --wise i3h4m
"R you stupid or playin' stupid" - extracted from Forrest Gump film
Download Complete Set Up BOT from me

Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: playerRecorder plugin

#8 Post by Technology »

playerRecorder plugin is now in SVN:
https://openkore.svn.sourceforge.net/sv ... rRecorder/

however, the changes above are not made yet.

and there is a version around somewhere that stores more information (guild, party, ...)
branch off or make it trunk?
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!

kali
OpenKore Monk
OpenKore Monk
Posts: 457
Joined: 04 Apr 2008, 10:10

Re: playerRecorder plugin

#9 Post by kali »

Trunk for enhanced features
Branch for unstable features or those that are major deviations from the trunk (e.g. one that will make data non-backwards compatible)

After all, the reason why we use a versioning system (SVN) is to keep track of changes.

I have also added sli's change above.
Got your topic trashed by a mod?

Trashing topics is one click, and moving a topic to its proper forum is a lot harder. You expend the least effort in deciding where to post, mods expend the least effort by trashing.

Have a nice day.

isieo
Kami-Sama Desu~
Kami-Sama Desu~
Posts: 195
Joined: 04 Apr 2008, 09:24
Noob?: Yes
Location: 31th Dimension
Contact:

Re: playerRecorder plugin

#10 Post by isieo »

wow my ancient plugin back in the days...

Post Reply