Page 1 of 1

Help with samp heal

Posted: 07 Oct 2018, 04:49
by Warklot
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?

Re: Help with samp heal

Posted: 07 Oct 2018, 06:39
by SL5
how is he sending "Heal"?

where you could read it? in a website?

is it a picture?

Re: Help with samp heal

Posted: 07 Oct 2018, 07:18
by Warklot
-Like /sms Warklot heal and i get message "heal"
-in the Documents>gta san andreas user files> samp > chatlog

Re: Help with samp heal

Posted: 07 Oct 2018, 09:12
by SL5
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?

Re: Help with samp heal

Posted: 07 Oct 2018, 09:26
by swagfag
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...

Re: Help with samp heal

Posted: 07 Oct 2018, 09:52
by Warklot
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;/

Re: Help with samp heal

Posted: 07 Oct 2018, 10:23
by SL5
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?

Re: Help with samp heal

Posted: 07 Oct 2018, 10:36
by Warklot
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

Re: Help with samp heal

Posted: 07 Oct 2018, 10:45
by swagfag
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.

Re: Help with samp heal

Posted: 08 Oct 2018, 06:54
by Warklot
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

Re: Help with samp heal

Posted: 09 Oct 2018, 11:55
by Warklot
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;/

Re: Help with samp heal

Posted: 09 Oct 2018, 12:03
by swagfag
idk, i have no idea what ur chatlog.txt looks like

Re: Help with samp heal

Posted: 09 Oct 2018, 12:07
by Warklot
swagfag wrote:idk, i have no idea what ur chatlog.txt looks like

Re: Help with samp heal

Posted: 09 Oct 2018, 12:38
by swagfag
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

Re: Help with samp heal

Posted: 09 Oct 2018, 12:53
by Warklot
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

Re: Help with samp heal

Posted: 09 Oct 2018, 13:22
by swagfag
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".

Re: Help with samp heal

Posted: 09 Oct 2018, 13:48
by Warklot
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

Re: Help with samp heal

Posted: 10 Oct 2018, 06:21
by swagfag

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

Re: Help with samp heal

Posted: 10 Oct 2018, 07:36
by Warklot
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]:"