AHK SAMP UdfEx (0.3.7)

Suicide Bomb

Active member
Joined
Jun 22, 2014
Messages
100
Reaction score
1
Re: <img class=

thanks but I wanted to give my actor a gun, like

GiveWeapon(weaponid, ammo)
 
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:
 

Ghost29

Member
Joined
Mar 11, 2015
Messages
10
Reaction score
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"
}
 

Ghost29

Member
Joined
Mar 11, 2015
Messages
10
Reaction score
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"
}
 

Ghost29

Member
Joined
Mar 11, 2015
Messages
10
Reaction score
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.
 

Danil_Valov

Member
Joined
Jun 3, 2015
Messages
11
Reaction score
0
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?
 

fusro

Member
Joined
Sep 21, 2014
Messages
20
Reaction score
0
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

Active member
Joined
Nov 6, 2014
Messages
52
Reaction score
0
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
Reaction score
0
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?
 

democrazy

Active member
Joined
Aug 4, 2014
Messages
65
Reaction score
0
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
 

Storm

Member
Joined
Jan 22, 2014
Messages
21
Reaction score
0
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

Active member
Joined
Jun 22, 2014
Messages
100
Reaction score
1
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
Reaction score
0
add GetChatLine_func := DllCall("GetProcAddress", UInt, hModule, Str, "GetChatLine") please
 

Momo92

Active member
Joined
Aug 21, 2013
Messages
42
Reaction score
0
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
Reaction score
0
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.
 

Alexandr Skinfy

New member
Joined
Jul 15, 2016
Messages
1
Reaction score
0
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")


Code:
WaitChat(text, callFuncChatWait, timeout = 0)
{
    global
	if(!IsObject(ChatLine))
		ChatLine := Object()
	if(!IsObject(isWait))
		isWait := Object()
	if(!IsObject(stTime))
		stTime := Object()
    if(isWait[txt])
        return
    isWait[text] := true
    if(timeout > 0)
    {
        stTime[text]  := A_TickCount
    }
    dwAddrr1 := readDWORD(hGTA, dwSAMP +ADDR_SAMP_CHATMSG_PTR)
    Loop
    {
        if(!isWait[text])
            return
        if(A_TickCount - stTime[text] >= timeout  && timeout > 0)
        {
            ErrorLevel := 1
            isWait[text] := false
            %callFuncChatWait%(text, text, 1)
            return
        }
        i := 0
        loop 99
        {
            RLine := 0x132 + ((99 - i) * 0xFC) + 125
            Reading := readMem(hGTA, dwAddrr1 + RLine)
            if(ChatLine[text] = Reading)
                i := 0
            if(RegExMatch(GetChatLineEx(i), text, result))
            {
                ErrorLevel := 0
                VarSetCapacity(TimeTime, 4, 0)
                NumPut(A_Hour A_Min A_Sec,TimeTime,0,"Int")
                WriteRaw(hGTA, dwAddrr1 + RLine, &TimeTime, 4)
				ChatLine[text] := readMem(hGTA, dwAddrr1 + RLine)
                isWait[text] := false
                %callFuncChatWait%(result, text, 0)
                return
            }
            i++
        }
    }
    return
}

[font=arial, sans-serif]Greetings to my Western friends . I am from Russia and I want to share with you their experience . I do not know much English. I use google translate. Do not judge strictly.
The purpose of the code below: Search in chat line and finding the cause % callFuncChatWait%. It works only with no "timeout", yet . Who will be able to bring to mind - well done . The problem with the "timeout" in the fact that the function will be called twice if you use "sleep" to function .[/font]
 

Momo92

Active member
Joined
Aug 21, 2013
Messages
42
Reaction score
0
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