Skip to content

Commit

Permalink
Pull Version 0.3.0 into Master Branch (#8)
Browse files Browse the repository at this point in the history
Version 0.3.0

### _SAMPAHK.ahk_
- WriteFloat() function added.
- WriteDWORD() function added.
- CPed not working addresses removed.
- editRecoil() Function added.
- Gun Recoil Address added.

### _README.md_
- Some text edited.

### _LICENSE.md_
- Changed to LGPL v3.0

Some code in SAMP.ahk by: EchoDRecho <[email protected]>
  • Loading branch information
mookums authored Apr 29, 2020
1 parent 878589b commit be0d599
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 18 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
## SAMPAHK (v0.2)

![Image of Build Status](https://ci.appveyor.com/api/projects/status/ys6gm8pk3xg02pvx?svg=true)
## SAMPAHK (0.3.0)

Based off: [SAMPUDF](https://github.com/paul-phoenix/SAMP-UDF-for-AutoHotKey) by paul-phoenix

Expand All @@ -11,9 +9,10 @@ Based off: [SAMPUDF](https://github.com/paul-phoenix/SAMP-UDF-for-AutoHotKey) by
SAMPAHK is an API specifically made to be used inside of [AutoHotKey](https://www.ahkscript.org). A majority of the framework comes from the original repository made by paul-phoenix, linked above.The end goal for SAMPAHK is to be able to provide a more complete platform for SA-MP memory modding in AutoHotKey. If you have any issues with the program, please leave an issue ticket.

### SUPPORTED SAMP VERSIONS
_Currently. only [SA-MP Version 0.3.7 R1.](https://dracoblue.net/downloads/samp-client/)_
_Currently. only [SA-MP Version 0.3.7 R1.](https://dracoblue.net/downloads/samp-client/) and Version 1 of the GTA SA Executable._


### USAGE
### USAGE
#### (MAKE SURE THE SAMP.AHK FILE IS IN THE SAME DIRECTORY AS THE .AHK YOU ARE WRITING)

#### Referencing the API in your script:
Expand Down
82 changes: 69 additions & 13 deletions SAMP.ahk
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
; #### SAMPAHK ####
; #### SAMPAHK ####
; https://github.com/kessec/SAMPAHK
; ####################

; UPDATE THIS OR YOUR MERGE WILL BE CLOSED.
; SOFTWARE VERSION: v0.2.0
; SOFTWARE VERSION: 0.3.0


; ErrorLevels
Expand Down Expand Up @@ -36,12 +36,6 @@ global ADDR_CPED_HPOFF := 0x540
global ADDR_CPED_ARMOROFF := 0x548
global ADDR_CPED_MONEY := 0xB7CE50
global ADDR_CPED_INTID := 0xA4ACE8
; global ADDR_CPED_PEDSTATE := 0x530
; global ADDR_CPED_RUNSTATE := 0x534
; global ADDR_CPED_ANIM_STATE := 1247
; global ADDR_CPED_ANIM_CROUCH := 1135
; global ADDR_CPED_ANIM_JUMP := 1133
; global ADDR_CPED_ANIM_GEN := 348

;GTA Car Addresses
global ADDR_VEHICLE_HPOFF := 0x4C0
Expand All @@ -55,7 +49,6 @@ global ADDR_CVEH_BIKE := 0x6C8
global ADDR_CVEH_BIKE_FTIRE := 0x65E
global ADDR_CVEH_BIKE_RTIRE := 0x65F


;GTA Enviroment Addresses
global ADDR_CURRENT_WEATHER := 0xC81320
global ADDR_CURRENT_GRAVITY := 0x863984
Expand All @@ -68,8 +61,6 @@ global ADDR_POSITION_Z := 0xB6F2EC
global ADDR_MOUSE_SENS := 0xB6EC1C
global ADDR_HBAR_COLOR := 0xBAB22C
global ADDR_MFONT_COLOR := 0xBAB230
; global ADDR_TEXT_BSTUNT := 0xBAB040
; global ADDR_TEXT_TMIDDLE := 0xBAAEC0
global ADDR_MENU_CID := 0x15D
global ADDR_MENU_IHOVER := 0x78D
global ADDR_MENU_SELECT := 0x54
Expand All @@ -80,6 +71,7 @@ global ADDR_MENU_MAPY := 0x6C
global ADDR_MENU_PLAYINMENU := 0x5C

; GTA Gun Addresses
global ADDR_GUN_RECOIL := 0x858CEC
global ADDR_CPED_GUN := 0x740
global ADDR_CPED_PISTOLAMMO := 0x5E0
global ADDR_CPED_SHOTGUNAMMO := 0x5FC
Expand Down Expand Up @@ -162,7 +154,7 @@ global bCheckSizeOnce := 1
; # - getUsername() get local player name #
; # - getId() get local player id #
; # - sendChatMessage(wText) send a message to the server #
; # - getLastChatMessage() get the last message added to the ChatBox #
; # - getLastChatMessage() get the last message added to the ChatBox #
; # - addMessageToChatWindow(wText) add a "private" text to the chatbox #
; # - showGameText(wText, dwTime, dwTextsize) show a text on the sreen #
; # - showDialog(dwStyle, wCaption, show a dialog-box #
Expand Down Expand Up @@ -194,6 +186,11 @@ global bCheckSizeOnce := 1
; # - getPlayerInteriorId() get interior id #
; # - getPlayerMoney() get player money #
; #####################################################################################################################
; # Gun Functions : #
; # - editRecoil() changes the recoil/spread #
; # - getGunType() gets the type of gun the local player has in hand. #
; # - getGunAmmo() gets the current ammo in the gun in hand. #
; #####################################################################################################################
; # Vehicle Functions: #
; # - isPlayerInAnyVehicle() check if the local player is inside some vehicle #
; # - isPlayerDriver() check if player is driver #
Expand Down Expand Up @@ -325,7 +322,8 @@ sendChatMessage(wText) {
getLastChatMessage(){
if(!checkHandles())
return ""
dwAddress := dwSAMP + ADDR_SAMP_CHATMSG_PTR

dwAddress := dwSAMP + ADDR_SAMP_CHATMSG_PTR
currentAddress := readDWORD(hGTA, dwAddress) + SAMP_LAST_CHAT_MESSAGE_OFFSET
if(ErrorLevel) {
ErrorLevel := ERROR_READ_MEMORY
Expand Down Expand Up @@ -1401,6 +1399,16 @@ GetChatLine(Line, ByRef Output, timestamp=0, color=0)
output := RegExReplace(output, "Ui)\{[a-f0-9]{6}\}")
return
}

; -1 = Error
editRecoil(wValue)
{
if(!checkHandles())
return -1

writeFloat(hGTA, ADDR_GUN_RECOIL, wValue)
}

;##################################################

/*
Expand Down Expand Up @@ -2058,6 +2066,30 @@ readFloat(hProcess, dwAddress) {
return NumGet(dwRead, 0, "Float")
}

;internal Stuff
writeFloat(hProcess, dwAddress, dwValue) {
if(!hProcess) {
ErrorLevel := ERROR_INVALID_HANDLE
return 0
}

VarSetCapacity(dwWrite, 4) ; float = 4
dwRet := DllCall( "WriteProcessMemory"
, "UInt", hProcess
, "UInt", dwAddress
, "Float*", dwValue
, "Uint", 4
, "Uint*", 0)
if(dwRet == 0) {
ErrorLevel := ERROR_WRITE_MEMORY
return 0
}

ErrorLevel := ERROR_OK
return 1
}


; internal stuff
readDWORD(hProcess, dwAddress) {
if(!hProcess) {
Expand All @@ -2081,6 +2113,30 @@ readDWORD(hProcess, dwAddress) {
return NumGet(dwRead, 0, "UInt")
}

; internal stuff
writeDWORD(hProcess, dwAddress, dwValue) {
if(!hProcess) {
ErrorLevel := ERROR_INVALID_HANDLE
return 0
}

VarSetCapacity(dwWrite, 4) ; DWORD = 4
dwRet := DllCall( "WriteProcessMemory"
, "UInt", hProcess
, "UInt", dwAddress
, "Str*", dwValue
, "Uint", 4
, "Uint*", 0)
if(dwRet == 0) {
ErrorLevel := ERROR_WRITE_MEMORY
return 0
}

ErrorLevel := ERROR_OK
return 1
}


; internal stuff
readMem(hProcess, dwAddress, dwLen=4, type="UInt") {
if(!hProcess) {
Expand Down

0 comments on commit be0d599

Please sign in to comment.