Openkore.com

OpenKore Forums
It is currently 17 Sep 2019, 20:54

All times are UTC - 5 hours [ DST ]





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: About If Function
PostPosted: 06 Jun 2015, 04:41 
Offline
Noob
Noob

Joined: 06 May 2015, 15:29
Posts: 5
Hi, i just make a new post here because i've searched so many post about if function in macro and never resolved my problem, i just want to know how to use if function that's my first question and my second question are about sniffing packet, what tools can be use now ? coz i played on IdRO and i've tried to sniff packet either used JCV, Packet Extractor V3, and PEEK (to get recvpacket) and WPE, rPE, CE (to get some packet id used skill) never of that tools worked for me... i just trying google and not find any of clue....openkore is the last bot exists...i hope do not died like the other coz some feature are great.....and this my macro for packet priest that returns on console bot error message on using if function :

Code:
automacro TerimaPM {
   console /\(From: (.*)\) : (.*)/
   run-once 1
   call ProsesPM
}

macro ProsesPM {
   $ply = $.lastMatch1
   $cekBG = @invamount (Blue Gemstone)
   $test = $.lastMatch2

   if (($.lastMatch2 == q1) && ($cekBG > 0)) goto pktwrp

   :pktwrp
   pause 1
   do sp 29 $ply 10
   pause 1
   do sp 34 $ply 10
   pause 1
   do sp 28 $ply 10
   pause 1
   do sp 28 $ply 10
   pause 1
   do sp 28 $ply 10
   pause 1
   do sl 27 207 109 4
   pause 2
   do warp 2
   stop

   release TerimaPM   
}


so i can not check the Blue Gemstone whether there are or not...so pls help me....i used macro 2.0.2 and the if function only works for me is if (condition) goto (label) if i used other if function like on manual if (condition) {do that bla bla} it will came error and i used openkore OpenKore what-will-become-2.1 ( r8954 ).


Last edited by D4rr3n09 on 08 Jun 2015, 12:53, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: About If and Sniffing Packet
PostPosted: 07 Jun 2015, 12:12 
Offline
Moderators
Moderators
User avatar

Joined: 16 Dec 2011, 02:53
Posts: 1215
Location: Brazil
What's "q1" ?

if ($.lastMatch2 == q1) ?

Would it be a text ? Try within quotes.

Please edit your topic name because it's not related with sniff. You really problem is about if statment error.

_________________
"'There are three things all wise men fear: the sea in storm, a night with no moon, and the anger of a gentle man.'" :P

viewtopic.php?f=10&t=16117

Thanks for this Eternal! =D <3<3


Top
 Profile  
 
 Post subject: Re: About If Function
PostPosted: 08 Jun 2015, 13:27 
Offline
Noob
Noob

Joined: 06 May 2015, 15:29
Posts: 5
yes q1 is text PM from another player thx sir to answer my question is it "q1" ? and what about i can't use my other if function in notepad++, i'll try to follow what manual macro wrote and it became all error with munch munch warning and if i pushed it came warning tempMacro 0 error in if syntax, the only one if function worked is with go to label and it didn't worked perfectly....once again i used macro 2.0.2 and using notepad++ to edit the macro, the other question is how to compare console $.lastMatchN =~ /regex from console OK output/ using if statement, i've already tried switch with case and if with call all came error @@ so how i must used this if function ? this is my actually code and this use to made thief to rogue job change, here is my full code

Code:
automacro KeTempatWarp {
   map payon
   run-once 1
   call JalanWarp
}

macro JalanWarp {
   pause 1
   do move payon 204 114
   pause 1
   do pm BarryAllen q1
   pause 10
   do move payon 207 109
   pause 1   
   release KeTempatWarp
}

automacro QuestPertama {
   console /(.*)(Your Coordinates: 195, 117)(.*)/
   run-once 1
   call KeTempatQuest1
}

macro KeTempatQuest1 {
   do move in_rogue 363 117
   pause 1
   do talk @npc (363 122)
   pause 1
   do talk resp 0
   pause 1
   release QuestPertama
}

automacro SetPertanyaan {
   console /(.*): 1\. (.*)/
   console /(.*): 1\.(.*)/
   run-once 1
   call JawabTanya
}

macro JawabTanya {
   pause 3

   if ($.lastMatch2 [color=#FF0000]==[/color] "Apa skill yang diperlukan untuk mempelajari skill Rogue,Tunnel Drive?") goto Jawab1
   if ($.lastMatch2 [color=#FF0000]==[/color] "Monster apakah yang menjatuhkan Gladius slot?") goto Jawab2
   if ($.lastMatch2 [color=#FF0000]==[/color] "Berapakah tingkat flee yang ditambahkan untuk skill Increase dodge level 10?") goto Jawab3
   stop

   :Jawab1
      do c A
   stop
   :Jawab2
      do c B
   stop
   :Jawab3
      do c 3
   
   release SetPertanyaan
}


why i put console two trigger because there are one question with a long word and nothin space within number one and the word so i used two console and i did try /S not trigerring the other question i've already tried this :
Code:
if ($.lastMatch2 =~ /Apa skill yang diperlukan untuk mempelajari skill Rogue,Tunnel Drive\?/) goto Jawab1
   if ($.lastMatch2 =~ /Monster apakah yang menjatuhkan Gladius slot\?/) goto Jawab2
   if ($.lastMatch2 =~ /Berapakah tingkat flee yang ditambahkan untuk skill Increase dodge level 10\?/) goto Jawab3
   stop

   :Jawab1
      do c A
   stop
   :Jawab2
      do c B
   stop
   :Jawab3
      do c 3


and this is output console
Quote:
Anggota Perkumpulan Rog: [Marky]
Anggota Perkumpulan Rog: Dengarkan baik-baik dan jawablah pertanyaannya!
Anggota Perkumpulan Rog: Auto-continuing talking
Anggota Perkumpulan Rog: [Marky]
Anggota Perkumpulan Rog: 1. Monster apakah yang menjatuhkan Gladius slot?
[macro] automacro SetPertanyaan triggered.
Anggota Perkumpulan Rog: Auto-continuing talking
- Responses (Anggota Perkumpulan Rog) --
# Response
0 Thief bug
1 Pecopeco
2 Desert wolf
3 Kobold
4 Cancel Chat
----------------------------------------
Anggota Perkumpulan Rog: Type 'talk resp #' to choose a response.


if i checked in log Question : $.lastMatch2 the output result is true based on what i want now the problem is how to separate those 3 set question using if statement @@ on output console above it should the kore did chat pubm B but it did not happened and blank and sit @@ which one i'm wrong ? Thx and sry bout the title i've already change it....


Top
 Profile  
 
 Post subject: Re: About If Function
PostPosted: 08 Jun 2015, 22:37 
Offline
Moderators
Moderators
User avatar

Joined: 16 Dec 2011, 02:53
Posts: 1215
Location: Brazil
Great boy. All i can say is instead of use "questions" as trigger, try to use the "responses" as trigger. (Only if you know all answers, as you can check in rogue test guide)
For example :

console /(\d+)\s+?(Response1|Response2|Response3)/i

[0-9] isn't equivalent to \d. [0-9] matches only 0123456789 characters, while \d matches [0-9] and other digit characters, for example Eastern Arabic numerals ٠١٢٣٤٥٦٧٨٩

\d+ = + means 1 or more times. So, \d+ is 1 or more digits.

\s = Space
\s+ = Space 1 or more times
\s+? = Optionally.

Since the same answer won't appear twice in different questions.

And using $.lastMatch1 to respond the right question. ^^

And i don't know if you're right to use "chat" command. You should use "talk resp".

You can't use two blocks of console .
Quote:
console ("<text>" | /<regexp>/[i])
Triggers when <text> is received on console or the text received matches <regexp>.
The i switch means the regexp is case-insensitive.
Set variables:
$.lastLogMsg - the console text that trigerred the automacro.
$.lastMatchN - backreference from regexp.
Console generally includes custom strings, like names and chat messages, which can match your regexp, so matching the beginning and the end of the string should almost always be used (learn about regexp to find out how to do it - it's not just matching symbols at the beginning/end). Furthermore, use as narrow character classes as possible (avoid using .* and alike). Otherwise, your macro may be exploited.
Furthermore, format of console output isn't frozen and can change in future versions and/or in translations. It's not a good idea to rely on console condition.

_________________
"'There are three things all wise men fear: the sea in storm, a night with no moon, and the anger of a gentle man.'" :P

viewtopic.php?f=10&t=16117

Thanks for this Eternal! =D <3<3


Top
 Profile  
 
 Post subject: Re: About If Function
PostPosted: 09 Jun 2015, 01:35 
Offline
Noob
Noob

Joined: 06 May 2015, 15:29
Posts: 5
Thank You sir, it have been great idea to worked with the responses....but still i'm stucked on if function here my new codes

Code:
automacro SetPertanyaan {
   console /(\d+)\s+?(Hide|Thief Bug|30)/i
   run-once 1
   call JawabTanya
}

macro JawabTanya {
   log Response : $.lastMatch2
   pause 3

   if ($.lastMatch2 == "Hide") call Jawab1
   pause 2
   if ($.lastMatch2 == "Thief Bug") call Jawab2
   pause 2
   if ($.lastMatch2 == "30") call Jawab3
   pause 2

   release SetPertanyaan
}

macro Jawab1 {
   do c A
}

macro Jawab2 {
   do c B
}

macro Jawab3 {
   do c C
}


and it's returned [macro] JawabTanya error: error in 2: syntax error in if statement, i used "chat" command to checked my if function worked or not, it seems did not worked at all :shock: coz if my if statement didn't worked all set question will have answer for my first if and it returns 50 points that will failed on rogue test except the same set question for my first set question, on my code above console /(\d+)\s+?(Hide|Thief Bug|30)/i it means Hide for set question one, Thief Bug for set question 2 and 30 for set question 3

And if i'd tried code if like this
Code:
macro JawabTanya {
   log Response : $.lastMatch2
   pause 3

   if ($.lastMatch2 == "Hide") {
             do c A
        }
   pause 2
   if ($.lastMatch2 == "Thief Bug") {
             do c B
        }
   pause 2
   if ($.lastMatch2 == "30") {
             do c C
        }
   pause 2

   release SetPertanyaan
}


it will appeared at the start turn on my bot showed error message like this

Quote:
control\macros.txt: ignoring line 'if ($.lastMatch2 =~ /Thief Bug/) {' (munch,
munch, strange block)
control\macros.txt: ignoring line 'if ($.lastMatch2 =~ /30/) {' (munch, munch,
strange block)
control\macros.txt: ignoring '}' (munch, munch, strange food)


only this step i failured, i just so stucked with this if statement T-T and for the last quote if i pushed the OK then shows error message like this
[macro] JawabTanya error: error in 2: syntax error in if statement


Top
 Profile  
 
 Post subject: Re: About If Function
PostPosted: 09 Jun 2015, 01:51 
Offline
Moderators
Moderators
User avatar

Joined: 16 Dec 2011, 02:53
Posts: 1215
Location: Brazil
Hey bro, check the macro on the final of post ... But first read this :

Your argument doesn't match because the log says "=~" and your macros posted here is using "==". So you should check your
macros.txt and exclude unnecessary macros. And another thing.

Read in macro plugin about if statment.Take a look in "else", "elsif", "switch/case".

Your macro Should be working, but there's multiple macros. I guess you forgot to erase something.

Sometimes here the if statment doesn't work, but to avoid this :

Download Macro Plugin

Delete only the "test" folder. Then move to your plugins folder.

Anyway, if doesn't work and only in your macros.txt are existing these macros and the problem persists, try using "goto".

You'll do this change, but try this :

Code:
macro JawabTanya {
   log Response : $.lastMatch2
   pause 3
   do talk resp $.lastMatch1
   release SetPertanyaan
}

_________________
"'There are three things all wise men fear: the sea in storm, a night with no moon, and the anger of a gentle man.'" :P

viewtopic.php?f=10&t=16117

Thanks for this Eternal! =D <3<3


Top
 Profile  
 
 Post subject: Re: About If Function
PostPosted: 09 Jun 2015, 05:54 
Offline
Noob
Noob

Joined: 06 May 2015, 15:29
Posts: 5
Thanks mod SkyLord with your suggestion i've already problem solved but i did not use if statement i use automacro with triggered another respon one by one and it worked perfectly and THANKS YOU FOR YOUR SUPPORT i'll try your DL link in case another people have problem same as i do i will feedback your link in here thanks once againnnn. At least i've been proud of what i did :D hahahaha it's releiveee, thanks a lot sky lorddd

With your DL links you gave me the If statements for me works perfectlyyyy now i can use switch and the other statement thanks SkyLord......pls close these threads thanksss


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group