|
Постоянный
Регистрация: 12.01.2018
Сообщений: 963
С нами:
4387250
Репутация:
133
|
|
Пытаюсь переделать свой скрипт в аси формат. Все сделал, кроме нормальной эмуляции игровых клавиш. Нынешняя эмуляция работает через раз.
Сообщение от Спойлер
C++:
Код:
#include "main.h"
void
__cdecl
thread
(
void
*
pArg
)
{
while
(
true
)
{
Sleep
(
1
)
;
if
(
isKeyDown
(
0x31
)
)
{
if
(
IsCharOnFoot
(
)
)
{
SetGameKeyState
(
0x20
,
255
)
;
Sleep
(
10
)
;
SetGameKeyState
(
0x20
,
0
)
;
GTAfunc_showStyledText
(
"ON FOOT"
,
2000
,
1
)
;
}
}
if
(
isKeyDown
(
0xA0
)
)
{
if
(
IsCharInAnyCar
(
)
)
{
type
=
CurrentVehicleModelType
(
)
;
if
(
type
==
1
)
{
SetGameKeyState
(
0x20
,
255
)
;
Sleep
(
10
)
;
SetGameKeyState
(
0x20
,
0
)
;
GTAfunc_showStyledText
(
"ON BIKE"
,
2000
,
1
)
;
}
else
if
(
type
==
2
)
{
SetGameKeyState
(
0x2
,
-
128
)
;
Sleep
(
10
)
;
SetGameKeyState
(
0x2
,
0
)
;
GTAfunc_showStyledText
(
"ON MOTO"
,
2000
,
1
)
;
}
}
}
}
}
BOOL APIENTRY
DllMain
(
HINSTANCE hinstDLL
,
DWORD fdwReason
,
LPVOID lpReserved
)
{
if
(
fdwReason
==
DLL_PROCESS_ATTACH
)
{
_beginthread
(
thread
,
0
,
nullptr
)
;
return
TRUE
;
}
}
Сообщение от Спойлер
C++:
Код:
#include
#include
#include
DWORD CPed
=
0xB6F5F0
;
DWORD CPedStatus
=
0x530
;
DWORD ProcID
;
DWORD p1
;
HANDLE hProcess
;
unsigned
int
CurrentVehiclePointer
=
0xBA18FC
;
int
Model
=
0
;
int
Status
=
0
;
int
type
;
unsigned
long
temp
;
int
bike
[
3
]
=
{
481
,
509
,
510
}
;
int
moto
[
11
]
=
{
448
,
461
,
462
,
463
,
468
,
471
,
521
,
522
,
523
,
581
,
586
}
;
using
namespace
std
;
DWORD
GetProcId
(
const
char
*
procname
)
{
PROCESSENTRY32 pe
;
HANDLE hSnap
;
pe
.
dwSize
=
sizeof
(
PROCESSENTRY32
)
;
hSnap
=
CreateToolhelp32Snapshot
(
TH32CS_SNAPPROCESS
,
NULL
)
;
if
(
Process32First
(
hSnap
,
&
pe
)
)
{
do
{
if
(
strcmp
(
pe
.
szExeFile
,
procname
)
==
0
)
break
;
}
while
(
Process32Next
(
hSnap
,
&
pe
)
)
;
}
return
pe
.
th32ProcessID
;
}
void
SetGameKeyState
(
BYTE key
,
BYTE state
)
{
p1
=
0xB73458
+
key
;
memset
(
(
void
*
)
p1
,
state
,
1
)
;
}
;
bool
isKeyDown
(
int
key
)
{
SHORT keyState
=
GetKeyState
(
key
)
;
return
(
keyState
&
0x8000
)
;
}
void
GTAfunc_showStyledText
(
const
char
*
text
,
int
time
,
int
style
)
{
(
(
void
(
__cdecl
*
)
(
const
char
*
text
,
int
time
,
int
style
)
)
(
0x0069F2B0
)
)
(
text
,
time
,
style
)
;
}
int
CurrentPedStatus
(
)
{
ProcID
=
GetProcId
(
"gta_sa.exe"
)
;
hProcess
=
OpenProcess
(
PROCESS_ALL_ACCESS
,
FALSE
,
ProcID
)
;
ReadProcessMemory
(
hProcess
,
reinterpret_cast
(
CPed
)
,
&
temp
,
sizeof
(
temp
)
,
0
)
;
CPedStatus
=
temp
+
0x530
;
ReadProcessMemory
(
hProcess
,
reinterpret_cast
(
CPedStatus
)
,
&
Status
,
sizeof
(
temp
)
,
0
)
;
return
Status
;
}
bool
IsCharInAnyCar
(
)
{
Status
=
CurrentPedStatus
(
)
;
if
(
Status
==
50
)
{
return
true
;
}
else
{
return
false
;
}
}
bool
IsCharOnFoot
(
)
{
Status
=
CurrentPedStatus
(
)
;
if
(
Status
==
1
)
{
return
true
;
}
else
{
return
false
;
}
}
int
CurrentVehicleModelType
(
)
{
unsigned
int
CurrentVehiclePointer
=
*
(
unsigned
int
*
)
0xBA18FC
;
unsigned
short
model
=
*
(
unsigned
short
*
)
(
CurrentVehiclePointer
+
34
)
;
if
(
IsCharInAnyCar
(
)
)
{
for
(
int
counter
=
0
;
counter
NULL
)
kPressingKeys
[
Key
]
.
dwStartTime
=
GetTickCount
(
)
;
return
TRUE
;
}
}
else
kPressingKeys
[
Key
]
.
bPressed
=
FALSE
;
return
FALSE
;
}
|