Reading text from chatlog file and make actions

Ask gaming related questions (AHK v1.1 and older)
dave3233
Posts: 3
Joined: 07 Feb 2021, 11:50

Reading text from chatlog file and make actions

07 Feb 2021, 12:17

Could You guys help me with the script for GTA samp server? I will repay in donations :)

I need a script that reads from chat log file and If appears in the file
"You caught Seriol, weighing 43 kg." and the number of x kg is greater than 80kg it will type "/fishing", but if the value is less than 80kg it will type "/thorwfish". And so until it catches a maximum of 4 fish, so it must have 4 fish over 80 kg. Sometimes, after entering the command "/fishing", the system gives the following messages:
You caught Sausage so you eat it!
You caught old pants, so you put them on!
You caught the lard, so you eat it!
You grabbed a money purse, you found $ x inside
The line broke!
The script should bypass these messages.

So far, I only have a command that reads a given phrase from the file and does something when it appears.
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Reading text from chatlog file and make actions

07 Feb 2021, 13:09

Here is a starting point, but it sounds like-- and not described-- you actually want to read the file as it is being generated. To accomplish that, you could process the file and then delete it, and read it again, in a loop.

Code: Select all

log := A_Desktop "\log.log", n := 0
If !FileExist(log) {
 MsgBox, 48, Error, File not found.`n`n%log%
 Return
}
Loop, Read, %log%
{
 RegExMatch(A_LoopReadLine, "You caught Seriol, weighing \K\d+?(?= kg)", kg)
 If !kg
  Continue
 If (kg >= 80) {
  Send /fishing`n
  If (++n < 4)
   Continue
  MsgBox, 64, Done, You won!
  Return
 } Else Send /throwfish`n
}
ThewarII
Posts: 49
Joined: 01 Oct 2014, 09:33

Re: Reading text from chatlog file and make actions

07 Feb 2021, 13:12

Can you share IP address of server Gta San Andreas multiplayer?
I can join and share scripts for you.
I :superhappy:(happy) when I know about AHK.
I have & am using AHK to do anything in windows microsoft.
The first time, I know it in around year 2013.
dave3233
Posts: 3
Joined: 07 Feb 2021, 11:50

Re: Reading text from chatlog file and make actions

07 Feb 2021, 14:51

@mikeyww
Thanks for your help :) The file is generated in the location C:\Users\PC\Documents\GTA San Andreas User Files\SAMP\chatlog.txt. How can I link this file to the script?
dave3233
Posts: 3
Joined: 07 Feb 2021, 11:50

Re: Reading text from chatlog file and make actions

07 Feb 2021, 14:52

@ThewarII
Its Polish server. I have translated the commands. It's a basic fishing script like one on samp.hzgaming.net:7777
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Reading text from chatlog file and make actions

07 Feb 2021, 15:00

You can update the first line.

Code: Select all

log := A_MyDocuments "\GTA San Andreas User Files\SAMP\chatlog.txt", n := 0
ThewarII
Posts: 49
Joined: 01 Oct 2014, 09:33

Re: Reading text from chatlog file and make actions

13 Apr 2021, 11:10

Tell me your server is playing.
I will make script fishing for you when i can.
I :superhappy:(happy) when I know about AHK.
I have & am using AHK to do anything in windows microsoft.
The first time, I know it in around year 2013.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 79 guests