AHK SAMP UdfEx (0.3.7)

D

Deleted member 37096

Guest
Display people around me through the chat isn't difficult. But now, I want to list them within a simple dialog.
I've tried to append the player infos into a var and add `n at the back. The Problem is that I'm only able to get a single player.

Could someone plz help me?
:sadpepe:
 
Joined
Mar 11, 2015
Messages
10
Likes
0
Points
1
1
emrtop said:
Display people around me through the chat isn't difficult. But now, I want to list them within a simple dialog.
I've tried to append the player infos into a var and add `n at the back. The Problem is that I'm only able to get a single player.

Could someone plz help me?
:sadpepe:
Code:
numpad1::
callFuncForAllStreamedInPlayers("foo", 300)
showdialog(2, "Names", names, "OK")
names := ""
return

foo(o)
{
    if(!o)
        return
    global name := o.name ""
    global Names .= "" NAME "`n"
}
 
Joined
Mar 11, 2015
Messages
10
Likes
0
Points
1
1
emrtop said:
Display people around me through the chat isn't difficult. But now, I want to list them within a simple dialog.
I've tried to append the player infos into a var and add `n at the back. The Problem is that I'm only able to get a single player.

Could someone plz help me?
:sadpepe:
Code:
numpad1::
callFuncForAllStreamedInPlayers("foo", 300)
showdialog(2, "Names", names, "OK")
names := ""
return

foo(o)
{
    if(!o)
        return
    global name := o.name ""
    global Names .= "" NAME "`n"
}
 
Joined
Mar 11, 2015
Messages
10
Likes
0
Points
1
1
Hello everyone, i need your help, can someone write/find a function that can take screenshots in game? And there is one problem, gdip + ahk doesn't work, it saves black screen or desktop. I really need this function! Thanks.
 
Joined
Jun 3, 2015
Messages
11
Likes
0
Points
1
1
Ghost29 said:
Hello everyone, i need your help, can someone write/find a function that can take screenshots in game? And there is one problem, gdip + ahk doesn't work, it saves black screen or desktop. I really need this function! Thanks.
Maybe can you use screenshot after press F8 button from Documents/GTA SA/samp directory?
 
Joined
Sep 21, 2014
Messages
20
Likes
0
Points
51
I compile and run SAMP.exe but it appears to crash. What could the problem be? It starts then closes with no error messages.
 

whoonga

Well-Known Member
Joined
Nov 6, 2014
Messages
52
Likes
0
Points
56
fusro said:
I compile and run SAMP.exe but it appears to crash. What could the problem be? It starts then closes with no error messages.
Because there is nothing to execute for AHK.
The SAMP.ahk is just a "list of functions", not an executable script.
 

Godarck

New Member
Joined
May 12, 2016
Messages
1
Likes
0
Points
1
1
RE: [AHK] samp UdfEx (0.3.7)

Suicide Bomb said:
luxdav link said:
Dude, here are my functions:

Code:
; sets the ingame hour (day/night)
; @author luxdav aka David_Luchs
; @param hour the time between 0 and 23
setTime(hour)
{
	if(!checkHandles())
		return
	; disable gta setTime function
	VarSetCapacity(nop, 6, 0)
	Loop 6 {
		NumPut(0x90,nop,A_INDEX-1,"UChar")
	}
	writeRaw(hGTA, 0x52D168, &nop, 6)

	; set our own weather
	VarSetCapacity(time, 1, 0)
	NumPut(hour, time,0,"Int")
	writeRaw(hGTA, 0xB70153, &time, 1)
}
Greets luxdav
Can you fix this one? It only sets the time for a milisecond or so.
springfield said:
@smn for time, nop this too -> samp.dll+9C0B4, same instruction.
Hello. I try all, but isn`t works. I have the same problem: "It only sets the time for a milisecond or so." 
Please can you fix it with complete code?
 
OP
OP
D

democrazy

Well-Known Member
Joined
Aug 4, 2014
Messages
65
Likes
0
Points
56
Suicide Bomb said:
democrazy said:
Suicide Bomb said:
Is it possible to register client side commands in AHK?
yes, but it doesn't make sense
use AHK hotkeys instead
How come it doesn't? Can you please give me an example?
client side commands need a function pointer, which will handle your command
but samp udf works external , so client side command is not useful
 
Joined
Jan 22, 2014
Messages
21
Likes
0
Points
51
democrazy said:
you can set "red checkpoint" with this functions, i made:
Code:
setCheckpoint(fX, fY, fZ, fSize ) {
    if(!checkHandles())
        return false
    dwFunc := dwSAMP + 0x9D340
    
    dwAddress := readDWORD(hGTA, dwSAMP + ADDR_SAMP_INCHAT_PTR) ;misc info
    if(ErrorLevel || dwAddress==0) {
        ErrorLevel := ERROR_READ_MEMORY
        return false
    }
    
    VarSetCapacity(buf, 16, 0)
    NumPut(fX, buf, 0, "Float")
    NumPut(fY, buf, 4, "Float")
    NumPut(fZ, buf, 8, "Float")
    NumPut(fSize, buf, 12, "Float")
    
    writeRaw(hGTA, pParam1, &buf, 16)
    
    dwLen := 31
    
    
    VarSetCapacity(injectData, dwLen, 0)
    
    NumPut(0xB9, injectData, 0, "UChar")
    NumPut(dwAddress, injectData, 1, "UInt")
    NumPut(0x68, injectData, 5, "UChar")
    NumPut(pParam1+12, injectData, 6, "UInt")
    NumPut(0x68, injectData, 10, "UChar")
    NumPut(pParam1, injectData, 11, "UInt")
    NumPut(0xE8, injectData, 15, "UChar")
    offset := dwFunc - (pInjectFunc + 20)
    NumPut(offset, injectData, 16, "Int")
    NumPut(0x05C7, injectData, 20, "UShort")
    NumPut(dwAddress+0x24, injectData, 22, "UInt")
    NumPut(1, injectData, 26, "UInt")
    NumPut(0xC3, injectData, 30, "UChar")
    
    
    writeRaw(hGTA, pInjectFunc, &injectData, dwLen)
    if(ErrorLevel)
        return false
    
    hThread := createRemoteThread(hGTA, 0, 0, pInjectFunc, 0, 0, 0)
    if(ErrorLevel)
        return false
    
    waitForSingleObject(hThread, 0xFFFFFFFF)
    
    closeProcess(hThread)
    
    ErrorLevel := ERROR_OK
    return true
}
disableCheckpoint()
{
    if(!checkHandles())
        return false
    
    dwAddress := readDWORD(hGTA, dwSAMP + ADDR_SAMP_INCHAT_PTR) ;misc info
    if(ErrorLevel || dwAddress==0) {
        ErrorLevel := ERROR_READ_MEMORY
        return false
    }
    
    VarSetCapacity(enablecp, 4, 0)
    NumPut(0,enablecp,0,"Int")
    writeRaw(hGTA, dwAddress+0x24, &enablecp, 4)
    
    ErrorLevel := ERROR_OK
    return true
}
How to set two and more markers?
 

Suicide Bomb

Well-Known Member
Joined
Jun 22, 2014
Messages
100
Likes
0
Points
66
democrazy said:
Suicide Bomb said:
democrazy said:
Suicide Bomb said:
Is it possible to register client side commands in AHK?
yes, but it doesn't make sense
use AHK hotkeys instead
How come it doesn't? Can you please give me an example?
client side commands need a function pointer, which will handle your command
but samp udf works external , so client side command is not useful
Okay, I get you. But when it comes to parameters hotkeys are really hard to work with, what I mean is creating a command like /payex [param1] [param2] [param3] etc. Do you have a solution for that? Thank you anyways!
 

dope

Active Member
Joined
Jan 11, 2014
Messages
37
Likes
0
Points
56
add GetChatLine_func := DllCall("GetProcAddress", UInt, hModule, Str, "GetChatLine") please
 

Momo92

Active Member
Joined
Aug 21, 2013
Messages
42
Likes
0
Points
56
dope said:
add GetChatLine_func := DllCall("GetProcAddress", UInt, hModule, Str, "GetChatLine") please
There is a function in the UDF I think by @luxdav:
Code:
; 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
}
 

dope

Active Member
Joined
Jan 11, 2014
Messages
37
Likes
0
Points
56
Momo92 said:
dope said:
add GetChatLine_func := DllCall("GetProcAddress", UInt, hModule, Str, "GetChatLine") please
There is a function in the UDF I think by @luxdav:
Code:
; 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
}
afaik trying to read the chatlog.txt doesn't work because SAMP doesn't update the file until you tab out of the game, or that's how it used to be.
 
Joined
Jul 15, 2016
Messages
1
Likes
0
Points
1
1
Code:
HexToDec(str)
{   
    local newStr := ""
    static comp := {0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, "a":10, "b":11, "c":12, "d":13, "e":14, "f":15}
    StringLower, str, str
    str := RegExReplace(str, "^0x|[^a-f0-9]+", "")
    Loop, % StrLen(str)
        newStr .= SubStr(str, (StrLen(str)-A_Index)+1, 1)
    newStr := StrSplit(newStr, "")
    local ret := 0
    for i,char in newStr
        ret += comp[char]*(16**(i-1))
    return ret
}
addChatMessageEx(Color, wText) {
    wText := "" wText

    if(!checkHandles())
        return false
    
	VarSetCapacity(data2, 4, 0)
    NumPut(HexToDec(Color),data2,0,"Int")
	
    Addrr := readDWORD(hGTA, dwSAMP+ADDR_SAMP_CHATMSG_PTR)
    
    VarSetCapacity(data1, 4, 0)
    NumPut(readDWORD(hGTA, Addrr + 0x12A), data1,0,"Int") 
    
    WriteRaw(hGTA, Addrr + 0x12A, &data2, 4)
	
    dwFunc := dwSAMP + FUNC_SAMP_ADDTOCHATWND
    dwChatInfo := readDWORD(hGTA, dwSAMP + ADDR_SAMP_CHATMSG_PTR)
    if(ErrorLevel) {
        ErrorLevel := ERROR_READ_MEMORY
        return false
    }
    
    callWithParams(hGTA, dwFunc, [["p", dwChatInfo], ["s", wText]], true)
    WriteRaw(hGTA, Addrr + 0x12A, &data1, 4)
    
    ErrorLevel := ERROR_OK
	
    return true
}
Code:
addChatMessageEx("FFD700", "Hello {FF00FF}world")

 

Momo92

Active Member
Joined
Aug 21, 2013
Messages
42
Likes
0
Points
56
dope said:
Momo92 said:
dope said:
add GetChatLine_func := DllCall("GetProcAddress", UInt, hModule, Str, "GetChatLine") please
There is a function in the UDF I think by @luxdav:
Code:
; 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
}
afaik trying to read the chatlog.txt doesn't work because SAMP doesn't update the file until you tab out of the game, or that's how it used to be.
That's not the case (anymore). Many people are using this or a similar function that works with the chatlog.
 
Top