Показать сообщение отдельно

  #6  
Старый 24.09.2025, 22:16
0xff65
Познающий
Регистрация: 23.01.2022
Сообщений: 36
С нами: 2267665

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

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

int count = 0;

if (count > 2) return;
if(key == 50)
count++;
Не работает совсем

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
}
}
,
{
51
,
{
25
,
27
,
26
}
}
,
{
52
,
{
29
}
}
,
{
53
,
{
34
,
33
}
}
}
;
int
count
=
0
;
Project5
(
)
{
Events
::
drawingEvent
+=
[
this
]
{
if
(
!
isPlayerPlaying
(
)
||
isInputActive
(
)
)
return
;
for
(
const
auto
&
[
key
,
weapons
]
:
vKeys
)
{
if
(
key
==
50
)
{
if
(
count
>
2
)
continue
;
if
(
KeyPressed
(
key
)
)
{
count
++
;
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
;
}
}
}
}
else
{
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
;
 
Ответить с цитированием