Open-SAMP-API icon indicating copy to clipboard operation
Open-SAMP-API copied to clipboard

GetChatLine

Open BigBrainAFK opened this issue 10 years ago • 4 comments
trafficstars

I noticed that the function GetChatLine(LineNumber(FromTheBottom), Variable) is missing.

Was it renamed or isn't it in the api?

BigBrainAFK avatar Jul 19 '15 16:07 BigBrainAFK

Here the function from SAMP UDF

; ##### Sonstiges ##### ; written by David_Luchs ; returns nth message of chatlog (beggining from bottom) ; -1 = error GetChatLine(Line, ByRef Output, timestamp=0, color=0){ chatindex := 0 FileRead, file, %A_MyDocuments%\GTA San Andreas User Files\SAMP\chatlog.txt loop, Parse, file, n,r { if(A_LoopField) chatindex := A_Index } loop, Parse, file, n,r { if(A_Index = chatindex - line){ output := A_LoopField break } } file := "" if(!timestamp) output := RegExReplace(output, "U)^[\d{2}:\d{2}:\d{2}]") if(!color) output := RegExReplace(output, "Ui){[a-f0-9]{6}}") return }

BigBrainAFK avatar Jul 24 '15 21:07 BigBrainAFK

If we have time, we add this without the need of the "chatlog.txt", so the performance is better.

ghost avatar Jul 25 '15 08:07 ghost

Right now I'm using the chatlog file as well... But it would be fantastic if the chatlog would be read directly from memory... Thank you.

DavidBrenner3 avatar Dec 27 '17 04:12 DavidBrenner3

getChatLineEx(line := 0) {
    ; 0x152 - offset for first message
    ; 0xFC - size of a message
    ; 99 - max count of a messages
    if(!checkHandles())
        return
    dwPtr := dwSAMP + ADDR_SAMP_CHATMSG_PTR
    dwAddress := readDWORD(hGTA, dwPtr)
    if(ErrorLevel)
        return
    msg := readString(hGTA, dwAddress + 0x152 + ( (99-line) * 0xFC), 0xFC)
    if(ErrorLevel)
        return
    return msg
}

LuxXx avatar May 28 '18 10:05 LuxXx