Hello,
i want to check if the player is spawned and i found this code in an autohotkey script and tried to convert it into c++ but with no success. I hope that someone can explain to me how to convert code such like this. Btw i am new at coding and learning c++.
all informations to this code
i want to check if the player is spawned and i found this code in an autohotkey script and tried to convert it into c++ but with no success. I hope that someone can explain to me how to convert code such like this. Btw i am new at coding and learning c++.
Code:
isPlayerSpawned() {
return checkHandles() && __DWORD(hGTA, dwSAMP, [SAMP_INFO_PTR, SAMP_POOLS, SAMP_POOL_PLAYER, SAMP_LOCALPLAYER, 0x136])
}
all informations to this code
Code:
global dwSAMP := 0x0
global SAMP_INFO_PTR := 0x21A0F8
global SAMP_POOLS := 0x3CD
global SAMP_POOL_PLAYER := 0x18
global SAMP_LOCALPLAYER := 0x22
checkHandles() {
return !refreshGTA() || !refreshSAMP() || !refreshMemory() ? false : true
}
refreshGTA() {
if (!(newPID := getPID("GTA:SA:MP"))) {
if (hGTA) {
virtualFreeEx(hGTA, pMemory, 0, 0x8000)
closeProcess(hGTA)
}
dwGTAPID := 0, hGTA := 0x0, dwSAMP := 0x0, pMemory := 0x0
return false
}
if (!hGTA || dwGTAPID != newPID) {
if (!(hGTA := openProcess(newPID))) {
dwGTAPID := 0, hGTA := 0x0, dwSAMP := 0x0, pMemory := 0x0
return false
}
dwGTAPID := newPID, dwSAMP := 0x0, pMemory := 0x0
}
return true
}
refreshSAMP() {
if (dwSAMP)
return true
dwSAMP := getModuleBaseAddress("samp.dll", hGTA)
if (!dwSAMP)
return false
if (__READMEM(hGTA, dwSAMP, [0x1036], "UChar") != 0xD8) {
msgbox, 64, % "SA:MP Version not compatible", % "use 0.3.7"
ExitApp
}
return true
}
refreshMemory() {
if (!pMemory) {
pMemory := virtualAllocEx(hGTA, 6384, 0x1000 | 0x2000, 0x40)
if (ErrorLevel) {
pMemory := 0x0
return false
}
pInjectFunc := pMemory + 5120
pDetours := pInjectFunc + 1024
}
return true
}
__DWORD(hProcess, dwAddress, offsets) {
if (!hProcess || !dwAddress)
return ""
VarSetCapacity(dwRead, 4)
for i, o in offsets {
dwRet := DllCall("ReadProcessMemory", "UInt", hProcess, "UInt", dwAddress + o, "Str", dwRead, "UInt", 4, "UInt*", 0)
if (!dwRet)
return ""
dwAddress := NumGet(dwRead, 0, "UInt")
}
return dwAddress
}