-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathplayer.hpp
More file actions
1132 lines (913 loc) · 32.8 KB
/
Copy pathplayer.hpp
File metadata and controls
1132 lines (913 loc) · 32.8 KB
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma once
#include "anim.hpp"
#include "entity.hpp"
#include "network.hpp"
#include "pool.hpp"
#include "types.hpp"
#include "values.hpp"
#include <chrono>
#include <string>
#include <type_traits>
#include <utility>
struct IVehicle;
struct IObject;
struct IPlayerObject;
struct IActor;
enum PlayerFightingStyle
{
PlayerFightingStyle_Normal = 4,
PlayerFightingStyle_Boxing = 5,
PlayerFightingStyle_KungFu = 6,
PlayerFightingStyle_KneeHead = 7,
PlayerFightingStyle_GrabKick = 15,
PlayerFightingStyle_Elbow = 16
};
enum PlayerState
{
PlayerState_None = 0,
PlayerState_OnFoot = 1,
PlayerState_Driver = 2,
PlayerState_Passenger = 3,
PlayerState_ExitVehicle = 4,
PlayerState_EnterVehicleDriver = 5,
PlayerState_EnterVehiclePassenger = 6,
PlayerState_Wasted = 7,
PlayerState_Spawned = 8,
PlayerState_Spectating = 9
};
enum PlayerWeaponSkill
{
PlayerWeaponSkill_Invalid = -1,
PlayerWeaponSkill_Pistol,
PlayerWeaponSkill_SilencedPistol,
PlayerWeaponSkill_DesertEagle,
PlayerWeaponSkill_Shotgun,
PlayerWeaponSkill_SawnOff,
PlayerWeaponSkill_SPAS12,
PlayerWeaponSkill_Uzi,
PlayerWeaponSkill_MP5,
PlayerWeaponSkill_AK47,
PlayerWeaponSkill_M4,
PlayerWeaponSkill_Sniper
};
enum PlayerSpecialAction
{
SpecialAction_None,
SpecialAction_Duck,
SpecialAction_Jetpack,
SpecialAction_EnterVehicle,
SpecialAction_ExitVehicle,
SpecialAction_Dance1,
SpecialAction_Dance2,
SpecialAction_Dance3,
SpecialAction_Dance4,
SpecialAction_HandsUp = 10,
SpecialAction_Cellphone,
SpecialAction_Sitting,
SpecialAction_StopCellphone,
SpecialAction_Beer = 20,
Specialaction_Smoke,
SpecialAction_Wine,
SpecialAction_Sprunk,
SpecialAction_Cuffed,
SpecialAction_Carry,
SpecialAction_Pissing = 68
};
enum PlayerAnimationSyncType
{
PlayerAnimationSyncType_NoSync,
PlayerAnimationSyncType_Sync,
PlayerAnimationSyncType_SyncOthers
};
enum PlayerBulletHitType : uint8_t
{
PlayerBulletHitType_None,
PlayerBulletHitType_Player = 1,
PlayerBulletHitType_Vehicle = 2,
PlayerBulletHitType_Object = 3,
PlayerBulletHitType_PlayerObject = 4,
};
enum BodyPart
{
BodyPart_Torso = 3,
BodyPart_Groin,
BodyPart_LeftArm,
BodyPart_RightArm,
BodyPart_LeftLeg,
BodyPart_RightLeg,
BodyPart_Head
};
enum MapIconStyle
{
MapIconStyle_Local,
MapIconStyle_Global,
MapIconStyle_LocalCheckpoint,
MapIconStyle_GlobalCheckpoint
};
enum PlayerClickSource
{
PlayerClickSource_Scoreboard
};
enum PlayerSpectateMode
{
PlayerSpectateMode_Normal = 1,
PlayerSpectateMode_Fixed,
PlayerSpectateMode_Side
};
enum PlayerCameraCutType
{
PlayerCameraCutType_Cut,
PlayerCameraCutType_Move
};
enum PlayerMarkerMode
{
PlayerMarkerMode_Off,
PlayerMarkerMode_Global,
PlayerMarkerMode_Streamed
};
enum LagCompMode
{
LagCompMode_Disabled = 0,
LagCompMode_PositionOnly = 2,
LagCompMode_Enabled = 1
};
enum PlayerWeapon
{
PlayerWeapon_Fist,
PlayerWeapon_BrassKnuckle,
PlayerWeapon_GolfClub,
PlayerWeapon_NiteStick,
PlayerWeapon_Knife,
PlayerWeapon_Bat,
PlayerWeapon_Shovel,
PlayerWeapon_PoolStick,
PlayerWeapon_Katana,
PlayerWeapon_Chainsaw,
PlayerWeapon_Dildo,
PlayerWeapon_Dildo2,
PlayerWeapon_Vibrator,
PlayerWeapon_Vibrator2,
PlayerWeapon_Flower,
PlayerWeapon_Cane,
PlayerWeapon_Grenade,
PlayerWeapon_Teargas,
PlayerWeapon_Moltov,
PlayerWeapon_Colt45 = 22,
PlayerWeapon_Silenced,
PlayerWeapon_Deagle,
PlayerWeapon_Shotgun,
PlayerWeapon_Sawedoff,
PlayerWeapon_Shotgspa,
PlayerWeapon_UZI,
PlayerWeapon_MP5,
PlayerWeapon_AK47,
PlayerWeapon_M4,
PlayerWeapon_TEC9,
PlayerWeapon_Rifle,
PlayerWeapon_Sniper,
PlayerWeapon_RocketLauncher,
PlayerWeapon_HeatSeeker,
PlayerWeapon_FlameThrower,
PlayerWeapon_Minigun,
PlayerWeapon_Satchel,
PlayerWeapon_Bomb,
PlayerWeapon_SprayCan,
PlayerWeapon_FireExtinguisher,
PlayerWeapon_Camera,
PlayerWeapon_Night_Vis_Goggles,
PlayerWeapon_Thermal_Goggles,
PlayerWeapon_Parachute,
PlayerWeapon_Vehicle = 49,
PlayerWeapon_Heliblades,
PlayerWeapon_Explosion,
PlayerWeapon_Drown = 53,
PlayerWeapon_Collision,
PlayerWeapon_End
};
enum PlayerWeaponType
{
PlayerWeaponType_None,
PlayerWeaponType_Melee,
PlayerWeaponType_Throwable,
PlayerWeaponType_Bullet,
PlayerWeaponType_Rocket,
PlayerWeaponType_Sprayable,
PlayerWeaponType_Special,
};
static const StringView PlayerWeaponNames[] = {
"Fist",
"Brass Knuckles",
"Golf Club",
"Nite Stick",
"Knife",
"Baseball Bat",
"Shovel",
"Pool Cue",
"Katana",
"Chainsaw",
"Dildo",
"Dildo",
"Vibrator",
"Vibrator",
"Flowers",
"Cane",
"Grenade",
"Teargas",
"Molotov Cocktail", // 18
"Invalid",
"Invalid",
"Invalid",
"Colt 45", // 22
"Silenced Pistol",
"Desert Eagle",
"Shotgun",
"Sawn-off Shotgun",
"Combat Shotgun",
"UZI",
"MP5",
"AK47",
"M4",
"TEC9",
"Rifle",
"Sniper Rifle",
"Rocket Launcher",
"Heat Seaker",
"Flamethrower",
"Minigun",
"Satchel Explosives",
"Bomb",
"Spray Can",
"Fire Extinguisher",
"Camera",
"Night Vision Goggles",
"Thermal Goggles",
"Parachute", // 46
"Invalid",
"Invalid",
"Vehicle", // 49
"Helicopter Blades", // 50
"Explosion", // 51
"Invalid",
"Drowned", // 53
"Splat"
};
static const StringView BodyPartString[] = {
"invalid",
"invalid",
"invalid",
"torso",
"groin",
"left arm",
"right arm",
"left leg",
"right leg",
"head"
};
struct PlayerKeyData
{
// todo fill with union
uint32_t keys;
int16_t upDown;
int16_t leftRight;
};
struct PlayerAnimationData
{
uint16_t ID;
uint16_t flags;
inline Pair<StringView, StringView> name() const
{
return splitAnimationNames(ID);
}
};
struct PlayerSurfingData
{
enum class Type
{
None,
Vehicle,
Object,
PlayerObject
} type;
int ID;
Vector3 offset;
};
/// Holds information for each weapon
struct WeaponInfo
{
PlayerWeaponType type;
int slot;
float range;
int clipSize;
int shootTime;
int reloadTime;
// Get information of a specific weapon
static const WeaponInfo& get(uint8_t weapon);
};
constexpr StaticArray<WeaponInfo, MAX_WEAPON_ID> WeaponInfoList = { {
{ PlayerWeaponType_Melee, 0, 1.6f, 0, 250, 0 }, // 0
{ PlayerWeaponType_Melee, 0, 1.6f, 0, 250, 0 }, // 1
{ PlayerWeaponType_Melee, 1, 1.6f, 0, 250, 0 }, // 2
{ PlayerWeaponType_Melee, 1, 1.6f, 0, 250, 0 }, // 3
{ PlayerWeaponType_Melee, 1, 1.6f, 0, 250, 0 }, // 4
{ PlayerWeaponType_Melee, 1, 1.6f, 0, 250, 0 }, // 5
{ PlayerWeaponType_Melee, 1, 1.6f, 0, 250, 0 }, // 6
{ PlayerWeaponType_Melee, 1, 1.6f, 0, 250, 0 }, // 7
{ PlayerWeaponType_Melee, 1, 1.6f, 0, 250, 0 }, // 8
{ PlayerWeaponType_Melee, 1, 1.6f, 0, 30, 0 }, // 9
{ PlayerWeaponType_Melee, 10, 1.6f, 0, 250, 0 }, // 10
{ PlayerWeaponType_Melee, 10, 1.6f, 0, 250, 0 }, // 11
{ PlayerWeaponType_Melee, 10, 1.6f, 0, 250, 0 }, // 12
{ PlayerWeaponType_Melee, 10, 1.6f, 0, 250, 0 }, // 13
{ PlayerWeaponType_Melee, 10, 1.6f, 0, 250, 0 }, // 14
{ PlayerWeaponType_Melee, 10, 1.6f, 0, 250, 0 }, // 15
{ PlayerWeaponType_Throwable, 8, 40.0f, 1, 500, 0 }, // 16
{ PlayerWeaponType_Throwable, 8, 40.0f, 1, 500, 0 }, // 17
{ PlayerWeaponType_Throwable, 8, 40.0f, 1, 500, 0 }, // 18
{ PlayerWeaponType_None, INVALID_WEAPON_SLOT, 0.0f, 0, 0, 0 }, // 19
{ PlayerWeaponType_None, INVALID_WEAPON_SLOT, 0.0f, 0, 0, 0 }, // 20
{ PlayerWeaponType_None, INVALID_WEAPON_SLOT, 0.0f, 0, 0, 0 }, // 21
{ PlayerWeaponType_Bullet, 2, 35.0f, 17, 350, 1300 }, // 22
{ PlayerWeaponType_Bullet, 2, 35.0f, 17, 450, 1300 }, // 23
{ PlayerWeaponType_Bullet, 2, 35.0f, 7, 950, 1300 }, // 24
{ PlayerWeaponType_Bullet, 3, 40.0f, 1, 1100, 0 }, // 25
{ PlayerWeaponType_Bullet, 3, 35.0f, 2, 300, 1300 }, // 26
{ PlayerWeaponType_Bullet, 3, 40.0f, 7, 400, 1500 }, // 27
{ PlayerWeaponType_Bullet, 4, 35.0f, 50, 110, 1500 }, // 28
{ PlayerWeaponType_Bullet, 4, 45.0f, 30, 95, 1650 }, // 29
{ PlayerWeaponType_Bullet, 5, 70.0f, 30, 120, 1900 }, // 30
{ PlayerWeaponType_Bullet, 5, 90.0f, 50, 120, 1900 }, // 31
{ PlayerWeaponType_Bullet, 4, 35.0f, 50, 110, 1500 }, // 32
{ PlayerWeaponType_Bullet, 6, 100.0f, 1, 1050, 0 }, // 33
{ PlayerWeaponType_Bullet, 6, 100.0f, 1, 1050, 0 }, // 34
{ PlayerWeaponType_Rocket, 7, 55.0f, 1, 1050, 0 }, // 35
{ PlayerWeaponType_Rocket, 7, 55.0f, 1, 1050, 0 }, // 36
{ PlayerWeaponType_Sprayable, 7, 5.1f, 500, 500, 500 }, // 37
{ PlayerWeaponType_Bullet, 7, 75.0f, 500, 20, 200 }, // 38
{ PlayerWeaponType_Special, 8, 40.0f, 1, 500, 0 }, // 39
{ PlayerWeaponType_Special, 12, 25.0f, 1, 500, 0 }, // 40
{ PlayerWeaponType_Sprayable, 9, 6.1f, 500, 10, 200 }, // 41
{ PlayerWeaponType_Sprayable, 9, 10.1f, 500, 10, 200 }, // 42
{ PlayerWeaponType_Special, 9, 100.0f, 1, 1200, 0 }, // 43
{ PlayerWeaponType_Special, 11, 200.0f, 0, 1500, 0 }, // 44
{ PlayerWeaponType_Special, 11, 200.0f, 0, 1500, 0 }, // 45
{ PlayerWeaponType_Special, 11, 1.6f, 1, 1500, 0 } // 46
} };
inline const WeaponInfo& WeaponInfo::get(uint8_t weapon)
{
if (weapon >= WeaponInfoList.size())
{
static const WeaponInfo invalidData = { PlayerWeaponType_None, INVALID_WEAPON_SLOT, 0.0f, 0, 0, 0 };
return invalidData;
}
return WeaponInfoList[weapon];
}
/// Holds weapon slot data
struct WeaponSlotData
{
uint8_t id;
uint32_t ammo;
WeaponSlotData()
: id(0)
, ammo(0)
{
}
WeaponSlotData(uint8_t id)
: id(id)
, ammo(0)
{
}
WeaponSlotData(uint8_t id, uint32_t ammo)
: id(id)
, ammo(ammo)
{
}
int8_t slot()
{
if (id >= WeaponInfoList.size())
{
return INVALID_WEAPON_SLOT;
}
return WeaponInfoList[id].slot;
}
bool shootable() const
{
if (id >= WeaponInfoList.size())
{
return false;
}
return WeaponInfoList[id].type == PlayerWeaponType_Bullet;
}
};
/// An array of weapon slots
typedef StaticArray<WeaponSlotData, MAX_WEAPON_SLOTS> WeaponSlots;
enum PlayerWeaponState : int8_t
{
PlayerWeaponState_Unknown = -1,
PlayerWeaponState_NoBullets,
PlayerWeaponState_LastBullet,
PlayerWeaponState_MoreBullets,
PlayerWeaponState_Reloading
};
struct PlayerAimData
{
Vector3 camFrontVector;
Vector3 camPos;
float aimZ;
float camZoom;
float aspectRatio;
PlayerWeaponState weaponState;
uint8_t camMode;
};
struct PlayerBulletData
{
Vector3 origin;
Vector3 hitPos;
Vector3 offset;
uint8_t weapon;
PlayerBulletHitType hitType;
uint16_t hitID;
};
struct PlayerSpectateData
{
enum ESpectateType
{
None,
Vehicle,
Player
};
bool spectating;
int spectateID;
ESpectateType type;
bool leftSpectating;
};
struct IPlayerPool;
struct IPlayer;
/// The player's name status returned when updating their name
enum EPlayerNameStatus
{
Updated, ///< The name has successfully been updated
Taken, ///< The name is already taken by another player
Invalid ///< The name is invalid
};
/// A player interface
struct IPlayer : public IExtensible, public IEntity
{
/// Kick the player
virtual void kick() = 0;
/// Ban the player
virtual void ban(StringView reason = StringView()) = 0;
/// Get whether the player is a bot (NPC)
virtual bool isBot() const = 0;
virtual const PeerNetworkData& getNetworkData() const = 0;
/// Get the peer's ping from their network
unsigned getPing() const
{
return getNetworkData().network->getPing(*this);
}
/// Attempt to send a packet to the network peer
/// @param bs The bit stream with data to send
bool sendPacket(Span<uint8_t> data, int channel, bool dispatchEvents = true)
{
return getNetworkData().network->sendPacket(*this, data, channel, dispatchEvents);
}
/// Attempt to send an RPC to the network peer
/// @param id The RPC ID for the current network
/// @param bs The bit stream with data to send
bool sendRPC(int id, Span<uint8_t> data, int channel, bool dispatchEvents = true)
{
return getNetworkData().network->sendRPC(*this, id, data, channel, dispatchEvents);
}
/// Attempt to broadcast an RPC derived from NetworkPacketBase to the player's streamed peers
/// @param packet The packet to send
virtual void broadcastRPCToStreamed(int id, Span<uint8_t> data, int channel, bool skipFrom = false) const = 0;
/// Attempt to broadcast a packet derived from NetworkPacketBase to the player's streamed peers
/// @param packet The packet to send
virtual void broadcastPacketToStreamed(Span<uint8_t> data, int channel, bool skipFrom = true) const = 0;
/// Broadcast sync packet
virtual void broadcastSyncPacket(Span<uint8_t> data, int channel) const = 0;
/// Immediately spawn the player
virtual void spawn() = 0;
/// Get the player's client version
virtual ClientVersion getClientVersion() const = 0;
/// Get player's client verison name
virtual StringView getClientVersionName() const = 0;
/// Set the player's position with the proper Z coordinate for the map
virtual void setPositionFindZ(Vector3 pos) = 0;
/// Set the player's camera position
virtual void setCameraPosition(Vector3 pos) = 0;
/// Get the player's camera position
virtual Vector3 getCameraPosition() = 0;
/// Set the direction a player's camera looks at
virtual void setCameraLookAt(Vector3 pos, int cutType) = 0;
/// Get the direction a player's camera looks at
virtual Vector3 getCameraLookAt() = 0;
/// Sets the camera to a place behind the player
virtual void setCameraBehind() = 0;
/// Interpolate camera position
virtual void interpolateCameraPosition(Vector3 from, Vector3 to, int time, PlayerCameraCutType cutType) = 0;
/// Interpolate camera look at
virtual void interpolateCameraLookAt(Vector3 from, Vector3 to, int time, PlayerCameraCutType cutType) = 0;
/// Attach player's camera to an object
virtual void attachCameraToObject(IObject& object) = 0;
/// Attach player's camera to a player object
virtual void attachCameraToObject(IPlayerObject& object) = 0;
/// Set the player's name
/// @return The player's new name status
virtual EPlayerNameStatus setName(StringView name) = 0;
/// Get the player's name
virtual StringView getName() const = 0;
/// Get the player's serial (gpci)
virtual StringView getSerial() const = 0;
/// Give a weapon to the player
virtual void giveWeapon(WeaponSlotData weapon) = 0;
/// Removes player weapon
virtual void removeWeapon(uint8_t weapon) = 0;
/// Set the player's ammo for a weapon
virtual void setWeaponAmmo(WeaponSlotData data) = 0;
/// Get player's weapons
virtual const WeaponSlots& getWeapons() const = 0;
/// Get single weapon
virtual WeaponSlotData getWeaponSlot(int slot) = 0;
/// Reset the player's weapons
virtual void resetWeapons() = 0;
/// Set the player's currently armed weapon
virtual void setArmedWeapon(uint32_t weapon) = 0;
/// Get the player's currently armed weapon
virtual uint32_t getArmedWeapon() const = 0;
/// Get the player's currently armed weapon ammo
virtual uint32_t getArmedWeaponAmmo() const = 0;
/// Set the player's shop name
virtual void setShopName(StringView name) = 0;
/// Get the player's shop name
virtual StringView getShopName() const = 0;
/// Set the player's drunk level
virtual void setDrunkLevel(int level) = 0;
/// Get the player's drunk level
virtual int getDrunkLevel() const = 0;
/// Set the player's colour
virtual void setColour(Colour colour) = 0;
/// Get the player's colour
virtual const Colour& getColour() const = 0;
/// Set another player's colour for this player
virtual void setOtherColour(IPlayer& other, Colour colour) = 0;
/// Get another player's colour for this player
virtual bool getOtherColour(IPlayer& other, Colour& colour) const = 0;
/// Set whether the player is controllable
virtual void setControllable(bool controllable) = 0;
/// Get whether the player is controllable
virtual bool getControllable() const = 0;
/// Set whether the player is spectating
virtual void setSpectating(bool spectating) = 0;
/// Set the player's wanted level
virtual void setWantedLevel(unsigned level) = 0;
/// Get the player's wanted level
virtual unsigned getWantedLevel() const = 0;
/// Play a sound for the player at a position
/// @param sound The sound ID
/// @param pos The position to play at
virtual void playSound(uint32_t sound, Vector3 pos) = 0;
/// Get the sound that was last played
virtual uint32_t lastPlayedSound() const = 0;
/// Play an audio stream for the player
/// @param url The HTTP URL of the stream
/// @param[opt] usePos Whether to play in a radius at a specific position
/// @param pos The position to play at
/// @param distance The distance to play at
virtual void playAudio(StringView url, bool usePos = false, Vector3 pos = Vector3(0.f), float distance = 0.f) = 0;
virtual bool playerCrimeReport(IPlayer& suspect, int crime) = 0;
/// Stop playing audio stream for the player
virtual void stopAudio() = 0;
/// Get the player's last played audio URL
virtual StringView lastPlayedAudio() const = 0;
// Create an explosion
virtual void createExplosion(Vector3 vec, int type, float radius) = 0;
// Send Death message
virtual void sendDeathMessage(IPlayer& player, IPlayer* killer, int weapon) = 0;
/// Send empty death message
virtual void sendEmptyDeathMessage() = 0;
/// Remove default map objects with a model in a radius at a specific position
/// @param model The object model to remove
/// @param pos The position to remove at
/// @param radius The radius to remove around
virtual void removeDefaultObjects(unsigned model, Vector3 pos, float radius) = 0;
/// Force class selection for the player
virtual void forceClassSelection() = 0;
/// Set the player's money
virtual void setMoney(int money) = 0;
/// Give money to the player
virtual void giveMoney(int money) = 0;
/// Reset the player's money to 0
virtual void resetMoney() = 0;
/// Get the player's money
virtual int getMoney() = 0;
/// Set a map icon for the player
virtual void setMapIcon(int id, Vector3 pos, int type, Colour colour, MapIconStyle style) = 0;
/// Unset a map icon for the player
virtual void unsetMapIcon(int id) = 0;
/// Toggle stunt bonus for the player
virtual void useStuntBonuses(bool enable) = 0;
/// Toggle another player's name tag for the player
virtual void toggleOtherNameTag(IPlayer& other, bool toggle) = 0;
/// Set the player's game time
/// @param hr The hours from 0 to 23
/// @param min The minutes from 0 to 59
virtual void setTime(Hours hr, Minutes min) = 0;
/// Get the player's game time
virtual Pair<Hours, Minutes> getTime() const = 0;
/// Toggle the player's clock visibility
virtual void useClock(bool enable) = 0;
/// Get whether the clock is visible for the player
virtual bool hasClock() const = 0;
/// Toggle widescreen for player
virtual void useWidescreen(bool enable) = 0;
/// Get widescreen status from player
virtual bool hasWidescreen() const = 0;
/// Set the transform applied to player rotation
virtual void setTransform(GTAQuat tm) = 0;
/// Set the player's health
virtual void setHealth(float health) = 0;
/// Get the player's health
virtual float getHealth() const = 0;
/// Set the player's score
virtual void setScore(int score) = 0;
/// Get the player's score
virtual int getScore() const = 0;
/// Set the player's armour
virtual void setArmour(float armour) = 0;
/// Get the player's armour
virtual float getArmour() const = 0;
/// Set the player's gravity
virtual void setGravity(float gravity) = 0;
/// Get player's gravity
virtual float getGravity() const = 0;
/// Set the player's world time
virtual void setWorldTime(Hours time) = 0;
/// Apply an animation to the player
/// @param animation The animation to apply
/// @param syncType How to sync the animation
virtual void applyAnimation(const AnimationData& animation, PlayerAnimationSyncType syncType) = 0;
/// Clear the player's animation
/// @param syncType How to sync the animation
virtual void clearAnimations(PlayerAnimationSyncType syncType) = 0;
/// Get the player's animation data
virtual PlayerAnimationData getAnimationData() const = 0;
/// Get the player's surf data
virtual PlayerSurfingData getSurfingData() const = 0;
/// Stream in the player for another player
/// @param other The player to stream in
virtual void streamInForPlayer(IPlayer& other) = 0;
/// Check if a player is streamed in for the current player
virtual bool isStreamedInForPlayer(const IPlayer& other) const = 0;
/// Stream out a player for the current player
/// @param other The player to stream out
virtual void streamOutForPlayer(IPlayer& other) = 0;
/// Get the players which are streamed in for this player
virtual const FlatPtrHashSet<IPlayer>& streamedForPlayers() const = 0;
/// Get the player's state
virtual PlayerState getState() const = 0;
/// Set the player's team
virtual void setTeam(int team) = 0;
/// Get the player's team
virtual int getTeam() const = 0;
/// Set the player's skin
virtual void setSkin(int skin, bool send = true) = 0;
/// Get the player's skin
virtual int getSkin() const = 0;
virtual void setChatBubble(StringView text, const Colour& colour, float drawDist, Milliseconds expire) = 0;
/// Send a message to the player
virtual void sendClientMessage(const Colour& colour, StringView message) = 0;
/// Send a standardly formatted chat message from another player
virtual void sendChatMessage(IPlayer& sender, StringView message) = 0;
/// Send a command to server (Player)
virtual void sendCommand(StringView message) = 0;
/// Send a game text message to the player
virtual void sendGameText(StringView message, Milliseconds time, int style) = 0;
/// Hide a game text message from the player
virtual void hideGameText(int style) = 0;
/// Check if the player can currently see this game text.
virtual bool hasGameText(int style) = 0;
/// Get the data for this gametext, if they have one.
virtual bool getGameText(int style, StringView& message, Milliseconds& time, Milliseconds& remaining) = 0;
/// Set the player's weather
virtual void setWeather(int weatherID) = 0;
/// Get the player's weather
virtual int getWeather() const = 0;
/// Set world bounds
virtual void setWorldBounds(Vector4 coords) = 0;
/// Get world bounds
virtual Vector4 getWorldBounds() const = 0;
/// Set the player's fighting style
/// @note See https://open.mp/docs/scripting/resources/fightingstyles
virtual void setFightingStyle(PlayerFightingStyle style) = 0;
/// Get the player's fighting style
/// @note See https://open.mp/docs/scripting/resources/fightingstyles
virtual PlayerFightingStyle getFightingStyle() const = 0;
/// Set the player's skill level
/// @note See https://open.mp/docs/scripting/resources/weaponskills
/// @param skill The skill type
/// @param level The skill level
virtual void setSkillLevel(PlayerWeaponSkill skill, int level) = 0;
/// Set the player's special action
virtual void setAction(PlayerSpecialAction action) = 0;
/// Get the player's special action
virtual PlayerSpecialAction getAction() const = 0;
/// Set the player's velocity
virtual void setVelocity(Vector3 velocity) = 0;
/// Get the player's velocity
virtual Vector3 getVelocity() const = 0;
/// Set the player's interior
virtual void setInterior(unsigned interior) = 0;
/// Get the player's interior
virtual unsigned getInterior() const = 0;
/// Get the player's key data
virtual const PlayerKeyData& getKeyData() const = 0;
/// Get the player's skill levels
/// @note See https://open.mp/docs/scripting/resources/weaponskills
virtual const StaticArray<uint16_t, NUM_SKILL_LEVELS>& getSkillLevels() const = 0;
/// Get the player's aim data
virtual const PlayerAimData& getAimData() const = 0;
/// Get the player's bullet data
virtual const PlayerBulletData& getBulletData() const = 0;
/// Toggle the camera targeting functions for the player
virtual void useCameraTargeting(bool enable) = 0;
/// Get whether the player has camera targeting functions enabled
virtual bool hasCameraTargeting() const = 0;
/// Remove the player from their vehicle
virtual void removeFromVehicle(bool force) = 0;
/// Get the player the player is looking at or nullptr if none
virtual IPlayer* getCameraTargetPlayer() = 0;
/// Get the vehicle the player is looking at or nullptr if none
virtual IVehicle* getCameraTargetVehicle() = 0;
/// Get the object the player is looking at or nullptr if none
virtual IObject* getCameraTargetObject() = 0;
/// Get the actor the player is looking at or nullptr if none
virtual IActor* getCameraTargetActor() = 0;
/// Get the player the player is targeting or nullptr if none
virtual IPlayer* getTargetPlayer() = 0;
/// Get the actor the player is targeting or nullptr if none
virtual IActor* getTargetActor() = 0;
/// Disable remote vehicle collision detection for this player.
virtual void setRemoteVehicleCollisions(bool collide) = 0;
/// Make player spectate another player
virtual void spectatePlayer(IPlayer& target, PlayerSpectateMode mode) = 0;
/// Make player spectate a vehicle
virtual void spectateVehicle(IVehicle& target, PlayerSpectateMode mode) = 0;
/// Get spectate data
virtual const PlayerSpectateData& getSpectateData() const = 0;
/// Send client check (asks for certain data depending on type of action)
virtual void sendClientCheck(int actionType, int address, int offset, int count) = 0;
/// Toggle player's collision for other players
virtual void toggleGhostMode(bool toggle) = 0;
/// Get player's collision status (ghost mode)
virtual bool isGhostModeEnabled() const = 0;
/// Get default objects removed array size (basically just how many times removeDefaultObject is called)
virtual int getDefaultObjectsRemovedCount() const = 0;
/// Get if player is kicked or not (about to be disconnected)
virtual bool getKickStatus() const = 0;
/// Clear player tasks
virtual void clearTasks(PlayerAnimationSyncType syncType) = 0;
/// Allow player to use weapons
virtual void allowWeapons(bool allow) = 0;
/// Check if player is allowed to use weapons
virtual bool areWeaponsAllowed() const = 0;
/// Teleport the player when they click the map
virtual void allowTeleport(bool allow) = 0;
/// Does the player teleport when they click the map
virtual bool isTeleportAllowed() const = 0;
/// Check if player is using an official client or not
virtual bool isUsingOfficialClient() const = 0;
/// Check if player is using omp or not
virtual bool isUsingOmp() const = 0;
/// Check if player is leaving spectator mode
virtual bool isLeavingSpectatorMode() const = 0;
virtual bool isDefaultObjectRemoved(unsigned model, Vector3 pos, float radius) const = 0;
};
/// Player spawn event handlers
struct PlayerSpawnEventHandler
{
virtual bool onPlayerRequestSpawn(IPlayer& player) { return true; }
virtual void onPlayerSpawn(IPlayer& player) { }
};
/// Player connection event handlers
struct PlayerConnectEventHandler
{
virtual void onIncomingConnection(IPlayer& player, StringView ipAddress, unsigned short port) { }
virtual void onPlayerConnect(IPlayer& player) { }
virtual void onPlayerDisconnect(IPlayer& player, PeerDisconnectReason reason) { }
virtual void onPlayerClientInit(IPlayer& player) { }
};
/// Player streaming event handlers
struct PlayerStreamEventHandler
{
virtual void onPlayerStreamIn(IPlayer& player, IPlayer& forPlayer) { }
virtual void onPlayerStreamOut(IPlayer& player, IPlayer& forPlayer) { }
};
/// Player text and commands event handlers
struct PlayerTextEventHandler
{
virtual bool onPlayerText(IPlayer& player, StringView message) { return true; }