Help on updating playerrecorder.pl

For everything NOT server specific support. Do NOT ask for connectivity help here!.

Moderator: Moderators

Boxxy
Noob
Noob
Posts: 1
Joined: 29 Aug 2012, 05:56
Noob?: Yes

Help on updating playerrecorder.pl

#1 Post by Boxxy »

I'm trying to use this code on a recent Openkore build, without success.

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 Utils qw(binAdd existsInList getFormattedDate);

Plugins::register("prec", "playerRecord", \&on_unload, \&on_reload);
my $hooks = Plugins::addHooks(
['charNameUpdate', \&write_player],
);
my $datadir = $Settings::logs_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 $targetG = $args->{guild}{name};
my $targetJob = $jobs_lut{$args->{jobID}};
my $targetLvl = $args->{lv};
my $targetSex = $sex_lut{$args->{sex}};
my $targetLocation = $field{name};
my $targetTime = localtime time;
my $file = "$datadir/players.csv";
my ($time, $uId, $name, $guild, $job, $lvl, $sex, $location);
my $exist=0;
my $line;


if ($targetG eq "") {
$targetG = "None";
}

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 = $_;
($time, $uId, $name, $guild, $job, $lvl, $sex, $location ) = $line =~ /^(\[\w{3} \w{3} \d{2} \d{2}:\d{2}:\d{2} \d{4}\]) (\d+) (\w+) (\w+ \w+?) (\w+ \w+?) (\d+) (\w+) (\w+)$/;
if ($uId eq $targetId && $name eq $targetName){
$exist=1;
}
}
close FILE;

if (!$exist) {
               if ($Settings::VERSION cmp '1.9.1' >= 0) {
                                 open FILE, ">>:utf8", $file;
                              } else {
                                 open FILE, ">> $file";
                              }
                  print FILE "[$targetTime];;;$targetId;$targetName;;$targetG;;;$targetJob;$targetLvl;$targetSex;$targetLocation\n" if ($targetName) ;
                  
                  close FILE;
         }
}
1;
I'm getting a syntax error on %field, line 45. I'm not a experctise on scripting, so I tried to change $field for $.map. Again, without success, as the bot just creates an empty excel file.

Can anybody help me getting this useful plugin working? As a noob, I'm out of ideas :?