Help with samp heal

Ask gaming related questions (AHK v1.1 and older)
Warklot
Posts: 12
Joined: 07 Oct 2018, 04:33

Help with samp heal

07 Oct 2018, 04:49

Hello, i basically need a code that would work in game. The code must do this: When a player sends me a message with a keyword "Heal" or [ID] the code must type out "/heal (The name of the person who's sending me a message or ID)" just for the record the game is GTA San Andreas, I need this for SA-MP server. Can anoyone make a code for me or atleast help me?
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: Help with samp heal

07 Oct 2018, 06:39

how is he sending "Heal"?

where you could read it? in a website?

is it a picture?
Warklot
Posts: 12
Joined: 07 Oct 2018, 04:33

Re: Help with samp heal

07 Oct 2018, 07:18

-Like /sms Warklot heal and i get message "heal"
-in the Documents>gta san andreas user files> samp > chatlog
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: Help with samp heal

07 Oct 2018, 09:12

Warklot wrote:-Like /sms Warklot heal and i get message "heal"
-in the Documents>gta san andreas user files> samp > chatlog
heal stands in the chatlog file?

so simply scan this file every second or so. works?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Help with samp heal

07 Oct 2018, 09:26

some guy asked for something similar a couple of days ago: https://autohotkey.com/boards/viewtopic ... hilit=samp
but they seem to have decided to overwrite the posts lol. what a drag...
Warklot
Posts: 12
Joined: 07 Oct 2018, 04:33

Re: Help with samp heal

07 Oct 2018, 09:52

swagfag wrote:some guy asked for something similar a couple of days ago: https://autohotkey.com/boards/viewtopic ... hilit=samp
but they seem to have decided to overwrite the posts lol. what a drag...
dat code doesn't work;/
User avatar
SL5
Posts: 879
Joined: 12 May 2015, 02:10
Contact:

Re: Help with samp heal

07 Oct 2018, 10:23

Warklot wrote:
swagfag wrote:some guy asked for something similar a couple of days ago: https://autohotkey.com/boards/viewtopic ... hilit=samp
but they seem to have decided to overwrite the posts lol. what a drag...
dat code doesn't work;/
what you mean by not work?
Warklot
Posts: 12
Joined: 07 Oct 2018, 04:33

Re: Help with samp heal

07 Oct 2018, 10:36

SL5 wrote:
Warklot wrote:
swagfag wrote:some guy asked for something similar a couple of days ago: https://autohotkey.com/boards/viewtopic ... hilit=samp
but they seem to have decided to overwrite the posts lol. what a drag...
dat code doesn't work;/
what you mean by not work?
like someone writes to me "heal" and
Send % "t/heal " playerID "{Enter}"
doesn't work
maybe i'm doing something wrong , i'm newbie:D
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Help with samp heal

07 Oct 2018, 10:45

no, its unlikely it would work without making some modifications.
in the thread the guy need to have the last line of the chatlog checked whether it contained "heal", and the previous line ran through a regexp to extract the "playerID"
so, besides the chatlog path, ud have to change at least those 2 things for the script to work at all.
Warklot
Posts: 12
Joined: 07 Oct 2018, 04:33

Re: Help with samp heal

08 Oct 2018, 06:54

swagfag wrote:no, its unlikely it would work without making some modifications.
in the thread the guy need to have the last line of the chatlog checked whether it contained "heal", and the previous line ran through a regexp to extract the "playerID"
so, besides the chatlog path, ud have to change at least those 2 things for the script to work at all.
mm can you help me?:D what to change:D
Warklot
Posts: 12
Joined: 07 Oct 2018, 04:33

Re: Help with samp heal

09 Oct 2018, 11:55

swagfag wrote:no, its unlikely it would work without making some modifications.
in the thread the guy need to have the last line of the chatlog checked whether it contained "heal", and the previous line ran through a regexp to extract the "playerID"
so, besides the chatlog path, ud have to change at least those 2 things for the script to work at all.

so how to exract the playerd id through regexp? sorry i'm so dumb;/
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Help with samp heal

09 Oct 2018, 12:03

idk, i have no idea what ur chatlog.txt looks like
Warklot
Posts: 12
Joined: 07 Oct 2018, 04:33

Re: Help with samp heal

09 Oct 2018, 12:07

swagfag wrote:idk, i have no idea what ur chatlog.txt looks like
Last edited by Warklot on 09 Oct 2018, 13:01, edited 1 time in total.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Help with samp heal

09 Oct 2018, 12:38

look, i dont play samp, this is all gibberish to me
craft a regexp to match the ID. eg. assuming its a number enclosed in braces:

Code: Select all

RegExMatch("wasd {1234} asdf", "{\K[^}]+", match)
msgbox % match
Warklot
Posts: 12
Joined: 07 Oct 2018, 04:33

Re: Help with samp heal

09 Oct 2018, 12:53

swagfag wrote:look, i dont play samp, this is all gibberish to me
craft a regexp to match the ID. eg. assuming its a number enclosed in braces:

Code: Select all

RegExMatch("wasd {1234} asdf", "{\K[^}]+", match)
msgbox % match
what does "{\K[^}]+" mean?:P sorry if its sounds dumb to you:D
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Help with samp heal

09 Oct 2018, 13:22

https://autohotkey.com/docs/misc/RegEx-QuickRef.htm
The escape sequence \K is similar to a look-behind assertion because it causes any previously-matched characters to be omitted from the final matched string. For example, foo\Kbar matches "foobar" but reports that it has matched "bar".
Warklot
Posts: 12
Joined: 07 Oct 2018, 04:33

Re: Help with samp heal

09 Oct 2018, 13:48

swagfag wrote:https://autohotkey.com/docs/misc/RegEx-QuickRef.htm
The escape sequence \K is similar to a look-behind assertion because it causes any previously-matched characters to be omitted from the final matched string. For example, foo\Kbar matches "foobar" but reports that it has matched "bar".
[20:31:01] [SMS] [Mantuxx_Downhiller {00FF00}[P] {E3B924}(67) >> Rusteze_Dinoco]:
[20:31:01] heal

Like if someone writes heal the program checks id example : (67) and heals that id
i don't know how to write that in ahk language
maybe its easier for you?:D like i know you are doing all the work, i appreciate that
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Help with samp heal

10 Oct 2018, 06:21

Code: Select all

secondToLast := "[20:31:01] [SMS] [Mantuxx_Downhiller {00FF00}[P] {E3B924}(67) >> Rusteze_Dinoco]:"
last := "[20:31:01] heal"

if (InStr(last, "heal") && RegExMatch(secondToLast, "(?<= \[SMS\] \[).*\((\d+)\) >>", M))
{
	playerID := M1

	MsgBox % "t/heal " playerID "{Enter}"
}
else
    msgbox something went wrong
the core logic works, so the regex should be the problem.
maybe the chatlog.txt isnt being opened, did u point the script to the correct file?
maybe ur chatlog.txt messages get prepended, instead of being appended to it. the script extracts and checks the last 2 lines from it
maybe the chatlog file is locked
Warklot
Posts: 12
Joined: 07 Oct 2018, 04:33

Re: Help with samp heal

10 Oct 2018, 07:36

swagfag wrote:

Code: Select all

secondToLast := "[20:31:01] [SMS] [Mantuxx_Downhiller {00FF00}[P] {E3B924}(67) >> Rusteze_Dinoco]:"
last := "[20:31:01] heal"

if (InStr(last, "heal") && RegExMatch(secondToLast, "(?<= \[SMS\] \[).*\((\d+)\) >>", M))
{
	playerID := M1

	MsgBox % "t/heal " playerID "{Enter}"
}
else
    msgbox something went wrong
the core logic works, so the regex should be the problem.
maybe the chatlog.txt isnt being opened, did u point the script to the correct file?
maybe ur chatlog.txt messages get prepended, instead of being appended to it. the script extracts and checks the last 2 lines from it
maybe the chatlog file is locked
chatlog is open + i only need ID to get if in that sms he writes "heal".This line changing every time i get different sms "[20:31:01] [SMS] [Mantuxx_Downhiller {00FF00}[P] {E3B924}(67) >> Rusteze_Dinoco]:"

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Pianist and 44 guests