HOME FORUMS MEMBERS RECENT POSTS LOG IN  
× Авторизация
Имя пользователя:
Пароль:
Нет аккаунта? Регистрация
Баннер 1   Баннер 2
НОВЫЕ ТОРГОВАЯ НОВОСТИ ЧАТ
loading...
Скрыть
Вернуться   ANTICHAT > ПРОГРАММИРОВАНИЕ > С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby
   
Ответ
 
Опции темы Поиск в этой теме Опции просмотра

  #1  
Старый 30.06.2024, 23:07
yoonost
Познающий
Регистрация: 21.01.2019
Сообщений: 62
С нами: 3847510

Репутация: 58
По умолчанию

Цитата:
Сообщение от ARMOR  

GitHub - xARMORx/SAMP-EmptyProject: Empty project for writing .asi plugins for GTA San Andreas and SAMP

Empty project for writing .asi plugins for GTA San Andreas and SAMP - xARMORx/SAMP-EmptyProject

github.com


Тут юзается
спасибо большое, думал что нужно его скачивать и билдить но оказалось все проще чем я думал

В чем проблема? Во время прорисовки радара крашит игру, пробовал сделать многое но результат один. В коде сейчас стандартный код gta_sa.exe но даже при этом происходит краш



 
Ответить с цитированием

  #2  
Старый 01.07.2024, 14:37
AdCKuY_DpO4uLa
Постоянный
Регистрация: 05.08.2018
Сообщений: 372
С нами: 4091290

Репутация: 213
По умолчанию

полный код кинь
 
Ответить с цитированием

  #3  
Старый 01.07.2024, 14:42
yoonost
Познающий
Регистрация: 21.01.2019
Сообщений: 62
С нами: 3847510

Репутация: 58
По умолчанию

Цитата:
Сообщение от AdCKuY_DpO4uLa  

полный код кинь
radar.cpp:





Код:
#include "radar.h"

void radar::initialize() {
    hookTransformPos.set_dest(0x583480);
    hookTransformPos.set_cb(std::bind(&radar::transformPos, this, _1, _2, _3));
    hookTransformPos.install();
}

RwV2d* __cdecl radar::transformPos(const decltype(hookTransformPos)& hook, CVector2D* out, CVector2D* in) {
    if (FrontEndMenuManager.drawRadarOrMap) {
        out->x = FrontEndMenuManager.m_fMapZoom * in->x + FrontEndMenuManager.m_fMapBaseX;
        out->y = FrontEndMenuManager.m_fMapBaseY - FrontEndMenuManager.m_fMapZoom * in->y;
    }
    else {
        out->x = 0.5 * (94.0 * (RsGlobal.maximumWidth * 0.0015625)) + RsGlobal.maximumWidth * 0.0015625 * 40.0 + 94.0 * (RsGlobal.maximumWidth * 0.0015625) * in->x * 0.5;
        out->y = RsGlobal.maximumHeight - 0.002232143 * RsGlobal.maximumHeight * 104.0 + 76.0 * (0.002232143 * RsGlobal.maximumHeight) * 0.5 - 76.0 * (0.002232143 * RsGlobal.maximumHeight) * in->y * 0.5;
    }
    return hook.get_trampoline()(out, in);
}


radar.h:





Код:
#pragma once

#include 

#include 
#include 
#include 
#include 
#include "CMenuManager.h"

using namespace plugin;
using namespace std::placeholders;

class radar {
public:
    void initialize();

private:
    kthook::kthook_simple hookTransformPos {};
    RwV2d* __cdecl transformPos(const decltype(hookTransformPos)& hook, CVector2D* out, CVector2D* in);
};

inline radar g_radar;
 
Ответить с цитированием

  #4  
Старый 01.07.2024, 14:55
AdCKuY_DpO4uLa
Постоянный
Регистрация: 05.08.2018
Сообщений: 372
С нами: 4091290

Репутация: 213
По умолчанию

Цитата:
Сообщение от yoonost  

radar.cpp:





Код:
#include "radar.h"

void radar::initialize() {
    hookTransformPos.set_dest(0x583480);
    hookTransformPos.set_cb(std::bind(&radar::transformPos, this, _1, _2, _3));
    hookTransformPos.install();
}

RwV2d* __cdecl radar::transformPos(const decltype(hookTransformPos)& hook, CVector2D* out, CVector2D* in) {
    if (FrontEndMenuManager.drawRadarOrMap) {
        out->x = FrontEndMenuManager.m_fMapZoom * in->x + FrontEndMenuManager.m_fMapBaseX;
        out->y = FrontEndMenuManager.m_fMapBaseY - FrontEndMenuManager.m_fMapZoom * in->y;
    }
    else {
        out->x = 0.5 * (94.0 * (RsGlobal.maximumWidth * 0.0015625)) + RsGlobal.maximumWidth * 0.0015625 * 40.0 + 94.0 * (RsGlobal.maximumWidth * 0.0015625) * in->x * 0.5;
        out->y = RsGlobal.maximumHeight - 0.002232143 * RsGlobal.maximumHeight * 104.0 + 76.0 * (0.002232143 * RsGlobal.maximumHeight) * 0.5 - 76.0 * (0.002232143 * RsGlobal.maximumHeight) * in->y * 0.5;
    }
    return hook.get_trampoline()(out, in);
}


radar.h:





Код:
#pragma once

#include 

#include 
#include 
#include 
#include 
#include "CMenuManager.h"

using namespace plugin;
using namespace std::placeholders;

class radar {
public:
    void initialize();

private:
    kthook::kthook_simple hookTransformPos {};
    RwV2d* __cdecl transformPos(const decltype(hookTransformPos)& hook, CVector2D* out, CVector2D* in);
};

inline radar g_radar;

C++:





Код:
class
radar
{
private
:
kthook
::
kthook_simple

TransformRadarPointToScreenSpaceHook
{
}
;
static
void
__cdecl
TransformRadarPointToScreenSpace_HOOKED
(
const
decltype
(
TransformRadarPointToScreenSpaceHook
)
&
hook
,
CVector2D
*
out
,
CVector2D
*
in
)
;
public
:
void
initialize
(
)
;
}
g_radar
;
void
radar
::
initialize
(
)
{
TransformRadarPointToScreenSpaceHook
.
set_dest
(
0x583480
)
;
TransformRadarPointToScreenSpaceHook
.
set_cb
(
&
TransformRadarPointToScreenSpace_HOOKED
)
;
TransformRadarPointToScreenSpaceHook
.
install
(
)
;
}
void
__cdecl radar
::
TransformRadarPointToScreenSpace_HOOKED
(
const
decltype
(
TransformRadarPointToScreenSpaceHook
)
&
hook
,
CVector2D
*
out
,
CVector2D
*
in
)
{
if
(
FrontEndMenuManager
.
drawRadarOrMap
)
{
out
->
x
=
FrontEndMenuManager
.
m_fMapZoom
*
in
->
x
+
FrontEndMenuManager
.
m_fMapBaseX
;
out
->
y
=
FrontEndMenuManager
.
m_fMapBaseY
-
FrontEndMenuManager
.
m_fMapZoom
*
in
->
y
;
}
else
{
out
->
x
=
0.5
*
(
94.0
*
(
RsGlobal
.
maximumWidth
*
0.0015625
)
)
+
RsGlobal
.
maximumWidth
*
0.0015625
*
40.0
+
94.0
*
(
RsGlobal
.
maximumWidth
*
0.0015625
)
*
in
->
x
*
0.5
;
out
->
y
=
RsGlobal
.
maximumHeight
-
0.002232143
*
RsGlobal
.
maximumHeight
*
104.0
+
76.0
*
(
0.002232143
*
RsGlobal
.
maximumHeight
)
*
0.5
-
76.0
*
(
0.002232143
*
RsGlobal
.
maximumHeight
)
*
in
->
y
*
0.5
;
}
//ты ведь в тупую логику переписал?? если так, то не нужно вообще ориг. функцию вызывать, т.к. все рассчеты будут тут
return
;
}


еще я не тестил эту лабуду
 
Ответить с цитированием

  #5  
Старый 01.07.2024, 15:02
yoonost
Познающий
Регистрация: 21.01.2019
Сообщений: 62
С нами: 3847510

Репутация: 58
По умолчанию

Цитата:
Сообщение от AdCKuY_DpO4uLa  

C++:





Код:
class
radar
{
private
:
kthook
::
kthook_simple

TransformRadarPointToScreenSpaceHook
{
}
;
static
void
__cdecl
TransformRadarPointToScreenSpace_HOOKED
(
const
decltype
(
TransformRadarPointToScreenSpaceHook
)
&
hook
,
CVector2D
*
out
,
CVector2D
*
in
)
;
public
:
void
initialize
(
)
;
}
g_radar
;
void
radar
::
initialize
(
)
{
TransformRadarPointToScreenSpaceHook
.
set_dest
(
0x583480
)
;
TransformRadarPointToScreenSpaceHook
.
set_cb
(
&
TransformRadarPointToScreenSpace_HOOKED
)
;
TransformRadarPointToScreenSpaceHook
.
install
(
)
;
}
void
__cdecl radar
::
TransformRadarPointToScreenSpace_HOOKED
(
const
decltype
(
TransformRadarPointToScreenSpaceHook
)
&
hook
,
CVector2D
*
out
,
CVector2D
*
in
)
{
if
(
FrontEndMenuManager
.
drawRadarOrMap
)
{
out
->
x
=
FrontEndMenuManager
.
m_fMapZoom
*
in
->
x
+
FrontEndMenuManager
.
m_fMapBaseX
;
out
->
y
=
FrontEndMenuManager
.
m_fMapBaseY
-
FrontEndMenuManager
.
m_fMapZoom
*
in
->
y
;
}
else
{
out
->
x
=
0.5
*
(
94.0
*
(
RsGlobal
.
maximumWidth
*
0.0015625
)
)
+
RsGlobal
.
maximumWidth
*
0.0015625
*
40.0
+
94.0
*
(
RsGlobal
.
maximumWidth
*
0.0015625
)
*
in
->
x
*
0.5
;
out
->
y
=
RsGlobal
.
maximumHeight
-
0.002232143
*
RsGlobal
.
maximumHeight
*
104.0
+
76.0
*
(
0.002232143
*
RsGlobal
.
maximumHeight
)
*
0.5
-
76.0
*
(
0.002232143
*
RsGlobal
.
maximumHeight
)
*
in
->
y
*
0.5
;
}
//ты ведь в тупую логику переписал?? если так, то не нужно вообще ориг. функцию вызывать, т.к. все рассчеты будут тут
return
;
}


еще я не тестил эту лабуду
не работает, проверь у себя

логику стандартную использую для теста хука, в будущем буду под плагин делать
 
Ответить с цитированием

  #6  
Старый 10.07.2024, 20:41
delanov
Познающий
Регистрация: 11.05.2023
Сообщений: 53
С нами: 1585608

Репутация: 23
По умолчанию



Проще говоря рег каллбэка крашит игру. самп р3
 
Ответить с цитированием

  #7  
Старый 11.07.2024, 01:42
yoonost
Познающий
Регистрация: 21.01.2019
Сообщений: 62
С нами: 3847510

Репутация: 58
По умолчанию

Цитата:
Сообщение от penta  

Проще говоря рег каллбэка крашит игру. самп р3
полный код
 
Ответить с цитированием

  #8  
Старый 11.07.2024, 12:02
delanov
Познающий
Регистрация: 11.05.2023
Сообщений: 53
С нами: 1585608

Репутация: 23
По умолчанию

Цитата:
Сообщение от yoonost  

полный код
C++:





Код:
#include "main.h"
bool
isPluginInitialized
=
false
;
//std::unique_ptr pRender = nullptr;
LRESULT __stdcall
WndProcCallBack
(
SAMP
::
CallBacks
::
HookedStructs
::
stWndProcParams
*
params
)
{
if
(
isPluginInitialized
)
{
if
(
ImGui_ImplWin32_WndProcHandler
(
params
->
hWnd
,
params
->
uMsg
,
params
->
wParam
,
params
->
lParam
)
)
{
return
1
;
}
}
return
0
;
//retn null if all good
}
static
bool
isOpen
=
false
;
HRESULT __stdcall
D3DPresentHook
(
SAMP
::
CallBacks
::
HookedStructs
::
stPresentParams
*
params
)
{
if
(
isPluginInitialized
)
{
ImGui_ImplDX9_NewFrame
(
)
;
//вызывалось до инициализации имгуи, поэтому крашило
ImGui_ImplWin32_NewFrame
(
)
;
ImGui
::
NewFrame
(
)
;
if
(
isOpen
)
{
if
(
ImGui
::
Begin
(
"Тестовое меню##1337"
,
&
isOpen
,
ImGuiWindowFlags_
::
ImGuiWindowFlags_NoSavedSettings
)
)
{
static
bool
bIsDemoWindowActive
=
false
;
ImGui
::
Checkbox
(
"Демо"
,
&
bIsDemoWindowActive
)
;
if
(
bIsDemoWindowActive
)
ImGui
::
ShowDemoWindow
(
&
bIsDemoWindowActive
)
;
for
(
int
i
=
0
;
i
!=
SAMP_MAX_PLAYERS
;
i
++
)
{
if
(
SAMP
::
pSAMP
->
getPlayers
(
)
->
iIsListed
[
i
]
==
0
||
SAMP
::
pSAMP
->
getStreamedOutPlayerInfo
(
)
->
fPlayerPos
[
i
]
[
0
]
==
0
||
SAMP
::
pSAMP
->
getStreamedOutPlayerInfo
(
)
->
fPlayerPos
[
i
]
[
1
]
==
0
||
SAMP
::
pSAMP
->
getStreamedOutPlayerInfo
(
)
->
fPlayerPos
[
i
]
[
2
]
==
0
)
continue
;
ImGui
::
Text
(
"PlayerID: %d, position: %0.f %0.f %0.f"
,
i
,
SAMP
::
pSAMP
->
getStreamedOutPlayerInfo
(
)
->
fPlayerPos
[
i
]
[
0
]
,
SAMP
::
pSAMP
->
getStreamedOutPlayerInfo
(
)
->
fPlayerPos
[
i
]
[
1
]
,
SAMP
::
pSAMP
->
getStreamedOutPlayerInfo
(
)
->
fPlayerPos
[
i
]
[
2
]
)
;
}
if
(
ImGui
::
Button
(
"Отправить пакет"
)
)
{
stOnFootData data
=
SAMP
::
pSAMP
->
getPlayers
(
)
->
pLocalPlayer
->
onFootData
;
data
.
fPosition
[
2
]
+=
10.0f
;
BitStream bs
;
bs
.
Write

(
ID_PLAYER_SYNC
)
;
bs
.
Write
(
(
PCHAR
)
&
data
,
sizeof
(
stOnFootData
)
)
;
SAMP
::
pSAMP
->
getRakNet
(
)
->
Send
(
&
bs
)
;
}
if
(
ImGui
::
Button
(
"Отправить RPC's"
)
)
{
constexpr
char
message
[
]
=
"Тестовое сообщение"
;
BitStream bsSend
;
bsSend
.
Write
(
(
std
::
uint8_t
)
std
::
strlen
(
message
)
)
;
bsSend
.
Write
(
message
,
(
std
::
uint8_t
)
std
::
strlen
(
message
)
)
;
SAMP
::
pSAMP
->
getRakNet
(
)
->
SendRPC
(
RPC_Chat
,
&
bsSend
)
;
}
if
(
ImGui
::
Button
(
"SAMP::classes::"
)
)
{
//WORK on R1 and R3
SAMP
::
classes
::
pChat
->
AddMessage
(
-
1
,
"Тестовое сообщение"
)
;
SAMP
::
classes
::
pGame
->
SetCursorMode
(
SAMP
::
classes
::
CursorMode
::
CMODE_NONE
,
false
)
;
}
for
(
int
i
=
0
;
i
!=
SAMP_MAX_PLAYERS
;
i
++
)
{
if
(
!
SAMP
::
pSAMP
->
getPlayers
(
)
->
IsPlayerStreamed
(
i
)
)
continue
;
#if defined (SAMP_R1_COMPILE)
ImGui
::
Text
(
"name of %d: %s"
,
i
,
SAMP
::
pSAMP
->
getPlayers
(
)
->
pRemotePlayer
[
i
]
->
szPlayerName
)
;
#elif defined (SAMP_R3_COMPILE)
ImGui
::
Text
(
"name of %d: %s"
,
i
,
SAMP
::
pSAMP
->
getPlayers
(
)
->
pRemotePlayer
[
i
]
->
PlayerName
.
c_str
(
)
)
;
#endif
}
if
(
ImGui
::
Button
(
"Plugin SDK Teleport"
)
)
{
CVector dest
=
FindPlayerPed
(
)
->
GetPosition
(
)
;
dest
.
z
+=
5.0f
;
FindPlayerPed
(
)
->
Teleport
(
dest
,
false
)
;
}
static
int
vehID
=
0
;
ImGui
::
InputInt
(
"Vehicle ID"
,
&
vehID
)
;
if
(
ImGui
::
Button
(
"тп кар"
)
)
{
if
(
SAMP
::
pSAMP
->
getVehicles
(
)
->
IsVehicleStreamed
(
vehID
)
)
{
SAMP
::
pSAMP
->
getVehicles
(
)
->
GetCVehicleFromSAMPVehicleID
(
vehID
)
->
Teleport
(
FindPlayerPed
(
)
->
GetPosition
(
)
,
false
)
;
}
}
if
(
ImGui
::
Button
(
"emul packet"
)
)
{
stOnFootData data
=
SAMP
::
pSAMP
->
getPlayers
(
)
->
pLocalPlayer
->
onFootData
;
BitStream bs
;
bs
.
Write

(
ID_PLAYER_SYNC
)
;
bs
.
Write

(
49
)
;
//playerID
bs
.
Write
(
(
PCHAR
)
&
data
,
sizeof
(
stOnFootData
)
)
;
SAMP
::
pSAMP
->
getRakNet
(
)
->
EmulPacket
(
&
bs
)
;
}
if
(
ImGui
::
Button
(
"emul rpc"
)
)
{
BitStream bs
;
bs
.
Write

(
0.0f
)
;
bs
.
Write

(
0.0f
)
;
bs
.
Write

(
0.5f
)
;
SAMP
::
pSAMP
->
getRakNet
(
)
->
EmulRPC
(
RPC_ScrSetPlayerVelocity
,
&
bs
)
;
}
ImGui
::
End
(
)
;
}
}
ImGui
::
EndFrame
(
)
;
ImGui
::
Render
(
)
;
ImGui_ImplDX9_RenderDrawData
(
ImGui
::
GetDrawData
(
)
)
;
//pRender->Initialize(params->pDevice);
//render example
//if (SUCCEEDED(pRender->BeginRender())) {
//    pRender->D3DBox(100, 100, 100, 100, 0xFF00BECC);
//    pRender->EndRender();
//}
}
return
D3D_OK
;
}
HRESULT __stdcall
D3DResetHook
(
SAMP
::
CallBacks
::
HookedStructs
::
stResetParams
*
params
)
{
if
(
isPluginInitialized
)
{
ImGui_ImplDX9_InvalidateDeviceObjects
(
)
;
//pRender->Invalidate();
}
return
D3D_OK
;
}
bool
__stdcall
RakClientSendHook
(
SAMP
::
CallBacks
::
HookedStructs
::
stRakClientSend
*
params
)
{
if
(
params
->
bitStream
->
GetData
(
)
[
0
]
==
ID_PLAYER_SYNC
)
{
params
->
bitStream
->
ResetReadPointer
(
)
;
params
->
bitStream
->
IgnoreBits
(
8
)
;
stOnFootData data
=
{
0
}
;
params
->
bitStream
->
Read
(
(
PCHAR
)
&
data
,
sizeof
(
stOnFootData
)
)
;
//data.fMoveSpeed[2] = 1.0f;
params
->
bitStream
->
ResetWritePointer
(
)
;
params
->
bitStream
->
Write

(
ID_PLAYER_SYNC
)
;
params
->
bitStream
->
Write
(
(
PCHAR
)
&
data
,
sizeof
(
stOnFootData
)
)
;
}
return
true
;
}
bool
__stdcall
RakClientRecvHook
(
SAMP
::
CallBacks
::
HookedStructs
::
stRakClientRecv
*
params
)
{
return
true
;
}
bool
__stdcall
RakClientRPCHook
(
SAMP
::
CallBacks
::
HookedStructs
::
stRakClientRPC
*
params
)
{
return
true
;
}
bool
__stdcall
RakClientRPCRecvHook
(
SAMP
::
CallBacks
::
HookedStructs
::
stRakClientRPCRecv
*
params
)
{
return
true
;
}
void
__cdecl
cmd
(
char
*
params
)
{
isOpen
^=
true
;
}
const
char
*
checkAddress
(
const
char
*
ipadress
,
const
char
*
adresses
[
]
,
size_t size
)
{
for
(
size_t i
=
0
;
i

LoadAPI
(
)
)
{
initialized
=
true
;
ImGui
::
CreateContext
(
)
;
ImGuiIO
&
io
=
ImGui
::
GetIO
(
)
;
io
.
Fonts
->
AddFontFromFileTTF
(
"C:\\Windows\\Fonts\\Arial.ttf"
,
16
,
NULL
,
ImGui
::
GetIO
(
)
.
Fonts
->
GetGlyphRangesCyrillic
(
)
)
;
(
void
)
io
;
ImGui_ImplWin32_Init
(
GetActiveWindow
(
)
)
;
ImGui_ImplDX9_Init
(
SAMP
::
CallBacks
::
pCallBackRegister
->
GetIDirect3DDevice9
(
)
)
;
ImGui
::
GetIO
(
)
.
ConfigFlags
|=
ImGuiConfigFlags_NoMouseCursorChange
;
//renderф
//pRender = std::make_unique(128);
//initialization
SAMP
::
pSAMP
->
addClientCommand
(
"menu"
,
cmd
)
;
SAMP
::
pSAMP
->
addMessageToChat
(
-
1
,
"SAMP API By AdCKuY_DpO4uLa loaded. %s"
,
SAMP
::
pSAMP
->
getInfo
(
)
->
szIP
)
;
char
*
ipadress
=
SAMP
::
pSAMP
->
getInfo
(
)
->
szIP
;
const
char
*
adresses
[
]
=
{
"46.174.52.144"
,
"37.230.137.194"
,
"37.230.228.142"
}
;
const
char
*
result
=
checkAddress
(
ipadress
,
adresses
,
sizeof
(
adresses
)
/
sizeof
(
adresses
[
0
]
)
)
;
if
(
!
result
)
{
}
//init raknet callbacks
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterRakClientCallback
(
RakClientSendHook
)
;
//registed RakClient Send Hook
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterRakClientCallback
(
RakClientRecvHook
)
;
//registed RakClient Recv Hook
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterRakClientCallback
(
RakClientRPCHook
)
;
//registed RakClient RPC Hook
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterRakClientCallback
(
RakClientRPCRecvHook
)
;
//registed RakClient RPC recv Hook
isPluginInitialized
=
true
;
}
}
if
(
initialized
)
{
//gameLoop
}
}
int
__stdcall
DllMain
(
HMODULE hModule
,
DWORD dwReason
,
LPVOID lpReserved
)
{
switch
(
dwReason
)
{
case
DLL_PROCESS_ATTACH
:
{
SAMP
::
Init
(
)
;
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterGameLoopCallback
(
GameLoop
)
;
//register gameloop hook
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterWndProcCallback
(
WndProcCallBack
)
;
//register wnd proc hook
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterD3DCallback
(
D3DPresentHook
)
;
//register D3D present hook
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterD3DCallback
(
D3DResetHook
)
;
//register D3D reset hook
printf
(
"\n -> Plugin loaded (%d)\n"
,
GetTickCount
(
)
)
;
break
;
}
case
DLL_PROCESS_DETACH
:
{
SAMP
::
pSAMP
->
unregisterChatCommand
(
cmd
)
;
SAMP
::
ShutDown
(
)
;
ImGui_ImplDX9_Shutdown
(
)
;
ImGui_ImplWin32_Shutdown
(
)
;
ImGui
::
DestroyContext
(
)
;
printf
(
"\n -> Plugin unloaded (%d)\n"
,
GetTickCount
(
)
)
;
break
;
}
}
return
true
;


UPD: крашит 12 айди пакета

P.S код не мой
 
Ответить с цитированием

  #9  
Старый 12.07.2024, 06:23
F0RQU1N and
Познавший АНТИЧАТ
Регистрация: 29.09.2018
Сообщений: 1,292
С нами: 4012500

Репутация: 138


По умолчанию

Цитата:
Сообщение от penta  

C++:





Код:
#include "main.h"
bool
isPluginInitialized
=
false
;
//std::unique_ptr pRender = nullptr;
LRESULT __stdcall
WndProcCallBack
(
SAMP
::
CallBacks
::
HookedStructs
::
stWndProcParams
*
params
)
{
if
(
isPluginInitialized
)
{
if
(
ImGui_ImplWin32_WndProcHandler
(
params
->
hWnd
,
params
->
uMsg
,
params
->
wParam
,
params
->
lParam
)
)
{
return
1
;
}
}
return
0
;
//retn null if all good
}
static
bool
isOpen
=
false
;
HRESULT __stdcall
D3DPresentHook
(
SAMP
::
CallBacks
::
HookedStructs
::
stPresentParams
*
params
)
{
if
(
isPluginInitialized
)
{
ImGui_ImplDX9_NewFrame
(
)
;
//вызывалось до инициализации имгуи, поэтому крашило
ImGui_ImplWin32_NewFrame
(
)
;
ImGui
::
NewFrame
(
)
;
if
(
isOpen
)
{
if
(
ImGui
::
Begin
(
"Тестовое меню##1337"
,
&
isOpen
,
ImGuiWindowFlags_
::
ImGuiWindowFlags_NoSavedSettings
)
)
{
static
bool
bIsDemoWindowActive
=
false
;
ImGui
::
Checkbox
(
"Демо"
,
&
bIsDemoWindowActive
)
;
if
(
bIsDemoWindowActive
)
ImGui
::
ShowDemoWindow
(
&
bIsDemoWindowActive
)
;
for
(
int
i
=
0
;
i
!=
SAMP_MAX_PLAYERS
;
i
++
)
{
if
(
SAMP
::
pSAMP
->
getPlayers
(
)
->
iIsListed
[
i
]
==
0
||
SAMP
::
pSAMP
->
getStreamedOutPlayerInfo
(
)
->
fPlayerPos
[
i
]
[
0
]
==
0
||
SAMP
::
pSAMP
->
getStreamedOutPlayerInfo
(
)
->
fPlayerPos
[
i
]
[
1
]
==
0
||
SAMP
::
pSAMP
->
getStreamedOutPlayerInfo
(
)
->
fPlayerPos
[
i
]
[
2
]
==
0
)
continue
;
ImGui
::
Text
(
"PlayerID: %d, position: %0.f %0.f %0.f"
,
i
,
SAMP
::
pSAMP
->
getStreamedOutPlayerInfo
(
)
->
fPlayerPos
[
i
]
[
0
]
,
SAMP
::
pSAMP
->
getStreamedOutPlayerInfo
(
)
->
fPlayerPos
[
i
]
[
1
]
,
SAMP
::
pSAMP
->
getStreamedOutPlayerInfo
(
)
->
fPlayerPos
[
i
]
[
2
]
)
;
}
if
(
ImGui
::
Button
(
"Отправить пакет"
)
)
{
stOnFootData data
=
SAMP
::
pSAMP
->
getPlayers
(
)
->
pLocalPlayer
->
onFootData
;
data
.
fPosition
[
2
]
+=
10.0f
;
BitStream bs
;
bs
.
Write

(
ID_PLAYER_SYNC
)
;
bs
.
Write
(
(
PCHAR
)
&
data
,
sizeof
(
stOnFootData
)
)
;
SAMP
::
pSAMP
->
getRakNet
(
)
->
Send
(
&
bs
)
;
}
if
(
ImGui
::
Button
(
"Отправить RPC's"
)
)
{
constexpr
char
message
[
]
=
"Тестовое сообщение"
;
BitStream bsSend
;
bsSend
.
Write
(
(
std
::
uint8_t
)
std
::
strlen
(
message
)
)
;
bsSend
.
Write
(
message
,
(
std
::
uint8_t
)
std
::
strlen
(
message
)
)
;
SAMP
::
pSAMP
->
getRakNet
(
)
->
SendRPC
(
RPC_Chat
,
&
bsSend
)
;
}
if
(
ImGui
::
Button
(
"SAMP::classes::"
)
)
{
//WORK on R1 and R3
SAMP
::
classes
::
pChat
->
AddMessage
(
-
1
,
"Тестовое сообщение"
)
;
SAMP
::
classes
::
pGame
->
SetCursorMode
(
SAMP
::
classes
::
CursorMode
::
CMODE_NONE
,
false
)
;
}
for
(
int
i
=
0
;
i
!=
SAMP_MAX_PLAYERS
;
i
++
)
{
if
(
!
SAMP
::
pSAMP
->
getPlayers
(
)
->
IsPlayerStreamed
(
i
)
)
continue
;
#if defined (SAMP_R1_COMPILE)
ImGui
::
Text
(
"name of %d: %s"
,
i
,
SAMP
::
pSAMP
->
getPlayers
(
)
->
pRemotePlayer
[
i
]
->
szPlayerName
)
;
#elif defined (SAMP_R3_COMPILE)
ImGui
::
Text
(
"name of %d: %s"
,
i
,
SAMP
::
pSAMP
->
getPlayers
(
)
->
pRemotePlayer
[
i
]
->
PlayerName
.
c_str
(
)
)
;
#endif
}
if
(
ImGui
::
Button
(
"Plugin SDK Teleport"
)
)
{
CVector dest
=
FindPlayerPed
(
)
->
GetPosition
(
)
;
dest
.
z
+=
5.0f
;
FindPlayerPed
(
)
->
Teleport
(
dest
,
false
)
;
}
static
int
vehID
=
0
;
ImGui
::
InputInt
(
"Vehicle ID"
,
&
vehID
)
;
if
(
ImGui
::
Button
(
"тп кар"
)
)
{
if
(
SAMP
::
pSAMP
->
getVehicles
(
)
->
IsVehicleStreamed
(
vehID
)
)
{
SAMP
::
pSAMP
->
getVehicles
(
)
->
GetCVehicleFromSAMPVehicleID
(
vehID
)
->
Teleport
(
FindPlayerPed
(
)
->
GetPosition
(
)
,
false
)
;
}
}
if
(
ImGui
::
Button
(
"emul packet"
)
)
{
stOnFootData data
=
SAMP
::
pSAMP
->
getPlayers
(
)
->
pLocalPlayer
->
onFootData
;
BitStream bs
;
bs
.
Write

(
ID_PLAYER_SYNC
)
;
bs
.
Write

(
49
)
;
//playerID
bs
.
Write
(
(
PCHAR
)
&
data
,
sizeof
(
stOnFootData
)
)
;
SAMP
::
pSAMP
->
getRakNet
(
)
->
EmulPacket
(
&
bs
)
;
}
if
(
ImGui
::
Button
(
"emul rpc"
)
)
{
BitStream bs
;
bs
.
Write

(
0.0f
)
;
bs
.
Write

(
0.0f
)
;
bs
.
Write

(
0.5f
)
;
SAMP
::
pSAMP
->
getRakNet
(
)
->
EmulRPC
(
RPC_ScrSetPlayerVelocity
,
&
bs
)
;
}
ImGui
::
End
(
)
;
}
}
ImGui
::
EndFrame
(
)
;
ImGui
::
Render
(
)
;
ImGui_ImplDX9_RenderDrawData
(
ImGui
::
GetDrawData
(
)
)
;
//pRender->Initialize(params->pDevice);
//render example
//if (SUCCEEDED(pRender->BeginRender())) {
//    pRender->D3DBox(100, 100, 100, 100, 0xFF00BECC);
//    pRender->EndRender();
//}
}
return
D3D_OK
;
}
HRESULT __stdcall
D3DResetHook
(
SAMP
::
CallBacks
::
HookedStructs
::
stResetParams
*
params
)
{
if
(
isPluginInitialized
)
{
ImGui_ImplDX9_InvalidateDeviceObjects
(
)
;
//pRender->Invalidate();
}
return
D3D_OK
;
}
bool
__stdcall
RakClientSendHook
(
SAMP
::
CallBacks
::
HookedStructs
::
stRakClientSend
*
params
)
{
if
(
params
->
bitStream
->
GetData
(
)
[
0
]
==
ID_PLAYER_SYNC
)
{
params
->
bitStream
->
ResetReadPointer
(
)
;
params
->
bitStream
->
IgnoreBits
(
8
)
;
stOnFootData data
=
{
0
}
;
params
->
bitStream
->
Read
(
(
PCHAR
)
&
data
,
sizeof
(
stOnFootData
)
)
;
//data.fMoveSpeed[2] = 1.0f;
params
->
bitStream
->
ResetWritePointer
(
)
;
params
->
bitStream
->
Write

(
ID_PLAYER_SYNC
)
;
params
->
bitStream
->
Write
(
(
PCHAR
)
&
data
,
sizeof
(
stOnFootData
)
)
;
}
return
true
;
}
bool
__stdcall
RakClientRecvHook
(
SAMP
::
CallBacks
::
HookedStructs
::
stRakClientRecv
*
params
)
{
return
true
;
}
bool
__stdcall
RakClientRPCHook
(
SAMP
::
CallBacks
::
HookedStructs
::
stRakClientRPC
*
params
)
{
return
true
;
}
bool
__stdcall
RakClientRPCRecvHook
(
SAMP
::
CallBacks
::
HookedStructs
::
stRakClientRPCRecv
*
params
)
{
return
true
;
}
void
__cdecl
cmd
(
char
*
params
)
{
isOpen
^=
true
;
}
const
char
*
checkAddress
(
const
char
*
ipadress
,
const
char
*
adresses
[
]
,
size_t size
)
{
for
(
size_t i
=
0
;
i

LoadAPI
(
)
)
{
initialized
=
true
;
ImGui
::
CreateContext
(
)
;
ImGuiIO
&
io
=
ImGui
::
GetIO
(
)
;
io
.
Fonts
->
AddFontFromFileTTF
(
"C:\\Windows\\Fonts\\Arial.ttf"
,
16
,
NULL
,
ImGui
::
GetIO
(
)
.
Fonts
->
GetGlyphRangesCyrillic
(
)
)
;
(
void
)
io
;
ImGui_ImplWin32_Init
(
GetActiveWindow
(
)
)
;
ImGui_ImplDX9_Init
(
SAMP
::
CallBacks
::
pCallBackRegister
->
GetIDirect3DDevice9
(
)
)
;
ImGui
::
GetIO
(
)
.
ConfigFlags
|=
ImGuiConfigFlags_NoMouseCursorChange
;
//renderф
//pRender = std::make_unique(128);
//initialization
SAMP
::
pSAMP
->
addClientCommand
(
"menu"
,
cmd
)
;
SAMP
::
pSAMP
->
addMessageToChat
(
-
1
,
"SAMP API By AdCKuY_DpO4uLa loaded. %s"
,
SAMP
::
pSAMP
->
getInfo
(
)
->
szIP
)
;
char
*
ipadress
=
SAMP
::
pSAMP
->
getInfo
(
)
->
szIP
;
const
char
*
adresses
[
]
=
{
"46.174.52.144"
,
"37.230.137.194"
,
"37.230.228.142"
}
;
const
char
*
result
=
checkAddress
(
ipadress
,
adresses
,
sizeof
(
adresses
)
/
sizeof
(
adresses
[
0
]
)
)
;
if
(
!
result
)
{
}
//init raknet callbacks
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterRakClientCallback
(
RakClientSendHook
)
;
//registed RakClient Send Hook
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterRakClientCallback
(
RakClientRecvHook
)
;
//registed RakClient Recv Hook
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterRakClientCallback
(
RakClientRPCHook
)
;
//registed RakClient RPC Hook
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterRakClientCallback
(
RakClientRPCRecvHook
)
;
//registed RakClient RPC recv Hook
isPluginInitialized
=
true
;
}
}
if
(
initialized
)
{
//gameLoop
}
}
int
__stdcall
DllMain
(
HMODULE hModule
,
DWORD dwReason
,
LPVOID lpReserved
)
{
switch
(
dwReason
)
{
case
DLL_PROCESS_ATTACH
:
{
SAMP
::
Init
(
)
;
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterGameLoopCallback
(
GameLoop
)
;
//register gameloop hook
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterWndProcCallback
(
WndProcCallBack
)
;
//register wnd proc hook
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterD3DCallback
(
D3DPresentHook
)
;
//register D3D present hook
SAMP
::
CallBacks
::
pCallBackRegister
->
RegisterD3DCallback
(
D3DResetHook
)
;
//register D3D reset hook
printf
(
"\n -> Plugin loaded (%d)\n"
,
GetTickCount
(
)
)
;
break
;
}
case
DLL_PROCESS_DETACH
:
{
SAMP
::
pSAMP
->
unregisterChatCommand
(
cmd
)
;
SAMP
::
ShutDown
(
)
;
ImGui_ImplDX9_Shutdown
(
)
;
ImGui_ImplWin32_Shutdown
(
)
;
ImGui
::
DestroyContext
(
)
;
printf
(
"\n -> Plugin unloaded (%d)\n"
,
GetTickCount
(
)
)
;
break
;
}
}
return
true
;


UPD: крашит 12 айди пакета

P.S код не мой
мб потому что ты 2 раза регаешь коллбеки?)))
 
Ответить с цитированием

  #10  
Старый 14.07.2024, 18:03
TokyoQq
Новичок
Регистрация: 14.01.2024
Сообщений: 20
С нами: 1228197

Репутация: 3
По умолчанию

как написать silent aim

типо у меня есть координаты кости головы но я не знаю как изменить координаты пули
 
Ответить с цитированием
Ответ





Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 


Быстрый переход




ANTICHAT ™ © 2001- Antichat Kft.