Open-SAMP-API
Open-SAMP-API copied to clipboard
GetChatLine
I noticed that the function GetChatLine(LineNumber(FromTheBottom), Variable) is missing.
Was it renamed or isn't it in the api?
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
}
If we have time, we add this without the need of the "chatlog.txt", so the performance is better.
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.
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
}