/
Packets.h
211 lines (162 loc) · 4.52 KB
/
Packets.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
This is a SAMP (0.3.7-R1) API project file.
Developer: LUCHARE <luchare.dev@gmail.com>
See more here https://github.com/LUCHARE/SAMP-API
Copyright (c) 2018 BlastHack Team <BlastHack.Net>. All rights reserved.
*/
#pragma once
#include "common.h"
#include "CVector.h"
#include "Animation.h"
#include "ControllerState.h"
//#include "CNetGame.h"
#define SAMP_COMPRESS_ASPECT_RATIO(_VALUE) (_VALUE * 255)
#define SAMP_COMPRESS_EXT_ZOOM(_VALUE) (_VALUE * 63)
#define SAMP_DECOMPRESS_ASPECT_RATIO(_VALUE) (_VALUE / 255)
#define SAMP_DECOMPRESS_EXT_ZOOM(_VALUE) (_VALUE / 63)
#define SAMP_DEFAULT_PACKET_CTOR(_TYPE) inline _TYPE() { for (int i = 0; i < sizeof(*this); i++) ((unsigned char *)this)[i] = 0; }
#define SAMP_PACKET_ID(_ID) static const unsigned char ID = _ID;
SAMP_BEGIN
namespace PACKET {
struct SAMP_API OnfootData {
ControllerState m_controllerState;
CVector m_position;
float m_fQuaternion[4];
unsigned char m_nHealth;
unsigned char m_nArmor;
unsigned char m_nCurrentWeapon;
unsigned char m_nSpecialAction;
CVector m_speed;
CVector m_surfingOffset;
ID m_nSurfingVehicleId;
Animation m_animation;
SAMP_PACKET_ID(207)
SAMP_DEFAULT_PACKET_CTOR(OnfootData)
};
struct SAMP_API IncarData {
ID m_nVehicle;
ControllerState m_controllerState;
float m_fQuaternion[4];
CVector m_position;
CVector m_speed;
float m_fHealth;
unsigned char m_nDriverHealth;
unsigned char m_nDriverArmor;
unsigned char m_nCurrentWeapon;
bool m_bSirenEnabled;
bool m_bLandingGear;
ID m_nTrailerId;
union {
unsigned short m_aHydraThrustAngle[2];
float m_fTrainSpeed;
};
SAMP_PACKET_ID(200)
SAMP_DEFAULT_PACKET_CTOR(IncarData)
};
struct SAMP_API AimData {
unsigned char m_nCameraMode;
CVector m_aimf1;
CVector m_aimPos;
float m_fAimZ;
unsigned char m_nCameraExtZoom : 6;
unsigned char m_nWeaponState : 2;
char m_nAspectRatio;
enum WeaponState { None, LastBullet, MoreBullets, Reloading };
SAMP_PACKET_ID(203)
SAMP_DEFAULT_PACKET_CTOR(AimData)
};
struct SAMP_API TrailerData {
ID m_nId;
CVector m_position;
float m_fQuaternion[4];
CVector m_speed;
CVector m_turnSpeed;
SAMP_PACKET_ID(210)
SAMP_DEFAULT_PACKET_CTOR(TrailerData)
};
struct SAMP_API PassengerData {
ID m_nVehicleId;
unsigned char m_nSeatId; // flags
unsigned char m_nCurrentWeapon;
unsigned char m_nHealth;
unsigned char m_nArmor;
ControllerState m_controllerState;
CVector m_position;
SAMP_PACKET_ID(211)
SAMP_DEFAULT_PACKET_CTOR(PassengerData)
};
struct SAMP_API UnoccupiedData {
ID m_nVehicleId;
unsigned char m_nSeatId;
CVector m_roll;
CVector m_direction;
CVector m_position;
CVector m_speed;
CVector m_turnSpeed;
float m_fHealth;
SAMP_PACKET_ID(209)
SAMP_DEFAULT_PACKET_CTOR(UnoccupiedData)
};
struct SAMP_API BulletData {
unsigned char m_nTargetType;
ID m_nTargetId;
CVector m_origin;
CVector m_target;
CVector m_center;
unsigned char m_nWeapon;
SAMP_PACKET_ID(206)
SAMP_DEFAULT_PACKET_CTOR(BulletData)
};
struct SAMP_API SpectatorData {
ControllerState m_controllerState;
CVector m_position;
SAMP_PACKET_ID(212)
SAMP_DEFAULT_PACKET_CTOR(SpectatorData)
};
struct SAMP_API StatsData {
int m_nMoney;
int m_nDrunkLevel;
SAMP_PACKET_ID(205)
SAMP_DEFAULT_PACKET_CTOR(StatsData)
};
/*
a structure in this block has dynamic size
struct SAMP_API WeaponsData {
ID m_nAimedPlayer;
ID m_nAimedActor;
struct {
char m_nSlot;
char m_nWeapon;
unsigned short m_nAmmo;
} m_aWeapons[n]; // 0 < n < 14
SAMP_PACKET_ID(204)
SAMP_DEFAULT_PACKET_CTOR(WeaponsData)
};
struct SAMP_API RconCommand {
unsigned long m_nTextLen;
char m_szText[m_nTextLen];
SAMP_PACKET_ID(201)
SAMP_DEFAULT_PACKET_CTOR(RconCommand)
};
struct SAMP_API MarkersData {
bool m_bCreate; // create(1)/remove(0)
int m_nCount;
struct {
ID m_nPlayer;
VectorCompressed m_vPos;
} m_aMarkers[m_nCount];
SAMP_PACKET_ID(208)
SAMP_DEFAULT_PACKET_CTOR(MarkersData)
};
*/
#if defined(__RAK_CLIENT_H)
template<class T>
void Send(T packet) {
RakNet::BitStream bs;
bs.Write(T::ID);
bs.Write(packet);
pNetGame->m_pRakClient->Send(&bs, HIGH_PRIORITY, RELIABLE, 0);
}
#endif
}
SAMP_END