near player info

Moderator: Moderators

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

near player info

#1 Post by RBiN »

given below is the main concept of the macro, you can modified it on whatever purpose you desire.

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'}; }}
      log name=$name job=$job lvl=$lvl sex=$sex dist=$dist guild=$guild id=$id
      #do something with Name $name or ID $id
   }
}
or you can use it with ezza's multiple if statement.

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
   }
}
dont just copy and paste it to your macros if you know what your doing and if theres anything wrong feel free to post. ;)
Last edited by RBiN on 16 Jun 2008, 07:16, edited 3 times in total.

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

Re: near player info

#2 Post by ezza »

1. if ($dist < 4 && ($job == "Blacksmith" && $guild == "noob")) goto next
2. if (($dist < 4 && $job == "Blacksmith") && $guild == "noob") goto next
stop #or you can use goto here

Choose either style 1 or 2 if statement... ((.* && .*) && .*) or (.* && (.* && .*))



p.s: Becarefull on the opening/closing round brackets. Each multiple if-statement only support in pairs... 3 if-statement conditions is prohibited.

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

Re: near player info

#3 Post by RBiN »

^
ah thx for the info i thought it was just the same as perl. hehe!

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

Re: near player info

#4 Post by ezza »

RBiN wrote:^
ah thx for the info i thought it was just the same as perl. hehe!


I've created the look-a-like perl if-statement for macro... unfortunately it's still have some issues that I'm gonna settle 1st. Btw, I hope you use the multiple if-statement alot in your future macro.. so that if you think/found any bug in the code, I appreciate if you could just give me a buzz. THX ^^

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

#5 Post by fco2783 »

im just wondering if this macro needed a hook...

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

Re: near player info

#6 Post by RBiN »

fco2783 wrote:im just wondering if this macro needed a hook...
i didnt use any hook on it. maybe you can use hook if you want it in different way

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

Re: near player info

#7 Post by ezza »

ermm... RBiN did you test this macro yourself? I dont know why my pc hang everytime a person appear in the console. Its like there is something just loop the internal codes for a non-stop looping. Or its just I'm the only 1 that faced this problem.

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

Re: near player info

#8 Post by RBiN »

ezza wrote:ermm... RBiN did you test this macro yourself? I dont know why my pc hang everytime a person appear in the console. Its like there is something just loop the internal codes for a non-stop looping. Or its just I'm the only 1 that faced this problem.
yep, i used it in my autobuff/coat macro but i havent test it yet w/ a multiple if function

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

Re: near player info

#9 Post by ezza »

Okay now its working after I delete the other automacro. But I have 1 or 2 issues:-

Code: Select all

1. my $_player = Match::player("$i") #No underscore
Whats this $_player related to the below code? Since the $_player is re-declared to the other purpose/s.

Code: Select all

2. 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'}; }
And also, all the infos regarding the players only stored the last person exist in your players list. Let say there are 3 ppl, the macro only print out the last person (ID number 2) in your list regardless on thier distance which you set at 1st is 5 (it also print the last player even if the dist is 7).


If you wanna play with eval that print such infos to all the players avail use push method SAMPLES HERE

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

Re: near player info

#10 Post by RBiN »

about the issues
1. Whats this $_player related to the below code? Since the $_player is re-declared to the other purpose/s.
actually its just the same w/ or w/o my, maybe i already have a bad sight that i didnt notice about it. :P ill just make it short then

foreach my $_player = Match::player($_i) (@{$::playersList->getItems()}) {

im not sure if the $i in macro and $_i in an eval returns the same value.

Code: Select all

And also, all the infos regarding the players only stored the last person exist in your players list. Let say there are 3 ppl, the macro only print out the last person (ID number 2) in your list regardless on thier distance which you set at 1st is 5 (it also print the last player even if the dist is 7).


If you wanna play with eval that print such infos to all the players avail use push method SAMPLES HERE
i didnt notice the problem since i often used this, thx for informing. ill try to fix this if i have time since ill be busy most of the day. :D

Post Reply