near player info

Moderator: Moderators

Message
Author
ezza
Developers
Developers
Posts: 109
Joined: 04 Apr 2008, 09:50

Re: near player info

#11 Post by ezza »

@RBiN - Your idea is brilliant (only a few of us can see the true potential). Hardly see macro users willing to post an eval issues even if it already solved us many kind of headache problems before. Maybe some of us are really selfish or they are afraid if the codes not nice and etc. Infact, we should encourage ppl to use this eval... practice alot will give us an awsome eval codes.


p.s: Keep-up the good work ^^ ... I'm watching :lol:

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

Re: near player info

#12 Post by fco2783 »

im totally noob at eval...

could you explain this macro...

Code: Select all

automacro test {
player /(.*)/, 5
exclusive 1
call {
$i = $.lastMatch1
do eval my $_player = Match::player($_i); foreach my $_player (@{$::playersList->getItems()}) { $::Macro::Data::varStack{name} = $_player->{'name'}; $::Macro::Data::varStack{job} = $_player->job; $::Macro::Data::varStack{lvl} = $_player->{'lv'}; $::Macro::Data::varStack{sex} = $::sex_lut{$_player->{'sex'}}; $::Macro::Data::varStack{dist} = sprintf("%.1f", distance($::char->{pos_to}, $_player->{pos_to})); $::Macro::Data::varStack{guild} = $_player->{guild} ? $_player->{guild}{name} : ''; $::Macro::Data::varStack{id} = $_player->{'binID'}; }
log name=$name job=$job lvl=$lvl sex=$sex dist=$dist guild=$guild id=$id
if ($dist < 4) goto next
:next
do something with $name or $id
stop
}
}
the way i understand it... this should post on the console something like this "name=BotPeople job=Novice and blah blah blah"

but seem cant make it work... is this only work if you are in the same guild or something???

last time ezza and help_us said it needed a hook to make it work, http://forums.openkore.com/viewtopic.php?f=32&t=555

ezza
Developers
Developers
Posts: 109
Joined: 04 Apr 2008, 09:50

Re: near player info

#13 Post by ezza »

@fco2783 - you got me wrong. The comment was not for this player syntax... new version macro can use regexp on player's name. In this case, the regexp use a back reference last match to any names (.*) with the distance lower than 5. So, it will trigger to any players name in that range.

If you wanna try playing this eval.. use this little modifications to the original post

Code: Select all

automacro test {
   player /(.*)/, 5
   timeout 5
   call {
      $n = $.lastMatch1
      log $n
      do eval foreach my $_player (@{$::playersList->getItems()}) { next if $_player->{'name'} eq "";if ($_player->{'name'} eq "$n") {$::Macro::Data::varStack{name} = $_player->{'name'}; $::Macro::Data::varStack{job} = $_player->job; $::Macro::Data::varStack{lvl} = $_player->{'lv'}; $::Macro::Data::varStack{sex} = $::sex_lut{$_player->{'sex'}}; $::Macro::Data::varStack{dist} = sprintf("%.1f", distance($::char->{pos_to}, $_player->{pos_to})); $::Macro::Data::varStack{guild} = $_player->{guild} ? $_player->{guild}{name} : ''; $::Macro::Data::varStack{id} = $_player->{'binID'}; }}
      if ($name = Unknown || $name = "") stop
      log name=$name job=$job lvl=$lvl sex=$sex dist=$dist guild=$guild id=$id
      log do something with Name $name or ID $id
   }
}

RBiN
Noob
Noob
Posts: 12
Joined: 07 Apr 2008, 03:31

Re: near player info

#14 Post by RBiN »

its still buggy though, if you put a specific distance it doesnt trigger when there's 2 or more player on screen. ill find some other alternative to that one, try to work it out this weekend coz its the only day im free. :D anyway i made some minor changes, also thx to ezza for the modification.

Code: Select all

automacro test {
   player /(.*)/, 5
   timeout 5
   call {
      $n = $.lastMatch1
      log $n
      do eval foreach my $_player (@{$::playersList->getItems()}) { next if $_player->{'name'} eq ""; next if $_player->{actorType} ne "Player"; if ($_player->{'name'} eq "$n") {$::Macro::Data::varStack{name} = $_player->{'name'}; $::Macro::Data::varStack{job} = $_player->job; $::Macro::Data::varStack{lvl} = $_player->{'lv'}; $::Macro::Data::varStack{sex} = $::sex_lut{$_player->{'sex'}}; $::Macro::Data::varStack{dist} = sprintf("%.1f", distance($::char->{pos_to}, $_player->{pos_to})); $::Macro::Data::varStack{guild} = $_player->{guild} ? $_player->{guild}{name} : ''; $::Macro::Data::varStack{id} = $_player->{'binID'}; }}
      if ($name = Unknown || $name = "") stop
      log name=$name job=$job lvl=$lvl sex=$sex dist=$dist guild=$guild id=$id
      log do something with Name $name or ID $id
   }
}

ezza
Developers
Developers
Posts: 109
Joined: 04 Apr 2008, 09:50

Re: near player info

#15 Post by ezza »

Well, actually I dont agree with (.*) at 1st, becoz it spam the automacro everytime there is a player around us. The modification code above just to make the eval match the $n with no specific usage other than get used to the perl eval practicing.


p.s: Triggering the automacro is more headache than coding the macro itself ^^.

[edit] Becarefull on the actor type. Unknown #ID player also in the same type of actor Player when it still not in the mem cache.. so dont worry.. the player syntax in automacro just trigger only to players.. not the anything else.

RBiN
Noob
Noob
Posts: 12
Joined: 07 Apr 2008, 03:31

Re: near player info

#16 Post by RBiN »

ezza wrote:[edit] Becarefull on the actor type. Unknown #ID player also in the same type of actor Player when it still not in the mem cache.. so dont worry.. the player syntax in automacro just trigger only to players.. not the anything else.
it also triggers when a homunculus is in sight thats why i put next if $_player->{actorType} ne "Player"

actually its more difficult to write an eval perl in macro than a normal perl. :p

ezza
Developers
Developers
Posts: 109
Joined: 04 Apr 2008, 09:50

Re: near player info

#17 Post by ezza »

Code: Select all

automacro test {
   player /(.*)/, 5
   timeout 5
   call {
      $n = $.lastMatch1
      log $n
      do eval foreach my Actor::Player $_player (@{$playersList->getItems()}) { next if $_player->{'name'} eq "";if ($_player->{'name'} eq "$n") {$::Macro::Data::varStack{name} = $_player->{'name'}; $::Macro::Data::varStack{job} = $_player->job; $::Macro::Data::varStack{lvl} = $_player->{'lv'}; $::Macro::Data::varStack{sex} = $::sex_lut{$_player->{'sex'}}; $::Macro::Data::varStack{dist} = sprintf("%.1f", distance($::char->{pos_to}, $_player->{pos_to})); $::Macro::Data::varStack{guild} = $_player->{guild} ? $_player->{guild}{name} : ''; $::Macro::Data::varStack{id} = $_player->{'binID'}; }}
      if ($name = Unknown || $name = "") stop
      log name=$name job=$job lvl=$lvl sex=$sex dist=$dist guild=$guild id=$id
      log do something with Name $name or ID $id
   }
}
How about we narrow the Actor type like this? Also remember, this eval only trying to match the player name $n... not the whole player list distance < 5.


Discussion: 1st, player syntax in automacro only match players name ($n)... not the homun. Then, we match the name ($n) to the existing players name in the playersList (did homun really exist in this playersList?). So, its the players name that we try to match here... not the homun, unless got some stupid ppl with the same name to the homun :lol:

p.s: So, what say you?

RBiN
Noob
Noob
Posts: 12
Joined: 07 Apr 2008, 03:31

Re: near player info

#18 Post by RBiN »

RBiN wrote:Discussion: 1st, player syntax in automacro only match players name ($n)... not the homun. Then, we match the name ($n) to the existing players name in the playersList (did homun really exist in this playersList?). So, its the players name that we try to match here... not the homun, unless got some stupid ppl with the same name to the homun :lol:

p.s: So, what say you?
it actually triggers the macro regardless if its a homunculus. i tried adding this part

Code: Select all

$::Macro::Data::varStack{type} = $_player->{actorType}
and it gave me this log
[macro][log] name=Big Bird type=Homunculus job=Filir

i also check it personally and it was really a homunculus. try to check it for urself.

ezza
Developers
Developers
Posts: 109
Joined: 04 Apr 2008, 09:50

Re: near player info

#19 Post by ezza »

Sry @RBiN, I havent see any homun type in my server... I tested this with my other ID. So, everytime it trigger .. i just can see my ID only ^^


Okay... seems like this is a challange to us since the player syntax also trigger on homun :shock: ... why dont you try this 1st, see if there is any bug or error

Code: Select all

automacro test {
   player /^.*/, 5
   timeout 10
   call {
       do eval my %_playersInfo;my @playersInformation;for (my $_i = 0; $_i < @playersID; $_i++) {next if ($::playersID[$_i] eq "");$_player = $::players{$::playersID[$_i]};$_playersInfo{$_i}{name} = ($_player->{'name'})?$_player->{'name'}:"Unknown";$_playersInfo{$_i}{job} = $::jobs_lut{$_player->{jobID}};$_playersInfo{$_i}{lvl} = $_player->{'lv'};$_playersInfo{$_i}{sex} = $::sex_lut{$_player->{'sex'}};$_playersInfo{$_i}{dist} = sprintf("%.1f", distance($::char->{pos_to}, $_player->{pos_to}));$_playersInfo{$_i}{guild} = $_player->{guild} ? $_player->{guild}{name} : 'None';$_playersInfo{$_i}{id} = $_player->{'binID'};$_playersInfo{$_i}{loc} = "$_player->{pos_to}{x}" . " $_player->{pos_to}{y}";push @playersInformation, \%_playersInfo;};$_i = 0;$_n = 1;message "-------------- Player List -----------------\nNo. Name (ID) Guild Sex Lvl Job Dist Loc\n--------------------------------------------\n";foreach (@playersInformation) {if ($_->{$_i}{dist} > 5) {$_i++;next} next if ($_->{$_i}{name} eq "");message "$_n\. $_->{$_i}{'name'} ($_->{$_i}{id}) [$_->{$_i}{'guild'}] $_->{$_i}{'sex'} $_->{$_i}{'lvl'} $_->{$_i}{job} Dist=$_->{$_i}{'dist'} ($_->{$_i}{loc})\n", "macro"; $_i++;$_n++}
   }
}

p.s: I hate homun ^^


[edit] Btw, I cant trigger the player /.*/ regexp. Is it really a regexp?

RBiN
Noob
Noob
Posts: 12
Joined: 07 Apr 2008, 03:31

Re: near player info

#20 Post by RBiN »

good work in making those player store in a hash, however it only prints player within the given distance but how can we determine which one to buffs? i think we dont have something like this

do something on $_->{$_i}{id} or $_->{$_i}{name}

so we will write it this way?
$id = @eval($_->{$_i}{id}
$name = @eval($_->{$_i}{name}
...and also the other element

i think thats a lot of work. i prefer the old macro we just need some other way to trigger it.

ps. nice idea though ^^

Post Reply