
31.01.2024, 12:17
|
|
Постоянный
Регистрация: 29.05.2017
Сообщений: 394
С нами:
4714653
Репутация:
98
|
|
Вроде что-то получилось.
C++:
Код:
struct
stOnFootData
{
uint16_t
sLeftRightKeys
;
uint16_t
sUpDownKeys
;
union
{
uint16_t
sKeys
;
struct
stSAMPKeys
stSampKeys
;
}
;
float
fPosition
[
3
]
;
float
fQuaternion
[
4
]
;
uint8_t
byteHealth
;
uint8_t
byteArmor
;
uint8_t
byteCurrentWeapon
;
uint8_t
byteSpecialAction
;
float
fMoveSpeed
[
3
]
;
float
fSurfingOffsets
[
3
]
;
uint16_t
sSurfingVehicleID
;
union
{
struct
{
uint16_t
id
;
uint8_t
frameDelta
;
union
{
struct
{
bool
loop
:
1
;
bool
lockX
:
1
;
bool
lockY
:
1
;
bool
freeze
:
1
;
uint8_t
time
:
2
;
uint8_t
_unused
:
1
;
bool
regular
:
1
;
}
;
uint8_t
value
;
}
flags
;
}
animation
;
struct
{
uint16_t
sCurrentAnimationID
;
uint16_t
sAnimFlags
;
}
;
}
;
}
;
void
emulOnFootData
(
int
sampPlayerId
,
stOnFootData onFootData
)
{
bool
bHasLeftRightKeys
=
onFootData
.
sLeftRightKeys
!=
0
?
true
:
false
;
bool
bHasUpDownKeys
=
onFootData
.
sUpDownKeys
!=
0
?
true
:
false
;
bool
bHasSurfInfo
=
onFootData
.
sSurfingVehicleID
!=
0
?
true
:
false
;
bool
bAnimation
=
onFootData
.
sCurrentAnimationID
!=
0
?
true
:
false
;
BitStream bs
;
bs
.
Write
(
(
unsigned
short
)
sampPlayerId
)
;
bs
.
Write
(
bHasLeftRightKeys
)
;
if
(
bHasLeftRightKeys
)
{
bs
.
Write
(
(
WORD
)
onFootData
.
sLeftRightKeys
)
;
}
bs
.
Write
(
bHasUpDownKeys
)
;
if
(
bHasUpDownKeys
)
{
bs
.
Write
(
(
WORD
)
onFootData
.
sUpDownKeys
)
;
}
bs
.
Write
(
onFootData
.
sKeys
)
;
// bs.WriteVector(onFootData.fPosition[0], onFootData.fPosition[1], onFootData.fPosition[2]);
bs
.
Write
(
onFootData
.
fPosition
[
0
]
)
;
bs
.
Write
(
onFootData
.
fPosition
[
1
]
)
;
bs
.
Write
(
onFootData
.
fPosition
[
2
]
)
;
bs
.
WriteNormQuat
(
onFootData
.
fQuaternion
[
0
]
,
onFootData
.
fQuaternion
[
1
]
,
onFootData
.
fQuaternion
[
2
]
,
onFootData
.
fQuaternion
[
3
]
)
;
BYTE byteHealthArmor
=
(
onFootData
.
byteHealth
getRakNet
(
)
->
emulateRecvPacket
(
207
,
&
bs
)
;
}
void
test
(
int
playerId
)
{
stOnFootData onFootData
;
onFootData
.
sLeftRightKeys
=
0
;
onFootData
.
sUpDownKeys
=
0
;
onFootData
.
sKeys
=
0
;
onFootData
.
fPosition
[
0
]
=
PEDSELF
->
GetPosition
(
)
->
fX
+
1.0
;
onFootData
.
fPosition
[
1
]
=
PEDSELF
->
GetPosition
(
)
->
fY
;
onFootData
.
fPosition
[
2
]
=
PEDSELF
->
GetPosition
(
)
->
fZ
;
onFootData
.
fQuaternion
[
0
]
=
SF
->
getSAMP
(
)
->
getPlayers
(
)
->
pLocalPlayer
->
onFootData
.
fQuaternion
[
0
]
;
onFootData
.
fQuaternion
[
1
]
=
SF
->
getSAMP
(
)
->
getPlayers
(
)
->
pLocalPlayer
->
onFootData
.
fQuaternion
[
1
]
;
onFootData
.
fQuaternion
[
2
]
=
SF
->
getSAMP
(
)
->
getPlayers
(
)
->
pLocalPlayer
->
onFootData
.
fQuaternion
[
2
]
;
onFootData
.
fQuaternion
[
3
]
=
SF
->
getSAMP
(
)
->
getPlayers
(
)
->
pLocalPlayer
->
onFootData
.
fQuaternion
[
3
]
;
onFootData
.
byteHealth
=
50
;
onFootData
.
byteArmor
=
100
;
onFootData
.
byteCurrentWeapon
=
24
;
onFootData
.
byteSpecialAction
=
68
;
onFootData
.
fMoveSpeed
[
0
]
=
SF
->
getSAMP
(
)
->
getPlayers
(
)
->
pLocalPlayer
->
onFootData
.
fMoveSpeed
[
0
]
;
onFootData
.
fMoveSpeed
[
1
]
=
SF
->
getSAMP
(
)
->
getPlayers
(
)
->
pLocalPlayer
->
onFootData
.
fMoveSpeed
[
1
]
;
onFootData
.
fMoveSpeed
[
2
]
=
SF
->
getSAMP
(
)
->
getPlayers
(
)
->
pLocalPlayer
->
onFootData
.
fMoveSpeed
[
2
]
;
bool
bHasSurfInfo
=
false
;
onFootData
.
fSurfingOffsets
[
0
]
=
0.0
;
onFootData
.
fSurfingOffsets
[
1
]
=
0.0
;
onFootData
.
fSurfingOffsets
[
2
]
=
0.0
;
onFootData
.
sSurfingVehicleID
=
0
;
bool
bAnimation
=
true
;
/*
onFootData.animation.id = 1224;
onFootData.animation.frameDelta = 1.0;
onFootData.animation.flags.lockX = false;
onFootData.animation.flags.lockY = false;
onFootData.animation.flags.freeze = false;
onFootData.animation.flags.time = false;
onFootData.animation.flags._unused = false;
onFootData.animation.flags.regular = false;*/
onFootData
.
sCurrentAnimationID
=
984
;
onFootData
.
sAnimFlags
=
4356
;
emulOnFootData
(
playerId
,
onFootData
)
;
}
Недостающие функции битстрима можно скопипастить отсюда.
UPD: исправил фатальные опечатки.
|
|
|