1pub mod events;
2pub mod functions;
3
4pub use functions::load_functions;
5
6use crate::{
7 actors::Actor,
8 classes::{self, PlayerClass},
9 dialogs::{self, DialogStyle},
10 objects::{self, Object, ObjectAttachmentSlotData, PlayerObject},
11 textdraws::{self, PlayerTextDraw},
12 types::{
13 animationdata::AnimationData,
14 colour::Colour,
15 network::{NetworkID, NetworkStats},
16 staticarray::StaticArray,
17 vector::{Vector2, Vector3, Vector4},
18 },
19 vehicles::{self, Vehicle},
20};
21use std::os::raw::c_void;
22
23use super::{
24 checkpoints::{self, PlayerCheckPointData, PlayerRaceCheckPointData, RaceCheckpointType},
25 menus::{self, Menu},
26 textlabels::{self, PlayerTextLabel},
27};
28
29pub struct Player {
30 handle: *const c_void,
31}
32
33impl Player {
34 pub fn new(handle: *const c_void) -> Self {
35 Self { handle }
36 }
37
38 pub fn get_handle(&self) -> *const c_void {
39 self.handle
40 }
41
42 pub fn send_client_message(&self, colour: Colour, message: &str) {
44 functions::SendClientMessage(self, colour, message);
45 }
46
47 pub fn get_name(&self) -> String {
49 let mut name = String::new();
50 functions::GetPlayerName(self, &mut name);
51 name
52 }
53
54 pub fn set_camera_pos(&self, pos: Vector3) {
56 functions::SetPlayerCameraPos(self, pos);
57 }
58
59 pub fn set_drunk_level(&self, level: isize) {
61 functions::SetPlayerDrunkLevel(self, level);
62 }
63
64 pub fn set_interior(&self, interiorid: isize) {
66 functions::SetPlayerInterior(self, interiorid);
67 }
68
69 pub fn set_wanted_level(&self, level: isize) {
71 functions::SetPlayerWantedLevel(self, level);
72 }
73
74 pub fn set_weather(&self, weatherid: isize) {
76 functions::SetPlayerWeather(self, weatherid);
77 }
78
79 pub fn get_weather(&self) -> isize {
81 functions::GetPlayerWeather(self)
82 }
83
84 pub fn set_skin(&self, skinid: isize) {
86 functions::SetPlayerSkin(self, skinid);
87 }
88
89 pub fn set_shop_name(&self, shopname: &str) {
91 functions::SetPlayerShopName(self, shopname)
92 }
93
94 pub fn give_money(&self, amount: isize) {
96 functions::GivePlayerMoney(self, amount)
97 }
98
99 pub fn set_camera_look_at(&self, pos: Vector3, cut: PlayerCameraCutType) {
101 functions::SetPlayerCameraLookAt(self, pos, cut)
102 }
103
104 pub fn set_camera_behind_player(&self) {
106 functions::SetCameraBehindPlayer(self)
107 }
108
109 pub fn create_explosion(&self, pos: Vector3, explosion_type: isize, radius: f32) {
111 functions::CreateExplosionForPlayer(self, pos, explosion_type, radius);
112 }
113
114 pub fn play_audio_stream(&self, url: &str, pos: Vector3, distance: f32, use_pos: bool) {
116 functions::PlayAudioStreamForPlayer(self, url, pos, distance, use_pos);
117 }
118
119 pub fn stop_audio_stream(&self) {
121 functions::StopAudioStreamForPlayer(self)
122 }
123
124 pub fn send_death_message(&self, killee: &Player, weapon: PlayerWeapon) {
126 functions::SendDeathMessage(self, killee, weapon);
127 }
128
129 pub fn toggle_widescreen(&self, enable: bool) {
131 functions::TogglePlayerWidescreen(self, enable)
132 }
133
134 pub fn is_widescreen_toggled(&self) -> bool {
136 functions::IsPlayerWidescreenToggled(self)
137 }
138
139 pub fn set_health(&self, health: f32) {
141 functions::SetPlayerHealth(self, health);
142 }
143
144 pub fn get_health(&self) -> f32 {
146 functions::GetPlayerHealth(self)
147 }
148
149 pub fn set_armour(&self, armour: f32) {
151 functions::SetPlayerArmour(self, armour)
152 }
153
154 pub fn get_armour(&self) -> f32 {
156 functions::GetPlayerArmour(self)
157 }
158
159 pub fn set_team(&self, teamid: isize) {
161 functions::SetPlayerTeam(self, teamid)
162 }
163
164 pub fn get_team(&self) -> isize {
166 functions::GetPlayerTeam(self)
167 }
168
169 pub fn set_score(&self, score: isize) {
171 functions::SetPlayerScore(self, score)
172 }
173
174 pub fn get_score(&self) -> isize {
176 functions::GetPlayerScore(self)
177 }
178
179 pub fn get_skin(&self) -> isize {
181 functions::GetPlayerSkin(self)
182 }
183
184 pub fn set_color(&self, colour: Colour) {
186 functions::SetPlayerColor(self, colour)
187 }
188
189 pub fn get_color(&self) -> isize {
191 functions::GetPlayerColor(self)
192 }
193
194 pub fn get_default_colour(&self) -> isize {
196 functions::GetDefaultPlayerColour(self)
197 }
198
199 pub fn get_drunk_level(&self) -> isize {
201 functions::GetPlayerDrunkLevel(self)
202 }
203
204 pub fn give_weapon(&self, data: WeaponSlotData) {
206 functions::GivePlayerWeapon(self, data)
207 }
208
209 pub fn remove_weapon(&self, weaponid: u8) {
211 functions::RemovePlayerWeapon(self, weaponid)
212 }
213
214 pub fn get_money(&self) -> isize {
216 functions::GetPlayerMoney(self)
217 }
218
219 pub fn reset_money(&self) {
221 functions::ResetPlayerMoney(self)
222 }
223
224 pub fn set_name(&self, name: &str) -> PlayerNameStatus {
226 functions::SetPlayerName(self, name)
227 }
228
229 pub fn get_state(&self) -> PlayerState {
231 functions::GetPlayerState(self)
232 }
233
234 pub fn get_ping(&self) -> isize {
236 functions::GetPlayerPing(self)
237 }
238
239 pub fn get_weapon(&self) -> PlayerWeapon {
241 functions::GetPlayerWeapon(self)
242 }
243
244 pub fn set_time(&self, hour: isize, minute: isize) {
246 functions::SetPlayerTime(self, hour, minute)
247 }
248
249 pub fn get_time(&self) -> (isize, isize) {
251 let mut hour = 0;
252 let mut minute = 0;
253 functions::GetPlayerTime(self, &mut hour, &mut minute);
254 (hour, minute)
255 }
256
257 pub fn toggle_clock(&self, enable: bool) {
259 functions::TogglePlayerClock(self, enable)
260 }
261
262 pub fn has_clock_enabled(&self) -> bool {
264 functions::PlayerHasClockEnabled(self)
265 }
266
267 pub fn force_class_selection(&self) {
269 functions::ForceClassSelection(self)
270 }
271
272 pub fn get_wanted_level(&self) -> isize {
274 functions::GetPlayerWantedLevel(self)
275 }
276
277 pub fn set_fighting_style(&self, style: PlayerFightingStyle) {
279 functions::SetPlayerFightingStyle(self, style)
280 }
281
282 pub fn get_fighting_style(&self) -> PlayerFightingStyle {
284 functions::GetPlayerFightingStyle(self)
285 }
286
287 pub fn set_velocity(&self, pos: Vector3) {
289 functions::SetPlayerVelocity(self, pos)
290 }
291
292 pub fn get_velocity(&self) -> Vector3 {
294 let mut pos = Vector3 {
295 x: 0.0,
296 y: 0.0,
297 z: 0.0,
298 };
299 functions::GetPlayerVelocity(self, &mut pos);
300 pos
301 }
302
303 pub fn get_camera_pos(&self) -> Vector3 {
305 let mut pos = Vector3 {
306 x: 0.0,
307 y: 0.0,
308 z: 0.0,
309 };
310 functions::GetPlayerCameraPos(self, &mut pos);
311 pos
312 }
313
314 pub fn get_distance_from_point(&self, pos: Vector3) -> f32 {
316 functions::GetPlayerDistanceFromPoint(self, pos)
317 }
318
319 pub fn get_interior(&self) -> isize {
321 functions::GetPlayerInterior(self)
322 }
323
324 pub fn set_pos(&self, pos: Vector3) {
326 functions::SetPlayerPos(self, pos)
327 }
328
329 pub fn get_pos(&self) -> Vector3 {
331 let mut pos = Vector3 {
332 x: 0.0,
333 y: 0.0,
334 z: 0.0,
335 };
336 functions::GetPlayerPos(self, &mut pos);
337 pos
338 }
339
340 pub fn get_virtual_world(&self) -> isize {
342 functions::GetPlayerVirtualWorld(self)
343 }
344
345 pub fn is_npc(&self) -> bool {
347 functions::IsPlayerNPC(self)
348 }
349
350 pub fn is_streamed_in(&self, other: &Player) -> bool {
352 functions::IsPlayerStreamedIn(self, other)
353 }
354
355 pub fn play_sound(&self, sound: usize, pos: Vector3) {
357 functions::PlayerPlaySound(self, sound, pos)
358 }
359
360 pub fn spectate_player(&self, target: &Player, mode: PlayerSpectateMode) {
362 functions::PlayerSpectatePlayer(self, target, mode)
363 }
364
365 pub fn spectate_vehicle(&self, vehicle: &Vehicle, mode: PlayerSpectateMode) {
367 functions::PlayerSpectateVehicle(self, vehicle, mode)
368 }
369
370 pub fn set_virtual_world(&self, vw: isize) {
372 functions::SetPlayerVirtualWorld(self, vw)
373 }
374
375 pub fn set_world_bounds(&self, coords: Vector4) {
377 functions::SetPlayerWorldBounds(self, coords)
378 }
379
380 pub fn clear_world_bounds(&self) {
382 functions::ClearPlayerWorldBounds(self)
383 }
384
385 pub fn get_world_bounds(&self) -> Vector4 {
387 let mut pos = Vector4 {
388 x: 0.0,
389 y: 0.0,
390 z: 0.0,
391 w: 0.0,
392 };
393 functions::GetPlayerWorldBounds(self, &mut pos);
394 pos
395 }
396
397 pub fn clear_animations(&self, sync_type: PlayerAnimationSyncType) {
399 functions::ClearAnimations(self, sync_type)
400 }
401
402 pub fn get_last_shot_vectors(&self) -> PlayerBulletData {
404 functions::GetPlayerLastShotVectors(self)
405 }
406
407 pub fn get_camera_target_player(&self) -> Option<Player> {
409 functions::GetPlayerCameraTargetPlayer(self)
410 }
411
412 pub fn get_camera_target_actor(&self) -> Option<Actor> {
414 functions::GetPlayerCameraTargetActor(self)
415 }
416
417 pub fn get_camera_target_object(&self) -> Option<Object> {
419 functions::GetPlayerCameraTargetObject(self)
420 }
421
422 pub fn get_camera_target_vehicle(&self) -> Option<Vehicle> {
424 functions::GetPlayerCameraTargetVehicle(self)
425 }
426
427 pub fn put_in_vehicle(&self, vehicle: &Vehicle, seat_id: isize) {
429 functions::PutPlayerInVehicle(self, vehicle, seat_id)
430 }
431
432 pub fn remove_building(&self, model: isize, pos: Vector3, radius: f32) {
434 functions::RemoveBuildingForPlayer(self, model, pos, radius)
435 }
436
437 pub fn get_buildings_removed(&self) -> isize {
439 functions::GetPlayerBuildingsRemoved(self)
440 }
441
442 pub fn remove_from_vehicle(&self, force: bool) {
444 functions::RemovePlayerFromVehicle(self, force)
445 }
446
447 pub fn remove_map_icon(&self, icon_id: isize) {
449 functions::RemovePlayerMapIcon(self, icon_id)
450 }
451
452 pub fn set_map_icon(
454 &self,
455 icon_id: isize,
456 pos: Vector3,
457 icon_type: isize,
458 colour: Colour,
459 style: MapIconStyle,
460 ) {
461 functions::SetPlayerMapIcon(self, icon_id, pos, icon_type, colour, style)
462 }
463
464 pub fn reset_weapons(&self) {
466 functions::ResetPlayerWeapons(self)
467 }
468
469 pub fn set_ammo(&self, data: WeaponSlotData) {
471 functions::SetPlayerAmmo(self, data)
472 }
473
474 pub fn set_armed_weapon(&self, weapon: PlayerWeapon) {
476 functions::SetPlayerArmedWeapon(self, weapon)
477 }
478
479 pub fn set_chat_bubble(
481 &self,
482 text: &str,
483 colour: Colour,
484 drawdistance: f32,
485 expiretime: isize,
486 ) {
487 functions::SetPlayerChatBubble(self, text, colour, drawdistance, expiretime)
488 }
489
490 pub fn set_pos_find_z(&self, pos: Vector3) {
492 functions::SetPlayerPosFindZ(self, pos)
493 }
494
495 pub fn set_skill_level(&self, weapon: PlayerWeaponSkill, level: isize) {
497 functions::SetPlayerSkillLevel(self, weapon, level)
498 }
499
500 pub fn set_special_action(&self, action: PlayerSpecialAction) {
502 functions::SetPlayerSpecialAction(self, action)
503 }
504
505 pub fn show_name_tag(&self, other: &Player, enable: bool) {
507 functions::ShowPlayerNameTagForPlayer(self, other, enable)
508 }
509
510 pub fn toggle_controllable(&self, enable: bool) {
512 functions::TogglePlayerControllable(self, enable)
513 }
514
515 pub fn toggle_spectating(&self, enable: bool) {
517 functions::TogglePlayerSpectating(self, enable)
518 }
519
520 pub fn apply_animation(&self, animation_data: AnimationData, sync: PlayerAnimationSyncType) {
522 functions::ApplyAnimation(
523 self,
524 &animation_data.get_animation_library(),
525 &animation_data.get_name(),
526 animation_data.delta,
527 animation_data.looping,
528 animation_data.lockX,
529 animation_data.lockY,
530 animation_data.freeze,
531 animation_data.time,
532 sync,
533 )
534 }
535
536 pub fn edit_attached_object(&self, index: isize) {
538 functions::EditAttachedObject(self, index)
539 }
540
541 pub fn enable_camera_target(&self, enable: bool) {
543 functions::EnablePlayerCameraTarget(self, enable)
544 }
545
546 pub fn enable_stunt_bonus(&self, enable: bool) {
548 functions::EnableStuntBonusForPlayer(self, enable)
549 }
550
551 pub fn get_ammo(&self) -> isize {
553 functions::GetPlayerAmmo(self)
554 }
555
556 pub fn get_animation_index(&self) -> isize {
558 functions::GetPlayerAnimationIndex(self)
559 }
560
561 pub fn get_facing_angle(&self) -> f32 {
563 functions::GetPlayerFacingAngle(self)
564 }
565
566 pub fn get_ip(&self) -> String {
568 let mut ip = String::new();
569 functions::GetPlayerIp(self, &mut ip);
570 ip
571 }
572
573 pub fn get_special_action(&self) -> PlayerSpecialAction {
575 functions::GetPlayerSpecialAction(self)
576 }
577
578 pub fn get_vehicle_id(&self) -> isize {
580 functions::GetPlayerVehicleID(self)
581 }
582
583 pub fn get_vehicle_seat(&self) -> isize {
585 functions::GetPlayerVehicleSeat(self)
586 }
587
588 pub fn get_weapon_data(&self, slot: isize) -> WeaponSlotData {
590 let mut weapon: WeaponSlotData = WeaponSlotData {
591 ammo: 0,
592 id: PlayerWeapon::Fist,
593 };
594 functions::GetPlayerWeaponData(self, slot, &mut weapon);
595 weapon
596 }
597
598 pub fn get_weapon_state(&self) -> isize {
600 functions::GetPlayerWeaponState(self)
601 }
602
603 pub fn interpolate_camera_pos(
605 &self,
606 from: Vector3,
607 to: Vector3,
608 time: isize,
609 cut: PlayerCameraCutType,
610 ) {
611 functions::InterpolateCameraPos(self, from, to, time, cut)
612 }
613
614 pub fn interpolate_camera_look_at(
616 &self,
617 from: Vector3,
618 to: Vector3,
619 time: isize,
620 cut: PlayerCameraCutType,
621 ) -> bool {
622 functions::InterpolateCameraLookAt(self, from, to, time, cut)
623 }
624
625 pub fn is_attached_object_slot_used(&self, index: isize) -> bool {
627 functions::IsPlayerAttachedObjectSlotUsed(self, index)
628 }
629
630 pub fn attach_camera_to_object(&self, object: &Object) {
632 functions::AttachCameraToObject(self, object)
633 }
634
635 pub fn attach_camera_to_player_object(&self, object: &PlayerObject) {
637 functions::AttachCameraToPlayerObject(self, object)
638 }
639
640 pub fn get_aim_data(&self) -> PlayerAimData {
641 functions::GetPlayerAimData(self)
642 }
643
644 pub fn get_keys(&self) -> PlayerKeyData {
646 let mut keys = 0;
647 let mut updown = 0;
648 let mut leftright = 0;
649 functions::GetPlayerKeys(self, &mut keys, &mut updown, &mut leftright)
650 }
651
652 pub fn get_surfing_data(&self) -> PlayerSurfingData {
653 functions::GetPlayerSurfingData(self)
654 }
655
656 pub fn get_target_player(&self) -> Option<Player> {
658 functions::GetPlayerTargetPlayer(self)
659 }
660
661 pub fn get_target_actor(&self) -> Option<Actor> {
663 functions::GetPlayerTargetActor(self)
664 }
665
666 pub fn is_in_vehicle(&self, target_vehicle: &Vehicle) -> bool {
668 functions::IsPlayerInVehicle(self, target_vehicle)
669 }
670
671 pub fn is_in_any_vehicle(&self) -> bool {
673 functions::IsPlayerInAnyVehicle(self)
674 }
675
676 pub fn is_in_range_of_point(&self, range: f32, coord: Vector3) -> bool {
678 functions::IsPlayerInRangeOfPoint(self, range, coord)
679 }
680
681 pub fn play_crime_report(&self, suspect: &Player, crime: isize) -> bool {
683 functions::PlayCrimeReportForPlayer(self, suspect, crime)
684 }
685
686 pub fn remove_attached_object(&self, index: isize) {
688 functions::RemovePlayerAttachedObject(self, index)
689 }
690
691 pub fn set_facing_angle(&self, angle: f32) {
693 functions::SetPlayerFacingAngle(self, angle)
694 }
695
696 pub fn set_marker_for_player(&self, other: &Player, colour: Colour) {
698 functions::SetPlayerMarkerForPlayer(self, other, colour)
699 }
700
701 pub fn get_marker_for_player(&self, other: &Player) -> isize {
703 functions::GetPlayerMarkerForPlayer(self, other)
704 }
705
706 pub fn allow_teleport(&self, allow: bool) {
708 functions::AllowPlayerTeleport(self, allow)
709 }
710
711 pub fn is_teleport_allowed(&self) -> bool {
713 functions::IsPlayerTeleportAllowed(self)
714 }
715
716 pub fn set_remote_vehicle_collisions(&self, collide: bool) {
717 functions::SetRemoteVehicleCollisions(self, collide)
718 }
719
720 pub fn select_text_draw(&self, hover_colour: Colour) {
722 functions::SelectTextDraw(self, hover_colour)
723 }
724
725 pub fn cancel_select_text_draw(&self) {
727 functions::CancelSelectTextDraw(self)
728 }
729
730 pub fn send_client_check(
732 &self,
733 action_type: isize,
734 address: isize,
735 offset: isize,
736 count: isize,
737 ) {
738 functions::SendClientCheck(self, action_type, address, offset, count)
739 }
740
741 pub fn spawn(&self) {
743 functions::SpawnPlayer(self)
744 }
745
746 pub fn gpci(&self) -> String {
748 let mut output = String::new();
749 functions::gpci(self, &mut output);
750 output
751 }
752
753 pub fn is_admin(&self) -> bool {
755 functions::IsPlayerAdmin(self)
756 }
757 pub fn kick(&self) {
759 functions::Kick(self)
760 }
761
762 pub fn game_text(&self, msg: &str, time: isize, style: isize) {
764 functions::GameTextForPlayer(self, msg, time, style)
765 }
766
767 pub fn hide_game_text(&self, style: isize) {
769 functions::HideGameTextForPlayer(self, style)
770 }
771
772 pub fn has_game_text(&self, style: isize) -> bool {
774 functions::HasGameText(self, style)
775 }
776
777 pub fn get_game_text(
779 &self,
780 style: isize,
781 message: &mut String,
782 time: &mut isize,
783 remaining: &mut isize,
784 ) -> bool {
785 functions::GetGameText(self, style, message, time, remaining)
786 }
787
788 pub fn ban(&self) {
790 functions::Ban(self)
791 }
792
793 pub fn ban_ex(&self, msg: &str) {
795 functions::BanEx(self, msg)
796 }
797
798 pub fn send_death_message_to_player(
800 &self,
801 killer: &Player,
802 killee: &Player,
803 weapon: PlayerWeapon,
804 ) {
805 functions::SendDeathMessageToPlayer(self, killer, killee, weapon)
806 }
807
808 pub fn send_message_to_player(&self, sender: &Player, message: &str) {
810 functions::SendPlayerMessageToPlayer(self, sender, message)
811 }
812
813 pub fn get_version(&self, output: &mut String) {
815 functions::GetPlayerVersion(self, output)
816 }
817
818 pub fn get_skill_level(&self, skill: isize) -> isize {
820 functions::GetPlayerSkillLevel(self, skill)
821 }
822
823 pub fn get_spectate_id(&self) -> isize {
825 functions::GetPlayerSpectateID(self)
826 }
827
828 pub fn get_spectate_data(&self) -> PlayerSpectateData {
829 functions::GetPlayerSpectateData(self)
830 }
831
832 pub fn get_raw_ip(&self) -> isize {
834 functions::GetPlayerRawIp(self)
835 }
836
837 pub fn set_gravity(&self, gravity: f32) {
839 functions::SetPlayerGravity(self, gravity)
840 }
841
842 pub fn get_gravity(&self) -> f32 {
844 functions::GetPlayerGravity(self)
845 }
846
847 pub fn set_admin(&self, set: bool) {
849 functions::SetPlayerAdmin(self, set)
850 }
851
852 pub fn is_spawned(&self) -> bool {
854 functions::IsPlayerSpawned(self)
855 }
856
857 pub fn is_controllable(&self) -> bool {
859 functions::IsPlayerControllable(self)
860 }
861
862 pub fn is_camera_target_enabled(&self) -> bool {
864 functions::IsPlayerCameraTargetEnabled(self)
865 }
866
867 pub fn toggle_ghost_mode(&self, toggle: bool) {
869 functions::TogglePlayerGhostMode(self, toggle)
870 }
871
872 pub fn get_ghost_mode(&self) -> bool {
874 functions::GetPlayerGhostMode(self)
875 }
876
877 pub fn allow_weapons(&self, allow: bool) {
879 functions::AllowPlayerWeapons(self, allow)
880 }
881
882 pub fn are_weapons_allowed(&self) -> bool {
884 functions::ArePlayerWeaponsAllowed(self)
885 }
886
887 pub fn is_using_official_client(&self) -> bool {
889 functions::IsPlayerUsingOfficialClient(self)
890 }
891
892 pub fn get_animation_data(&self) -> PlayerAnimationData {
893 functions::GetPlayerAnimationData(self)
894 }
895
896 pub fn is_in_drive_by_mode(&self) -> bool {
898 functions::IsPlayerInDriveByMode(self)
899 }
900
901 pub fn is_cuffed(&self) -> bool {
903 functions::IsPlayerCuffed(self)
904 }
905
906 pub fn get_custom_skin(&self) -> isize {
908 functions::GetPlayerCustomSkin(self)
909 }
910
911 pub fn redirect_download(&self, url: &str) -> bool {
913 functions::RedirectDownload(self, url)
914 }
915
916 pub fn set_player_checkpoint(&self, centre_position: Vector3, radius: f32) {
919 checkpoints::functions::SetPlayerCheckpoint(self, centre_position, radius);
920 }
921
922 pub fn disable_player_checkpoint(&self) {
924 checkpoints::functions::DisablePlayerCheckpoint(self);
925 }
926
927 pub fn is_player_in_checkpoint(&self) -> bool {
929 checkpoints::functions::IsPlayerInCheckpoint(self)
930 }
931
932 pub fn set_player_race_checkpoint(
934 &self,
935 race_check_point_type: RaceCheckpointType,
936 centre_position: Vector3,
937 next_position: Vector3,
938 radius: f32,
939 ) {
940 checkpoints::functions::SetPlayerRaceCheckpoint(
941 self,
942 race_check_point_type,
943 centre_position,
944 next_position,
945 radius,
946 )
947 }
948
949 pub fn disable_player_race_checkpoint(&self) {
951 checkpoints::functions::DisablePlayerRaceCheckpoint(self)
952 }
953
954 pub fn is_player_in_race_checkpoint(&self) -> bool {
956 checkpoints::functions::IsPlayerInRaceCheckpoint(self)
957 }
958
959 pub fn is_player_checkpoint_active(&self) -> bool {
961 checkpoints::functions::IsPlayerCheckpointActive(self)
962 }
963
964 pub fn get_player_checkpoint(&self) -> PlayerCheckPointData {
966 let mut center_pos = Vector3::default();
967 let mut radius = 0.0;
968 checkpoints::functions::GetPlayerCheckpoint(self, &mut center_pos, &mut radius);
969 PlayerCheckPointData::new(center_pos, radius)
970 }
971
972 pub fn is_player_race_checkpoint_active(&self) -> bool {
974 checkpoints::functions::IsPlayerRaceCheckpointActive(self)
975 }
976
977 pub fn get_player_race_checkpoint(&self) -> PlayerRaceCheckPointData {
979 let mut center_pos = Vector3::default();
980 let mut next_pos = Vector3::default();
981 let mut radius = 0.0;
982 checkpoints::functions::GetPlayerRaceCheckpoint(
983 self,
984 &mut center_pos,
985 &mut next_pos,
986 &mut radius,
987 );
988 PlayerRaceCheckPointData::new(center_pos, next_pos, radius)
989 }
990
991 pub fn set_spawn_info(&self, player_class: PlayerClass) {
993 classes::functions::SetSpawnInfo(self, player_class)
994 }
995
996 pub fn get_spawn_info(&self) -> PlayerClass {
998 let mut data = PlayerClass::default();
999 classes::functions::GetSpawnInfo(self, &mut data);
1000 data
1001 }
1002
1003 pub fn show_dialog(
1005 &self,
1006 dialog: i16,
1007 style: DialogStyle,
1008 title: &str,
1009 body: &str,
1010 button1: &str,
1011 button2: &str,
1012 ) {
1013 dialogs::functions::ShowPlayerDialog(self, dialog, style, title, body, button1, button2)
1014 }
1015
1016 pub fn get_dialog_id(&self) -> i16 {
1018 dialogs::functions::GetPlayerDialogID(self)
1019 }
1020
1021 pub fn hide_dialog(&self) -> bool {
1023 dialogs::functions::HidePlayerDialog(self)
1024 }
1025
1026 pub fn get_id(&self) -> usize {
1027 functions::GetPlayerID(self)
1028 }
1029 pub fn from_id(playerid: isize) -> Option<Player> {
1030 functions::GetPlayerFromID(playerid)
1031 }
1032 pub fn get_menu(&self) -> Option<Menu> {
1034 menus::functions::GetPlayerMenu(self)
1035 }
1036
1037 pub fn edit_object(&self, object: &Object) {
1039 objects::functions::EditObject(self, object)
1040 }
1041 pub fn select_object(&self) {
1043 objects::functions::SelectObject(self)
1044 }
1045 pub fn end_object_editing(&self) {
1047 objects::functions::EndObjectEditing(self)
1048 }
1049 pub fn create_player_object(
1051 &self,
1052 modelid: isize,
1053 position: Vector3,
1054 rotation: Vector3,
1055 drawDistance: f32,
1056 ) -> Option<PlayerObject> {
1057 objects::functions::CreatePlayerObject(self, modelid, position, rotation, drawDistance)
1058 }
1059 pub fn destroy_player_object(&self, object: PlayerObject) {
1061 objects::functions::DestroyPlayerObject(self, &object);
1062 }
1063 pub fn edit_player_object(&self, object: &PlayerObject) {
1065 objects::functions::EditPlayerObject(self, object)
1066 }
1067
1068 pub fn get_player_object_from_id(&self, id: isize) -> Option<PlayerObject> {
1070 objects::functions::GetPlayerObjectFromID(self, id)
1071 }
1072
1073 pub fn create_player_text_draw(&self, position: Vector2, text: &str) -> Option<PlayerTextDraw> {
1075 textdraws::functions::CreatePlayerTextDraw(self, position, text)
1076 }
1077 pub fn player_text_draw_destroy(&self, textdraw: &PlayerTextDraw) {
1079 textdraws::functions::PlayerTextDrawDestroy(self, textdraw)
1080 }
1081
1082 pub fn create_player_text_label_on_player(
1083 &self,
1084 attachedPlayer: &Player,
1085 text: &str,
1086 colour: Colour,
1087 position: Vector3,
1088 drawDistance: f32,
1089 los: bool,
1090 ) -> Option<PlayerTextLabel> {
1091 textlabels::functions::CreatePlayer3DTextLabelOnPlayer(
1092 self,
1093 attachedPlayer,
1094 text,
1095 colour,
1096 position,
1097 drawDistance,
1098 los,
1099 )
1100 }
1101 pub fn create_player_text_label_on_vehicle(
1102 &self,
1103 attachedVehicle: &Vehicle,
1104 text: &str,
1105 colour: Colour,
1106 position: Vector3,
1107 drawDistance: f32,
1108 los: bool,
1109 ) -> Option<PlayerTextLabel> {
1110 textlabels::functions::CreatePlayer3DTextLabelOnVehicle(
1111 self,
1112 attachedVehicle,
1113 text,
1114 colour,
1115 position,
1116 drawDistance,
1117 los,
1118 )
1119 }
1120 pub fn create_player_text_label(
1122 &self,
1123 text: &str,
1124 colour: Colour,
1125 position: Vector3,
1126 drawDistance: f32,
1127 los: bool,
1128 ) -> Option<PlayerTextLabel> {
1129 textlabels::functions::CreatePlayer3DTextLabel(
1130 self,
1131 text,
1132 colour,
1133 position,
1134 drawDistance,
1135 los,
1136 )
1137 }
1138 pub fn delete_player_text_label(&self, textlabel: PlayerTextLabel) {
1140 textlabels::functions::DeletePlayer3DTextLabel(self, &textlabel)
1141 }
1142
1143 pub fn is_player_in_mod_shop(&self) -> bool {
1145 vehicles::functions::IsPlayerInModShop(self)
1146 }
1147 pub fn get_player_siren_state(&self) -> isize {
1149 vehicles::functions::GetPlayerSirenState(self)
1150 }
1151 pub fn get_player_landing_gear_state(&self) -> isize {
1153 vehicles::functions::GetPlayerLandingGearState(self)
1154 }
1155 pub fn get_player_hydra_reactor_angle(&self) -> isize {
1157 vehicles::functions::GetPlayerHydraReactorAngle(self)
1158 }
1159 pub fn get_player_train_speed(&self) -> f32 {
1161 vehicles::functions::GetPlayerTrainSpeed(self)
1162 }
1163
1164 pub fn get_net_stats(&self) -> NetworkStats {
1166 functions::GetPlayerNetworkStats(self)
1167 }
1168
1169 pub fn net_stats_get_ip_port(&self) -> NetworkID {
1171 functions::NetStats_GetIpPort(self)
1172 }
1173
1174 pub fn send_message_to_all(&self, message: &str) {
1176 functions::SendPlayerMessageToAll(self, message)
1177 }
1178
1179 pub fn set_attached_object(&self, index: isize, attachment: ObjectAttachmentSlotData) {
1181 functions::SetPlayerAttachedObject(self, index, attachment)
1182 }
1183 pub fn get_attached_object(&self, index: isize) -> ObjectAttachmentSlotData {
1185 functions::GetPlayerAttachedObject(self, index)
1186 }
1187}
1188
1189#[repr(C)]
1191#[derive(PartialEq, Clone, Copy, Debug)]
1192pub enum MapIconStyle {
1193 Local,
1194 Global,
1195 LocalCheckpoint,
1196 GlobalCheckpoint,
1197}
1198
1199#[repr(u8)]
1201#[derive(PartialEq, Clone, Copy, Debug)]
1202pub enum ClientVersion {
1203 Samp037,
1204 Samp03dl,
1205 Openmp,
1206}
1207
1208#[repr(C)]
1210#[derive(PartialEq, Clone, Copy, Debug)]
1211pub enum PlayerCameraCutType {
1212 Cut,
1213 Move,
1214}
1215
1216#[repr(C)]
1218#[derive(PartialEq, Clone, Copy, Debug)]
1219pub enum PlayerNameStatus {
1220 Updated,
1222 Taken,
1224 Invalid,
1226}
1227
1228#[repr(C)]
1230#[derive(PartialEq, Clone, Copy, Debug)]
1231pub enum PlayerAnimationSyncType {
1232 NoSync,
1234 Sync,
1236 SyncOthers,
1238}
1239
1240#[repr(C)]
1242#[derive(Default, Clone, Copy, Debug)]
1243pub struct WeaponSlotData {
1244 pub id: PlayerWeapon,
1246 pub ammo: u32,
1248}
1249
1250impl WeaponSlotData {
1251 pub fn new(id: PlayerWeapon, ammo: u32) -> Self {
1252 Self { id, ammo }
1253 }
1254}
1255
1256#[repr(C)]
1258#[derive(PartialEq, Clone, Copy, Debug)]
1259pub struct PlayerAnimationData {
1260 pub id: u16,
1261 pub flags: u16,
1267}
1268
1269#[repr(C)]
1271#[derive(PartialEq, Clone, Copy, Debug)]
1272pub enum PlayerFightingStyle {
1273 Normal = 4,
1274 Boxing = 5,
1275 KungFu = 6,
1276 KneeHead = 7,
1277 GrabKick = 15,
1278 Elbow = 16,
1279}
1280
1281#[repr(C)]
1283#[derive(PartialEq, Clone, Copy, Debug)]
1284pub enum PlayerState {
1285 None = 0,
1286 OnFoot = 1,
1287 Driver = 2,
1288 Passenger = 3,
1289 ExitVehicle = 4,
1290 EnterVehicleDriver = 5,
1291 EnterVehiclePassenger = 6,
1292 Wasted = 7,
1293 Spawned = 8,
1294 Spectating = 9,
1295}
1296
1297#[repr(C)]
1299#[derive(PartialEq, Clone, Copy, Debug)]
1300pub enum PlayerWeaponSkill {
1301 Pistol,
1302 SilencedPistol,
1303 DesertEagle,
1304 Shotgun,
1305 SawnOff,
1306 Spas12,
1307 Uzi,
1308 Mp5,
1309 Ak47,
1310 M4,
1311 Sniper,
1312}
1313
1314#[repr(C)]
1316#[derive(PartialEq, Clone, Copy, Debug)]
1317pub enum PlayerSpecialAction {
1318 None,
1320 Duck,
1322 Jetpack,
1324 EnterVehicle,
1326 ExitVehicle,
1328 Dance1,
1330 Dance2,
1332 Dance3,
1334 Dance4,
1336 HandsUp = 10,
1338 Cellphone,
1340 Sitting,
1342 StopCellphone,
1344 Beer = 20,
1346 Smoke,
1348 Wine,
1350 Sprunk,
1352 Cuffed,
1354 Carry,
1356 Pissing = 68,
1358}
1359
1360#[repr(C)]
1362#[derive(PartialEq, Clone, Copy, Debug)]
1363pub struct PlayerSurfingData {
1364 pub surftype: isize,
1365 pub id: isize,
1366 pub offset: Vector3,
1367}
1368
1369#[repr(C)]
1370#[derive(PartialEq, Clone, Copy, Debug)]
1371pub struct PlayerKeyData {
1372 pub keys: u32,
1373 pub upDown: i16,
1374 pub leftRight: i16,
1375}
1376
1377#[repr(C)]
1378#[derive(PartialEq, Clone, Copy, Debug)]
1379pub struct PlayerBulletData {
1380 pub origin: Vector3,
1381 pub hitPos: Vector3,
1382 pub offset: Vector3,
1383 pub weapon: PlayerWeapon,
1384 pub hitType: PlayerBulletHitType,
1385 pub hitID: u16,
1386}
1387#[repr(C)]
1388#[derive(PartialEq, Clone, Copy, Debug)]
1389pub enum PlayerBulletHitType {
1390 None,
1391 Player = 1,
1392 Vehicle = 2,
1393 Object = 3,
1394 PlayerObject = 4,
1395}
1396
1397#[repr(C)]
1398#[derive(PartialEq, Clone, Copy, Debug)]
1399pub enum SpectateType {
1400 None,
1401 Vehicle,
1402 Player,
1403}
1404
1405#[repr(C)]
1406#[derive(PartialEq, Clone, Copy, Debug)]
1407pub struct PlayerSpectateData {
1408 pub spectating: bool,
1409 pub spectateID: isize,
1410 pub spectate_type: SpectateType,
1411}
1412
1413#[repr(C)]
1414#[derive(PartialEq, Clone, Copy, Debug)]
1415pub enum PlayerSpectateMode {
1416 Normal = 1,
1417 Fixed,
1418 Side,
1419}
1420
1421#[repr(C)]
1422#[derive(PartialEq, Clone, Copy, Debug)]
1423pub struct PlayerAimData {
1424 pub camFrontVector: Vector3,
1425 pub camPos: Vector3,
1426 pub aimZ: f32,
1427 pub camZoom: f32,
1428 pub aspectRatio: f32,
1429 pub weaponState: PlayerWeaponState,
1430 pub camMode: u8,
1431}
1432
1433#[repr(C)]
1434#[derive(PartialEq, Clone, Copy, Debug)]
1435pub enum PlayerWeaponState {
1436 Unknown = -1,
1437 NoBullets,
1438 LastBullet,
1439 MoreBullets,
1440 Reloading,
1441}
1442
1443#[repr(C)]
1444#[derive(PartialEq, Clone, Copy, Debug)]
1445pub enum BodyPart {
1446 Torso = 3,
1447 Groin,
1448 LeftArm,
1449 RightArm,
1450 LeftLeg,
1451 RightLeg,
1452 Head,
1453}
1454
1455#[repr(C)]
1456#[derive(PartialEq, Clone, Copy, Debug)]
1457pub enum PlayerClickSource {
1458 Scoreboard,
1459}
1460
1461pub type WeaponSlots = StaticArray<WeaponSlotData, 13>;
1462
1463#[repr(u8)]
1464#[derive(PartialEq, Copy, Clone, Default, Debug)]
1465pub enum PlayerWeapon {
1466 #[default]
1467 Fist,
1468 BrassKnuckle,
1469 GolfClub,
1470 NiteStick,
1471 Knife,
1472 Bat,
1473 Shovel,
1474 PoolStick,
1475 Katana,
1476 Chainsaw,
1477 Dildo,
1478 Dildo2,
1479 Vibrator,
1480 Vibrator2,
1481 Flower,
1482 Cane,
1483 Grenade,
1484 Teargas,
1485 Moltov,
1486 Colt45 = 22,
1487 Silenced,
1488 Deagle,
1489 Shotgun,
1490 Sawedoff,
1491 Shotgspa,
1492 UZI,
1493 MP5,
1494 AK47,
1495 M4,
1496 TEC9,
1497 Rifle,
1498 Sniper,
1499 RocketLauncher,
1500 HeatSeeker,
1501 FlameThrower,
1502 Minigun,
1503 Satchel,
1504 Bomb,
1505 SprayCan,
1506 FireExtinguisher,
1507 Camera,
1508 NightVisGoggles,
1509 ThermalGoggles,
1510 Parachute,
1511 Vehicle = 49,
1512 Heliblades,
1513 Explosion,
1514 Drown = 53,
1515 Collision,
1516 End,
1517 Connect = 200,
1518 Disconnect,
1519 Suicide = 255,
1520}
1521
1522pub mod PlayerKeys {
1524 pub const ACTION: u32 = 1;
1525 pub const CROUCH: u32 = 2;
1526 pub const FIRE: u32 = 4;
1527 pub const SPRINT: u32 = 8;
1528 pub const SECONDARY_ATTACK: u32 = 16;
1529 pub const JUMP: u32 = 32;
1530 pub const LOOK_RIGHT: u32 = 64;
1531 pub const HANDBRAKE: u32 = 128;
1532 pub const LOOK_LEFT: u32 = 256;
1533 pub const SUBMISSION: u32 = 512;
1534 pub const LOOK_BEHIND: u32 = 512;
1535 pub const WALK: u32 = 1024;
1536 pub const ANALOG_UP: u32 = 2048;
1537 pub const ANALOG_DOWN: u32 = 4096;
1538 pub const ANALOG_LEFT: u32 = 8192;
1539 pub const ANALOG_RIGHT: u32 = 16384;
1540 pub const YES: u32 = 65536;
1541 pub const NO: u32 = 131072;
1542 pub const CTRL_BACK: u32 = 262144;
1543 pub const UP: isize = -128;
1544 pub const DOWN: isize = 128;
1545 pub const LEFT: isize = -128;
1546 pub const RIGHT: isize = 128;
1547}