diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0a04128 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 998248c..0000000 --- a/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019 Kessec / The SAMPAHK Team - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index 874b365..248fa67 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -## SAMPAHK (0.3.0) +## SAMPAHK (0.8.0) +## SAM (0.6.0) + Based off: [SAMPUDF](https://github.com/paul-phoenix/SAMP-UDF-for-AutoHotKey) by paul-phoenix @@ -6,7 +8,7 @@ Based off: [SAMPUDF](https://github.com/paul-phoenix/SAMP-UDF-for-AutoHotKey) by ### Synopsis -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. +SAMPAHK is an API specifically made to be used inside of [AutoHotKey](https://www.ahkscript.org). A part 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/) and Version 1 of the GTA SA Executable._ diff --git a/SAM.ahk b/SAM.ahk new file mode 100644 index 0000000..460fe6a --- /dev/null +++ b/SAM.ahk @@ -0,0 +1,69 @@ +; /$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$ /$$ +; /$$__ $$ /$$__ $$| $$$ /$$$| $$__ $$ /$$__ $$| $$ | $$| $$ /$$/ +;| $$ \__/| $$ \ $$| $$$$ /$$$$| $$ \ $$| $$ \ $$| $$ | $$| $$ /$$/ +;| $$$$$$ | $$$$$$$$| $$ $$/$$ $$| $$$$$$$/| $$$$$$$$| $$$$$$$$| $$$$$/ +; \____ $$| $$__ $$| $$ $$$| $$| $$____/ | $$__ $$| $$__ $$| $$ $$ +; /$$ \ $$| $$ | $$| $$\ $ | $$| $$ | $$ | $$| $$ | $$| $$\ $$ +;| $$$$$$/| $$ | $$| $$ \/ | $$| $$ | $$ | $$| $$ | $$| $$ \ $$ +; \______/ |__/ |__/|__/ |__/|__/ |__/ |__/|__/ |__/|__/ \__/ +; +; ################################ +; https://github.com/kessec/SAMPAHK +; ################################ + +; UPDATE THIS OR YOUR MERGE WILL BE CLOSED. +Version := "SAM CORE VERSION: 0.6.0" + +#NoEnv +SendMode Input +SetWorkingDir %A_ScriptDir% +#IfWinActive GTA:SA:MP +#Persistent + +PIDS := Array() +Names := Array() +logLoc = %A_ScriptDir%\log.txt + +FormatTime, tsVar, T12, Time +FileDelete, %logLoc% +FileAppend,/$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$ /$$`n/$$__ $$ /$$__ $$| $$$ /$$$| $$__ $$ /$$__ $$| $$ | $$| $$ /$$/`n| $$ \__/| $$ \ $$| $$$$ /$$$$| $$ \ $$| $$ \ $$| $$ | $$| $$ /$$/`n| $$$$$$ | $$$$$$$$| $$ $$/$$ $$| $$$$$$$/| $$$$$$$$| $$$$$$$$| $$$$$/`n\____ $$| $$__ $$| $$ $$$| $$| $$____/ | $$__ $$| $$__ $$| $$ $$`n/$$ \ $$| $$ | $$| $$\ $ | $$| $$ | $$ | $$| $$ | $$| $$\ $$`n| $$$$$$/| $$ | $$| $$ \/ | $$| $$ | $$ | $$| $$ | $$| $$ \ $$`n\______/ |__/ |__/|__/ |__/|__/ |__/ |__/|__/ |__/|__/ \__/ `n, %logLoc% +FileAppend, %Version%`n, %logLoc% +FileReadLine, cVersion, %A_ScriptDir%\sam_mods\SAMP.ahk, 17 +FileAppend, %cVersion%`n`n, %logLoc% +FileAppend, %tsVar%: SAM Core successfully loaded.`n, %logLoc% + +Sleep, 20000 +Loop, %A_ScriptDir%\sam_mods\*.ahk{ + Run, %A_LoopFileFullPath% ,,, vPID + SplitPath % A_LoopFileFullPath,,,, name + Names.push(name) + FormatTime, tsVar, T12, Time + FileAppend, %tsVar%: %name% successfully loaded.`n, %logLoc% + PIDS.push(vPID) + } + +Loop, %A_ScriptDir%\sam_mods\*.exe{ + Run, %A_LoopFileFullPath% + SplitPath % A_LoopFileFullPath, name + Names.push(name) + FormatTime, tsVar, T12, Time + FileAppend, %tsVar%: %name% successfully loaded.`n, %logLoc% + PIDS.push(vPID) +} + +while(true) +{ + if(!WinExist("GTA:SA:MP")){ + Loop % PIDS.Length() + { + FormatTime, tsVar, T12, Time + vTemp := PIDS[A_Index] + vName := Names[A_Index] + FileAppend, %tsVar%: %vName% sucessfully closed.`n, %logLoc% + Process, Close, %vTemp% + } + FormatTime, tsVar, T12, Time + FileAppend, %tsVar%: SAM Core sucessfully closed.`n, %logLoc% + ExitApp +} +} diff --git a/SAMP.ahk b/SAMP.ahk index b85de16..f97ecb8 100644 --- a/SAMP.ahk +++ b/SAMP.ahk @@ -1,10 +1,21 @@ -; #### SAMPAHK #### -; https://github.com/kessec/SAMPAHK -; #################### -; UPDATE THIS OR YOUR MERGE WILL BE CLOSED. -; SOFTWARE VERSION: 0.3.0 +; /$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$ /$$ +; /$$__ $$ /$$__ $$| $$$ /$$$| $$__ $$ /$$__ $$| $$ | $$| $$ /$$/ +;| $$ \__/| $$ \ $$| $$$$ /$$$$| $$ \ $$| $$ \ $$| $$ | $$| $$ /$$/ +;| $$$$$$ | $$$$$$$$| $$ $$/$$ $$| $$$$$$$/| $$$$$$$$| $$$$$$$$| $$$$$/ +; \____ $$| $$__ $$| $$ $$$| $$| $$____/ | $$__ $$| $$__ $$| $$ $$ +; /$$ \ $$| $$ | $$| $$\ $ | $$| $$ | $$ | $$| $$ | $$| $$\ $$ +;| $$$$$$/| $$ | $$| $$ \/ | $$| $$ | $$ | $$| $$ | $$| $$ \ $$ +; \______/ |__/ |__/|__/ |__/|__/ |__/ |__/|__/ |__/|__/ \__/ +; +; ################################ +; https://github.com/kessec/SAMPAHK +; ################################ +; KEEP THE VERSION TEXT AT LINE 17 OR YOUR MERGE WILL BE CLOSED. +/* +SAMPAHK VERSION: 0.8.0 +*/ ; ErrorLevels global ERROR_OK := 0 @@ -23,7 +34,11 @@ global ERROR_WAIT_FOR_OBJECT := 12 global ERROR_CREATE_THREAD := 13 -;GTA Control Block Addresses +; Address Styling: +; Similar to this: ADDR_POINTER_INFO +; Example: ADDR_CPED_HPOFF is dependent on the CPED pointer and is the offset for HP information. + +; GTA Control Block Addresses global ADDR_CPED_PTR := 0xB6F5F0 global ADDR_VEHICLE_PTR := 0xBA18FC global ADDR_CVEH_PTR := 0xB6F980 @@ -37,7 +52,8 @@ global ADDR_CPED_ARMOROFF := 0x548 global ADDR_CPED_MONEY := 0xB7CE50 global ADDR_CPED_INTID := 0xA4ACE8 -;GTA Car Addresses + +; GTA Car Addresses global ADDR_VEHICLE_HPOFF := 0x4C0 global ADDR_VEHICLE_DOORSTATE := 0x4F8 global ADDR_VEHICLE_ENGINESTATE := 0x428 @@ -49,13 +65,18 @@ global ADDR_CVEH_BIKE := 0x6C8 global ADDR_CVEH_BIKE_FTIRE := 0x65E global ADDR_CVEH_BIKE_RTIRE := 0x65F -;GTA Enviroment Addresses + +; GTA Enviroment Addresses global ADDR_CURRENT_WEATHER := 0xC81320 global ADDR_CURRENT_GRAVITY := 0x863984 global ADDR_ZONECODE := 0xA49AD4 global ADDR_POSITION_X := 0xB6F2E4 global ADDR_POSITION_Y := 0xB6F2E8 global ADDR_POSITION_Z := 0xB6F2EC +global ADDR_CPED_X_OFF := 0x30 +global ADDR_CPED_Y_OFF := 0x34 +global ADDR_CPED_Z_OFF := 0x38 +global ADDR_CPED_ROTZ := 0x558 ; GTA Menu Addresses global ADDR_MOUSE_SENS := 0xB6EC1C @@ -72,7 +93,7 @@ global ADDR_MENU_PLAYINMENU := 0x5C ; GTA Gun Addresses global ADDR_GUN_RECOIL := 0x858CEC -global ADDR_CPED_GUN := 0x740 +global ADDR_CPED_GUN_TYPE := 0x740 global ADDR_CPED_PISTOLAMMO := 0x5E0 global ADDR_CPED_SHOTGUNAMMO := 0x5FC ; global ADDR_GUN_TYPE := 00 @@ -80,7 +101,11 @@ global ADDR_CPED_SHOTGUNAMMO := 0x5FC ; global ADDR_GUN_AMMO := 08 ; global ADDR_GUN_RAMMO := 12 -;GTA Misc. Addresses +; GTA Cheat Addresses +global ADDR_CHEAT_INFRUN := 0xB7CEE4 + + +; GTA Misc. Addresses global ADDR_GARAGE_DOORSTATE := 0x4D @@ -185,6 +210,12 @@ global bCheckSizeOnce := 1 ; # - getPlayerArmor() get ARMOR # ; # - getPlayerInteriorId() get interior id # ; # - getPlayerMoney() get player money # +; # - getPlayerRotation() get the rotation of the player. # +; ##################################################################################################################### +; # 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. # ; ##################################################################################################################### ; # Gun Functions : # ; # - editRecoil() changes the recoil/spread # @@ -206,6 +237,7 @@ global bCheckSizeOnce := 1 ; ##################################################################################################################### ; # Coordinates: # ; # - getCoordinates() get local player's position # +; # - getTargetPedCoordinates() get targeted player's position # ; # ----------------------------------------------------------------------------------------------------------------- # ; # - calculateZone(X, Y, Z) get zone # ; # - calculateCity(X, Y, Z) get city # @@ -221,7 +253,6 @@ global bCheckSizeOnce := 1 ; # - refreshGTA() # ; # - refreshSAMP() # ; # - refreshMemory() # -; # - isGameIntialized() -WORK IN PROGRESS- # ; # - getPID(szWindow) # ; # - openProcess(dwPID, dwRights) # ; # - closeProcess(hProcess) # @@ -231,6 +262,9 @@ global bCheckSizeOnce := 1 ; # - readDWORD(hProcess, dwAddress) # ; # - readMem(hProcess, dwAddress, dwLen=4, type="UInt") # ; # - writeString(hProcess, dwAddress, wString) # +; # - writeFloat(hProcess, dwAddress, dwValue) # +; # - writeDWORD(hProcess, dwAddress, dwValue) # +; # - writeMem(hProcess, dwAddress, dwValue, dwLen=4, type="UInt") # ; # - writeRaw(hProcess, dwAddress, data, dwLen) # ; # - callWithParams(hProcess, dwFunc, aParams, bCleanupStack = true) # ; # - virtualAllocEx(hProcess, dwSize, flAllocationType, flProtect) # @@ -242,8 +276,7 @@ global bCheckSizeOnce := 1 ; # - __unicodeToAnsi(wString, nLen = 0) # ; ##################################################################################################################### ; # Debug Functions: # -; # - sendToDebug(tString) # -; # - logDebug() # +; # - sendToDebug(tString) # # ; ##################################################################################################################### ; ##### SAMP-Functions ##### @@ -969,6 +1002,34 @@ getPlayerMoney() { return money } + +; Creates an object that stores the Z rotation. +; Example +; o := getPlayerRotation() +; o[1] := Z in Rotation Matrix +; o[2] := Z in Degrees + + getPlayerRotation() { + if(!checkHandles()) + return -1 + + dwCPedPtr := readDWORD(hGTA, ADDR_CPED_PTR) + if(ErrorLevel) { + ErrorLevel := ERROR_READ_MEMORY + return -1 + } + + dwAddr := dwCPedPtr + ADDR_CPED_ROTZ + fRot := readFloat(hGTA, dwAddr) + if(ErrorLevel) { + ErrorLevel := ERROR_READ_MEMORY + return -1 + } + + ErrorLevel := ERROR_OK + return [fRot, fRot * -55.77] + } + ; ##### Vehicle Functions ##### ; 1 = local player is inside a vehicle @@ -1238,6 +1299,53 @@ getCoordinates() { return [fX, fY, fZ] } +; returns an object which contains targeted players position +; returns an empty string on error +; example: +; o := getTargetPedCoordinates() +; o[1] //x pos +; o[2] //y pos +; o[3] //z pos +getTargetPedCoordinates(){ + if(!checkHandles()) + return "" + + dwCPedPtr := getTargetPed() + if(ErrorLevel) { + ErrorLevel := ERROR_READ_MEMORY + return "" + } + + dwAddressPos := readDword(hGTA, dwCPedPtr + 0x14) + dwAddressX := dwAddressPos + ADDR_CPED_X_OFF + dwAddressY := dwAddressPos + ADDR_CPED_Y_OFF + dwAddressZ := dwAddressPos + ADDR_CPED_Z_OFF + + tpX := readFloat(hGTA, dwAddressX) + if(ErrorLevel) { + ErrorLevel := ERROR_READ_MEMORY + return "" + } + + tpY := readFloat(hGTA, dwAddressY) + if(ErrorLevel) { + ErrorLevel := ERROR_READ_MEMORY + return "" + } + + + tpZ := readFloat(hGTA, dwAddressZ) + if(ErrorLevel) { + ErrorLevel := ERROR_READ_MEMORY + return "" + } + + + ErrorLevel := ERROR_OK + return [tpX, tpY, tpZ] + } + + ; pass coordinates to get a zone name or get an empty string on error calculateZone(posX, posY, posZ) { posX += 0 @@ -1303,52 +1411,11 @@ calculateCity(posX, posY, posZ) { ; sends a string to the debug text file, good for checking if chunks of code work. (Included due to ease of access for me.) sendToDebug(tString){ -dbLoc = %A_ScriptDir%\debug.txt - -FormatTime, tsVar, R -FileAppend, -( -%tsVar% -%tString% - -), %dbLoc% -} - -; logging basic debugging information (Work In Progress) -logDebug(){ -dbLoc = %A_ScriptDir%\debug.txt -uN := getUsername() -gC := getCoordinates() -gPH := getPlayerHealth() -iPD := isPlayerDriver() -gVT := getVehicleType() -gVHI := getVehicleModelId() -gIP := getIP() -FormatTime, tsVar, T12, Time - -FileAppend, -( -%tsVar% -%uN%, %gC%, %gPH%, %iPD%, %gVT%, %gVHI%, %gIP% -ER = %ErrorLevel% - +logLoc = %A_ScriptDir%\..\log.txt -), %dbLoc% +FormatTime, tsVar, T12, Time +FileAppend, %tsVar%: %tString%.`n, %logLoc% } -return - -; uses checkHandles() to check if the game is initalized. (Work In Progress) -isGameIntialized(){ - if(!checkHandles()) - { - SendtoDebug("S1, IGI, F-cHC") - return false - } else { - SendtoDebug("S1, IGI, S-cHC") - return true - } - } -return ;By GoodBlokeAri aka David_Luchs getTargetPed() @@ -1400,13 +1467,46 @@ GetChatLine(Line, ByRef Output, timestamp=0, color=0) return } -; -1 = Error +; -1 = Error checking handles. +; -2 = In plane. editRecoil(wValue) { if(!checkHandles()) return -1 + + if(getVehicleType() = 5) + return -2 writeFloat(hGTA, ADDR_GUN_RECOIL, wValue) + return +} + + +; Retrieves the gun type you are currently holding. +; EXAMPLES: +; 92 = Deagle +; 97 = MP5 +; -1 = Fist +; -2 = Error +getGunType() +{ + if(!checkHandles()) + return -2 + + dwCPedPtr := readDWORD(hGTA, ADDR_CPED_PTR) + if(ErrorLevel) { + ErrorLevel := ERROR_READ_MEMORY + return -2 + } + + dwGunType := readMem(hGta, dwCpedPtr + ADDR_CPED_GUN_TYPE, 4, "Char") + if(ErrorLevel) { + ErrorLevel := ERROR_READ_MEMORY + return -2 + } + + ErrorLevel := ERROR_OK + return dwGunType } ;################################################## @@ -1815,6 +1915,7 @@ initZonesAndCities() { AddZone("Las Venturas", 869.461, 596.349, -242.990, 2997.060, 2993.870, 900.000) AddZone("Red County", -1213.910, -768.027, -242.990, 2997.060, 596.349, 900.000) AddZone("Los Santos", 44.615, -2892.970, -242.990, 2997.060, -768.027, 900.000) + return } ; internal stuff @@ -1828,6 +1929,7 @@ AddZone(sName, x1, y1, z1, x2, y2, z2) { zone%nZone%_y2 := y2 zone%nZone%_z2 := z2 nZone := nZone + 1 + return } ; internal stuff @@ -1841,6 +1943,7 @@ AddCity(sName, x1, y1, z1, x2, y2, z2) { city%nCity%_y2 := y2 city%nCity%_z2 := z2 nCity := nCity + 1 + return } ; ##### Memory Stuff ##### @@ -2160,6 +2263,29 @@ readMem(hProcess, dwAddress, dwLen=4, type="UInt") { return NumGet(dwRead, 0, type) } +;interal stuff +writeMem(hProcess, dwAddress, dwValue, dwLen=4, type="UInt") { + if(!hProcess) { + ErrorLevel := ERROR_INVALID_HANDLE + return 0 + } + + VarSetCapacity(dwRead, dwLen) + dwRet := DllCall( "WriteProcessMemory" + , "UInt", hProcess + , "UInt", dwAddress + , "Str*", dwValue + , "UInt", dwLen + , "UInt*", 0) + if(dwRet == 0) { + ErrorLevel := ERROR_READ_MEMORY + return 0 + } + + ErrorLevel := ERROR_OK + return NumGet(dwRead, 0, type) +} + ; internal stuff writeString(hProcess, dwAddress, wString) { if(!hProcess) { @@ -2426,3 +2552,5 @@ __unicodeToAnsi(wString, nLen = 0) { , "Uint", 0) return sString } + +return diff --git a/SAMPTest.ahk b/SAMPTest.ahk deleted file mode 100644 index fe7a51a..0000000 --- a/SAMPTest.ahk +++ /dev/null @@ -1,126 +0,0 @@ -SendMode Input -SetWorkingDir %A_ScriptDir% -#Warn -#UseHook -#NoEnv -#SingleInstance force -#include %A_ScriptDir%\SAMP.ahk - -Hotkey, Enter, Off -Hotkey, Escape, Off - -bchat:=0 -return - -+T:: -~t:: -Suspend On -Hotkey, Enter, On -Hotkey, Escape, On -Hotkey, t, Off -return - -~NumpadEnter:: -~Enter:: -Suspend Permit -Suspend Off -Hotkey, t, On -Hotkey, Enter, Off -Hotkey, Escape, Off -return - -~Escape:: -Suspend Permit -Suspend Off -Hotkey, t, On -Hotkey, Enter, Off -Hotkey, Escape, Off -return - - -;######################################################################################################### - - -;Type in a nickname and it shows some info about this player -Numpad1:: -SendInput tName:{Space} -Suspend On -Hotkey, Enter, On -Hotkey, Escape, On -Input varName, V I M,{enter} -SendInput {end}+{home}{Del}{esc} -varID := getPlayerIdByName(varName) -showGameText(getPlayerNameById(varID) "~n~Score: " getPlayerScoreById(varID) "~n~Ping: " getPlayerPingById(varID), 2000, 5) -return - -;Type in a ID and it shows some info about this player -Numpad2:: -SendInput tID:{Space} -Suspend On -Hotkey, Enter, On -Hotkey, Escape, On -Input varID, V I M,{enter} -SendInput {end}+{home}{Del}{esc} -;updateScoreboardData() ;wird nun implizit aufgerufen -showGameText(getPlayerNameById(varID) "~n~Score: " getPlayerScoreById(varID) "~n~Ping: " getPlayerPingById(varID) "~n~IsNPC: " isNPCById(varID), 2000, 5) -return - -;play an "audio stream" -Numpad3:: -playAudioStream("http://breakz.us/radio/listen.pls") -return - -;stopp an "audio stream" -Numpad4:: -stopAudioStream() -return - -;show some info about the local player, use some functions -Numpad5:: -if ( isInChat() ) - return -addMessageToChatWindow("{FFFFFF}IP: {FF0000}" getIP() "{FFFFFF}, Hostname: {FF0000}" getHostname()) -addMessageToChatWindow("{FFFFFF}Players: {FF0000}" countOnlinePlayers()) -addMessageToChatWindow("{FFFFFF}Name: {FF0000}" getUsername()) -addMessageToChatWindow("{FFFFFF}HP: {FF0000}" getPlayerHealth() "{FFFFFF}, ARMOR: {FF0000}" getPlayerArmor()) -addMessageToChatWindow("{FFFFFF}Money: {FF0000}" getPlayerMoney()) -addMessageToChatWindow("{FFFFFF}Interior id: {FF0000}" getPlayerInteriorId()) -pos := getCoordinates() -addMessageToChatWindow("{FFFFFF}Zone: {FF0000}" calculateZone(pos[1],pos[2],pos[3]) "{FFFFFF}, Stadt: {FF0000}" calculateCity(pos[1],pos[2],pos[3])) -sendChatMessage("blub") -sendChatMessage("/asd") -showGameText("test", 2000, 5) -return - -;shows a dialog-box -Numpad6:: -showDialog(5, "Titel", "Weapon`tPrice`tAmmo`nDeagle`t$5000`t100`nSawnoff`t$5000`t100`nPistol`t$1000`t50", "OK" ) -return - -;show some info about the current vehicle -Numpad7:: -addMessageToChatWindow("{FFFFFF}Vehicle Type:" getVehicleType()) -addMessageToChatWindow("{FFFFFF}Model:" getVehicleModelId()) -addMessageToChatWindow("{FFFFFF}Model Name:" getVehicleModelName()) -addMessageToChatWindow("{FFFFFF}Is Driver:" isPlayerDriver()) -addMessageToChatWindow("{FFFFFF}Light State:" getVehicleLightState()) -addMessageToChatWindow("{FFFFFF}Engine State:" getVehicleEngineState()) -addMessageToChatWindow("{FFFFFF}Door State:" getVehicleLockState()) -return - -Numpad8:: -addMessageToChatWindow("{FFFFFF}block chat " (bchat ? "{FF0000}off" : "{00FF00}on")) -if(bchat) - unBlockChatInput() -else - blockChatInput() -bchat:=!bchat -return - -; Sending a string to the debug.txt with sendToDebug() and logging the current conditions with logDebug() if the game is currently initalized. -NumPad9:: -init := isGameIntialized() -if(init){ -sendToDebug("Sample Text") -logDebug() -return