
16.03.2026, 03:49
|
|
Флудер
Регистрация: 02.02.2019
Сообщений: 5,070
С нами:
3831395
Репутация:
183
|
|
Сообщение от 0xff65
Приветствую, выхожу из машины плагин перестает работать почему-то, pPed->m_pVehicle
C++:
Код:
#include "plugin.h"
#include "CWorld.h"
#include "CCamera.h"
#include "extensions/ScriptCommands.h"
using
namespace
plugin
;
class
Project5
{
public
:
std
::
unordered_map
>
vKeys
=
{
{
49
,
{
31
,
30
}
}
,
{
50
,
{
22
,
23
,
24
,
91
}
}
,
{
51
,
{
25
,
27
,
26
}
}
,
{
52
,
{
29
}
}
,
{
53
,
{
34
,
33
}
}
}
;
Project5
(
)
{
Events
::
drawingEvent
+=
[
this
]
{
if
(
!
isPlayerPlaying
(
)
||
isInputActive
(
)
)
return
;
for
(
const
auto
&
[
key
,
weapons
]
:
vKeys
)
{
if
(
KeyPressed
(
key
)
)
{
printf
(
"Key: %d\n"
,
key
)
;
CPed
*
pPed
=
CWorld
::
Players
[
CWorld
::
PlayerInFocus
]
.
m_pPed
;
std
::
uint32_t
nHandle
=
CPools
::
GetPedRef
(
pPed
)
;
for
(
std
::
uint8_t
nWeapon
:
weapons
)
{
printf
(
"Weapon: %d\n"
,
nWeapon
)
;
if
(
Command
(
nHandle
,
nWeapon
)
)
{
Command
(
nHandle
,
0
)
;
Command
(
nHandle
,
nWeapon
)
;
break
;
}
}
}
}
}
;
}
bool
isPlayerPlaying
(
)
{
return
CWorld
::
Players
[
CWorld
::
PlayerInFocus
]
.
m_pPed
!=
nullptr
;
}
bool
isInputActive
(
)
{
CPed
*
pPed
=
CWorld
::
Players
[
CWorld
::
PlayerInFocus
]
.
m_pPed
;
return
(
pPed
&&
pPed
->
m_pVehicle
)
;
}
}
Project5Plugin
;
Потому что при выходе из машины в m_pPed всё равно хранится указатель на последний транспорт в котором сидел игрок, а у тебя в isInputActive() идёт как раз таки проверка на то пустой указатель m_pVehicle, или нет. Правильней будет проверять так:
C++:
Код:
bool
isPlayerInVehicle
(
)
{
CPed
*
pPed
=
CWorld
::
Players
[
CWorld
::
PlayerInFocus
]
.
m_pPed
;
if
(
!
pPed
)
return
false
;
return
pPed
->
bInVehicle
;
}
|
|
|