SAMPProjects / Open-SAMP-API

An open source API for GTA SA:MP
GNU Lesser General Public License v3.0
63 stars 15 forks source link

GetChatLine #14

Open BigBrainAFK opened 9 years ago

BigBrainAFK commented 9 years ago

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

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

BigBrainAFK commented 9 years ago

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 }

ghost commented 9 years ago

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

DavidBrenner3 commented 6 years ago

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.

LuxXx commented 6 years ago
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
}