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
use autocxx::prelude::*;

use crate::{
    base_objects::{extra_pools::AnyEntity, player, vehicle},
    helpers::{self, IntoHash, IntoString},
    meta::entity_stream_synced_meta::StreamSyncedEntityMeta,
    quaternion::Quaternion,
    rgba::Rgba,
    sdk, structs,
    vector::Vector3,
    SomeResult, VoidResult,
};

/// # **`Vehicle implementation`**
impl vehicle::Vehicle {
    pub fn new(
        model: impl IntoHash,
        pos: impl Into<Vector3>,
        rot: impl Into<Vector3>,
    ) -> SomeResult<vehicle::VehicleContainer> {
        let pos = pos.into();
        let rot = rot.into();

        Ok(helpers::create_base_object!(
            vehicle,
            sdk::ICore::CreateVehicle(
                model.into_hash(),
                pos.x(),
                pos.y(),
                pos.z(),
                rot.x(),
                rot.y(),
                rot.z(),
            ),
            anyhow::bail!("Vehicle model is incorrect or there is no free id for new entity")
        ))
    }

    pub fn destroy(&self) -> VoidResult {
        vehicle::remove_from_pool!(self)?;
        self.internal_destroy()
    }

    pub fn driver(&self) -> SomeResult<Option<player::PlayerContainer>> {
        helpers::get_any_option_base_object!(sdk::IVehicle::GetDriver(self.raw_ptr()?), player)
    }

    pub fn attached(&self) -> SomeResult<Option<vehicle::VehicleContainer>> {
        helpers::get_any_option_base_object!(sdk::IVehicle::GetAttached(self.raw_ptr()?), vehicle)
    }

    pub fn attached_to(&self) -> SomeResult<Option<vehicle::VehicleContainer>> {
        helpers::get_any_option_base_object!(sdk::IVehicle::GetAttachedTo(self.raw_ptr()?), vehicle)
    }

    pub fn is_destroyed(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsDestroyed(self.raw_ptr()?) })
    }

    pub fn is_primary_color_rgb(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsPrimaryColorRGB(self.raw_ptr()?) })
    }

    pub fn is_secondary_color_rgb(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsSecondaryColorRGB(self.raw_ptr()?) })
    }

    pub fn is_tire_smoke_color_custom(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsTireSmokeColorCustom(self.raw_ptr()?) })
    }

    pub fn custom_tires(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::GetCustomTires(self.raw_ptr()?) })
    }

    pub fn is_extra_on(&self, extra_id: u8) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsExtraOn(self.raw_ptr()?, extra_id) })
    }

    pub fn is_neon_active(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsNeonActive(self.raw_ptr()?) })
    }

    pub fn is_engine_on(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsEngineOn(self.raw_ptr()?) })
    }

    pub fn is_handbrake_active(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsHandbrakeActive(self.raw_ptr()?) })
    }

    pub fn is_siren_active(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsSirenActive(self.raw_ptr()?) })
    }

    pub fn is_window_opened(&self, window_id: u8) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsWindowOpened(self.raw_ptr()?, window_id) })
    }

    pub fn is_daylight_on(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsDaylightOn(self.raw_ptr()?) })
    }

    pub fn is_nightlight_on(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsNightlightOn(self.raw_ptr()?) })
    }

    pub fn is_flamethrower_active(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsFlamethrowerActive(self.raw_ptr()?) })
    }

    pub fn is_wheel_burst(&self, wheel_id: u8) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsWheelBurst(self.raw_ptr()?, wheel_id) })
    }

    pub fn does_wheel_has_tire(&self, wheel_id: u8) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::DoesWheelHasTire(self.raw_ptr()?, wheel_id) })
    }

    pub fn is_wheel_detached(&self, wheel_id: u8) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsWheelDetached(self.raw_ptr()?, wheel_id) })
    }

    pub fn is_wheel_on_fire(&self, wheel_id: u8) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsWheelOnFire(self.raw_ptr()?, wheel_id) })
    }

    pub fn get_wheel_health(&self, wheel_id: u8) -> SomeResult<f32> {
        Ok(unsafe { sdk::IVehicle::GetWheelHealth(self.raw_ptr()?, wheel_id) })
    }

    pub fn is_light_damaged(&self, light_id: u8) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsLightDamaged(self.raw_ptr()?, light_id) })
    }

    pub fn is_window_damaged(&self, window_id: u8) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsWindowDamaged(self.raw_ptr()?, window_id) })
    }

    pub fn is_special_light_damaged(&self, special_light_id: u8) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsSpecialLightDamaged(self.raw_ptr()?, special_light_id) })
    }

    pub fn has_armored_windows(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::HasArmoredWindows(self.raw_ptr()?) })
    }

    pub fn manual_engine_control(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsManualEngineControl(self.raw_ptr()?) })
    }

    pub fn set_manual_engine_control(&self, toggle: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetManualEngineControl(self.raw_ptr()?, toggle) }
        Ok(())
    }

    pub fn get_mod(&self, category: u8) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetMod(self.raw_ptr()?, category) })
    }

    pub fn get_mods_count(&self, category: u8) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetModsCount(self.raw_ptr()?, category) })
    }

    pub fn mod_kits_count(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetModKitsCount(self.raw_ptr()?) })
    }

    pub fn mod_kit(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetModKit(self.raw_ptr()?) })
    }

    pub fn set_mod_kit(&self, id: u8) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::SetModKit(self.raw_ptr()?, id) })
    }

    pub fn primary_color(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetPrimaryColor(self.raw_ptr()?) })
    }

    pub fn set_primary_color(&self, color: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetPrimaryColor(self.raw_ptr()?, color) }
        Ok(())
    }

    pub fn secondary_color(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetSecondaryColor(self.raw_ptr()?) })
    }

    pub fn set_secondary_color(&self, color: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetSecondaryColor(self.raw_ptr()?, color) }
        Ok(())
    }

    pub fn pearl_color(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetPearlColor(self.raw_ptr()?) })
    }

    pub fn wheel_color(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetWheelColor(self.raw_ptr()?) })
    }

    pub fn set_wheel_color(&self, color: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetWheelColor(self.raw_ptr()?, color) }
        Ok(())
    }

    pub fn interior_color(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetInteriorColor(self.raw_ptr()?) })
    }

    pub fn set_interior_color(&self, color: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetInteriorColor(self.raw_ptr()?, color) }
        Ok(())
    }

    pub fn dashboard_color(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetDashboardColor(self.raw_ptr()?) })
    }

    pub fn set_dashboard_color(&self, color: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetDashboardColor(self.raw_ptr()?, color) }
        Ok(())
    }

    pub fn wheel_type(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetWheelType(self.raw_ptr()?) })
    }

    pub fn wheel_variation(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetWheelVariation(self.raw_ptr()?) })
    }

    pub fn rear_wheel_variation(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetRearWheelVariation(self.raw_ptr()?) })
    }

    pub fn set_wheels(&self, wheel_type: u8, variation: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetWheels(self.raw_ptr()?, wheel_type, variation) }
        Ok(())
    }

    pub fn set_rear_wheels(&self, variation: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetRearWheels(self.raw_ptr()?, variation) }
        Ok(())
    }

    pub fn set_custom_tires(&self, toggle: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetCustomTires(self.raw_ptr()?, toggle) }
        Ok(())
    }

    pub fn special_darkness(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetSpecialDarkness(self.raw_ptr()?) })
    }

    pub fn set_special_darkness(&self, value: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetSpecialDarkness(self.raw_ptr()?, value) }
        Ok(())
    }

    pub fn numberplate_index(&self) -> SomeResult<u32> {
        Ok(unsafe { sdk::IVehicle::GetNumberplateIndex(self.raw_ptr()?) })
    }

    pub fn set_numberplate_index(&self, index: u32) -> VoidResult {
        unsafe { sdk::IVehicle::SetNumberplateIndex(self.raw_ptr()?, index) }
        Ok(())
    }

    pub fn window_tint(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetWindowTint(self.raw_ptr()?) })
    }

    pub fn set_window_tint(&self, tint: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetWindowTint(self.raw_ptr()?, tint) }
        Ok(())
    }

    pub fn dirt_level(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetDirtLevel(self.raw_ptr()?) })
    }

    pub fn set_dirt_level(&self, level: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetDirtLevel(self.raw_ptr()?, level) }
        Ok(())
    }

    pub fn neon_active(&self) -> SomeResult<structs::VehicleNeon> {
        let (mut left, mut right, mut front, mut back) = Default::default();
        unsafe {
            sdk::IVehicle::GetNeonActive(
                self.raw_ptr()?,
                &mut left,
                &mut right,
                &mut front,
                &mut back,
            )
        }

        Ok(structs::VehicleNeon {
            left,
            right,
            front,
            back,
        })
    }

    pub fn set_neon_active(&self, left: bool, right: bool, front: bool, back: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetNeonActive(self.raw_ptr()?, left, right, front, back) }
        Ok(())
    }

    pub fn livery(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetLivery(self.raw_ptr()?) })
    }

    pub fn set_livery(&self, livery: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetLivery(self.raw_ptr()?, livery) }
        Ok(())
    }

    pub fn roof_livery(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetRoofLivery(self.raw_ptr()?) })
    }

    pub fn set_roof_livery(&self, roof_livery: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetRoofLivery(self.raw_ptr()?, roof_livery) }
        Ok(())
    }

    pub fn headlight_color(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetHeadlightColor(self.raw_ptr()?) })
    }

    pub fn radio_station_index(&self) -> SomeResult<u32> {
        Ok(unsafe { sdk::IVehicle::GetRadioStationIndex(self.raw_ptr()?) })
    }

    pub fn lock_state(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetLockState(self.raw_ptr()?) })
    }

    pub fn set_lock_state(&self, state: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetLockState(self.raw_ptr()?, state) }
        Ok(())
    }

    pub fn get_door_state(&self, door_id: u8) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetDoorState(self.raw_ptr()?, door_id) })
    }

    pub fn wheels_count(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetWheelsCount(self.raw_ptr()?) })
    }

    pub fn repairs_count(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetRepairsCount(self.raw_ptr()?) })
    }

    pub fn body_health(&self) -> SomeResult<u32> {
        Ok(unsafe { sdk::IVehicle::GetBodyHealth(self.raw_ptr()?) })
    }

    pub fn body_additional_health(&self) -> SomeResult<u32> {
        Ok(unsafe { sdk::IVehicle::GetBodyAdditionalHealth(self.raw_ptr()?) })
    }

    pub fn get_part_damage_level(&self, part_id: u8) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetPartDamageLevel(self.raw_ptr()?, part_id) })
    }

    pub fn get_part_bullet_holes(&self, part_id: u8) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetPartBulletHoles(self.raw_ptr()?, part_id) })
    }

    pub fn get_armored_window_shoot_count(&self, window_id: u8) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetArmoredWindowShootCount(self.raw_ptr()?, window_id) })
    }

    pub fn get_bumper_damage_level(&self, bumper_id: u8) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetBumperDamageLevel(self.raw_ptr()?, bumper_id) })
    }

    pub fn roof_closed(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::GetRoofState(self.raw_ptr()?) == 1 })
    }

    pub fn set_roof_closed(&self, toggle: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetRoofState(self.raw_ptr()?, toggle as u8) }
        Ok(())
    }

    /// At present this function is **unstable**,
    /// consider recreating the vehicle instead. <br>
    /// <https://github.com/altmp/altv-issues/issues/1748> <br>
    /// <https://github.com/altmp/altv-issues/issues/1184> <br>
    /// <https://github.com/altmp/altv-issues/issues/1445> <br>
    /// <https://github.com/altmp/altv-issues/issues/1426> <br>
    pub fn repair(&self) -> VoidResult {
        unsafe { sdk::IVehicle::SetFixed(self.raw_ptr()?) }
        Ok(())
    }

    pub fn primary_color_rgb(&self) -> SomeResult<Rgba> {
        Ok(helpers::read_cpp_rgba(
            unsafe { sdk::IVehicle::GetPrimaryColorRGB(self.raw_ptr()?) }.within_unique_ptr(),
        ))
    }

    pub fn set_primary_color_rgb(&self, color: impl Into<Rgba>) -> VoidResult {
        let color: Rgba = color.into();
        unsafe {
            sdk::IVehicle::SetPrimaryColorRGB(
                self.raw_ptr()?,
                color.r(),
                color.g(),
                color.b(),
                color.a(),
            )
        }
        Ok(())
    }

    pub fn secondary_color_rgb(&self) -> SomeResult<Rgba> {
        Ok(helpers::read_cpp_rgba(
            unsafe { sdk::IVehicle::GetSecondaryColorRGB(self.raw_ptr()?) }.within_unique_ptr(),
        ))
    }

    pub fn set_secondary_color_rgb(&self, color: impl Into<Rgba>) -> VoidResult {
        let color: Rgba = color.into();
        unsafe {
            sdk::IVehicle::SetSecondaryColorRGB(
                self.raw_ptr()?,
                color.r(),
                color.g(),
                color.b(),
                color.a(),
            )
        }
        Ok(())
    }

    pub fn tire_smoke_color(&self) -> SomeResult<Rgba> {
        Ok(helpers::read_cpp_rgba(
            unsafe { sdk::IVehicle::GetTireSmokeColor(self.raw_ptr()?) }.within_unique_ptr(),
        ))
    }

    pub fn set_tire_smoke_color(&self, color: impl Into<Rgba>) -> VoidResult {
        let color: Rgba = color.into();
        unsafe {
            sdk::IVehicle::SetTireSmokeColor(
                self.raw_ptr()?,
                color.r(),
                color.g(),
                color.b(),
                color.a(),
            )
        }
        Ok(())
    }

    pub fn numberplate_text(&self) -> SomeResult<String> {
        Ok(unsafe { sdk::IVehicle::GetNumberplateText(self.raw_ptr()?) }.to_string())
    }

    pub fn set_numberplate_text(&self, text: impl IntoString) -> VoidResult {
        unsafe { sdk::IVehicle::SetNumberplateText(self.raw_ptr()?, text.into_string()) }
        Ok(())
    }

    pub fn appearance_data_base64(&self) -> SomeResult<String> {
        Ok(unsafe { sdk::IVehicle::GetAppearanceDataBase64(self.raw_ptr()?) }.to_string())
    }

    pub fn set_appearance_data_base64(&self, data: impl IntoString) -> VoidResult {
        unsafe { sdk::IVehicle::LoadAppearanceDataFromBase64(self.raw_ptr()?, data.into_string()) }
        Ok(())
    }

    pub fn game_state_base64(&self) -> SomeResult<String> {
        Ok(unsafe { sdk::IVehicle::GetGameStateBase64(self.raw_ptr()?) }.to_string())
    }

    pub fn set_game_state_base64(&self, data: impl IntoString) -> VoidResult {
        unsafe { sdk::IVehicle::LoadGameStateFromBase64(self.raw_ptr()?, data.into_string()) }
        Ok(())
    }

    pub fn health_data_base64(&self) -> SomeResult<String> {
        Ok(unsafe { sdk::IVehicle::GetHealthDataBase64(self.raw_ptr()?) }.to_string())
    }

    pub fn set_health_data_base64(&self, data: impl IntoString) -> VoidResult {
        unsafe { sdk::IVehicle::LoadHealthDataFromBase64(self.raw_ptr()?, data.into_string()) }
        Ok(())
    }

    pub fn damage_data_base64(&self) -> SomeResult<String> {
        Ok(unsafe { sdk::IVehicle::GetDamageDataBase64(self.raw_ptr()?) }.to_string())
    }

    pub fn set_damage_data_base64(&self, data: impl IntoString) -> VoidResult {
        unsafe { sdk::IVehicle::LoadDamageDataFromBase64(self.raw_ptr()?, data.into_string()) }
        Ok(())
    }

    pub fn script_data_base64(&self) -> SomeResult<String> {
        Ok(unsafe { sdk::IVehicle::GetScriptDataBase64(self.raw_ptr()?) }.to_string())
    }

    pub fn set_script_data_base64(&self, data: impl IntoString) -> VoidResult {
        unsafe { sdk::IVehicle::LoadScriptDataFromBase64(self.raw_ptr()?, data.into_string()) }
        Ok(())
    }

    pub fn neon_color(&self) -> SomeResult<Rgba> {
        Ok(helpers::read_cpp_rgba(
            unsafe { sdk::IVehicle::GetNeonColor(self.raw_ptr()?) }.within_unique_ptr(),
        ))
    }

    pub fn set_neon_color(&self, color: impl Into<Rgba>) -> VoidResult {
        let color: Rgba = color.into();
        unsafe {
            sdk::IVehicle::SetNeonColor(self.raw_ptr()?, color.r(), color.g(), color.b(), color.a())
        }
        Ok(())
    }

    pub fn set_engine_on(&self, toggle: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetEngineOn(self.raw_ptr()?, toggle) }
        Ok(())
    }

    pub fn set_headlight_color(&self, color: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetHeadlightColor(self.raw_ptr()?, color) }
        Ok(())
    }

    pub fn set_radio_station_index(&self, index: u32) -> VoidResult {
        unsafe { sdk::IVehicle::SetRadioStationIndex(self.raw_ptr()?, index) }
        Ok(())
    }

    pub fn set_siren_active(&self, toggle: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetSirenActive(self.raw_ptr()?, toggle) }
        Ok(())
    }

    pub fn set_door_state(&self, door_id: u8, state: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetDoorState(self.raw_ptr()?, door_id, state) }
        Ok(())
    }

    pub fn set_window_opened(&self, window_id: u8, state: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetWindowOpened(self.raw_ptr()?, window_id, state) }
        Ok(())
    }

    pub fn set_lights_multiplier(&self, multiplier: f32) -> VoidResult {
        unsafe { sdk::IVehicle::SetLightsMultiplier(self.raw_ptr()?, multiplier) }
        Ok(())
    }

    pub fn set_engine_health(&self, health: i32) -> VoidResult {
        unsafe { sdk::IVehicle::SetEngineHealth(self.raw_ptr()?, health) }
        Ok(())
    }

    pub fn set_petrol_tank_health(&self, health: i32) -> VoidResult {
        unsafe { sdk::IVehicle::SetPetrolTankHealth(self.raw_ptr()?, health) }
        Ok(())
    }

    pub fn set_wheel_burst(&self, wheel_id: u8, state: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetWheelBurst(self.raw_ptr()?, wheel_id, state) }
        Ok(())
    }

    pub fn set_wheel_has_tire(&self, wheel_id: u8, state: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetWheelHasTire(self.raw_ptr()?, wheel_id, state) }
        Ok(())
    }

    pub fn set_wheel_detached(&self, wheel_id: u8, state: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetWheelDetached(self.raw_ptr()?, wheel_id, state) }
        Ok(())
    }

    pub fn set_wheel_on_fire(&self, wheel_id: u8, state: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetWheelOnFire(self.raw_ptr()?, wheel_id, state) }
        Ok(())
    }

    pub fn set_wheel_health(&self, wheel_id: u8, health: f32) -> VoidResult {
        unsafe { sdk::IVehicle::SetWheelHealth(self.raw_ptr()?, wheel_id, health) }
        Ok(())
    }

    pub fn set_wheel_fixed(&self, wheel_id: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetWheelFixed(self.raw_ptr()?, wheel_id) }
        Ok(())
    }

    pub fn set_body_health(&self, health: u32) -> VoidResult {
        unsafe { sdk::IVehicle::SetBodyHealth(self.raw_ptr()?, health) }
        Ok(())
    }

    pub fn set_body_additional_health(&self, health: u32) -> VoidResult {
        unsafe { sdk::IVehicle::SetBodyAdditionalHealth(self.raw_ptr()?, health) }
        Ok(())
    }

    pub fn set_part_damage_level(&self, part_id: u8, damage: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetPartDamageLevel(self.raw_ptr()?, part_id, damage) }
        Ok(())
    }

    pub fn set_part_bullet_holes(&self, part_id: u8, shoots_count: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetPartBulletHoles(self.raw_ptr()?, part_id, shoots_count) }
        Ok(())
    }

    pub fn set_light_damaged(&self, light_id: u8, damaged: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetLightDamaged(self.raw_ptr()?, light_id, damaged) }
        Ok(())
    }

    pub fn set_window_damaged(&self, window_id: u8, damaged: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetWindowDamaged(self.raw_ptr()?, window_id, damaged) }
        Ok(())
    }

    pub fn set_special_light_damaged(&self, special_light_id: u8, damaged: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetSpecialLightDamaged(self.raw_ptr()?, special_light_id, damaged) }
        Ok(())
    }

    pub fn set_armored_window_health(&self, window_id: u8, health: f32) -> VoidResult {
        unsafe { sdk::IVehicle::SetArmoredWindowHealth(self.raw_ptr()?, window_id, health) }
        Ok(())
    }

    pub fn set_armored_window_shoot_count(&self, window_id: u8, count: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetArmoredWindowShootCount(self.raw_ptr()?, window_id, count) }
        Ok(())
    }

    pub fn set_bumper_damage_level(&self, bumper_id: u8, damage_level: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetBumperDamageLevel(self.raw_ptr()?, bumper_id, damage_level) }
        Ok(())
    }

    pub fn drift_mode(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsDriftMode(self.raw_ptr()?) })
    }

    pub fn set_drift_mode(&self, toggle: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetDriftMode(self.raw_ptr()?, toggle) }
        Ok(())
    }

    pub fn boat_anchor_active(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsBoatAnchorActive(self.raw_ptr()?) })
    }

    pub fn set_boat_anchor_active(&self, toggle: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetBoatAnchorActive(self.raw_ptr()?, toggle) }
        Ok(())
    }

    pub fn set_search_light(
        &self,
        toggle: bool,
        spotted_entity: impl Into<AnyEntity>,
    ) -> SomeResult<bool> {
        let entity: AnyEntity = spotted_entity.into();
        Ok(unsafe { sdk::IVehicle::SetSearchLight(self.raw_ptr()?, toggle, entity.raw_ptr()?) })
    }

    pub fn light_state(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetLightState(self.raw_ptr()?) })
    }

    pub fn set_light_state(&self, state: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetLightState(self.raw_ptr()?, state) }
        Ok(())
    }

    pub fn has_timed_explosion(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::HasTimedExplosion(self.raw_ptr()?) })
    }

    pub fn timed_explosion_culprit(&self) -> SomeResult<Option<player::PlayerContainer>> {
        helpers::get_any_option_base_object!(
            sdk::IVehicle::GetTimedExplosionCulprit(self.raw_ptr()?),
            player
        )
    }

    pub fn timed_explosion_time(&self) -> SomeResult<u32> {
        Ok(unsafe { sdk::IVehicle::GetTimedExplosionTime(self.raw_ptr()?) })
    }

    pub fn set_timed_explosion(
        &self,
        state: bool,
        culprit: impl Into<player::PlayerContainer>,
        time: u32,
    ) -> VoidResult {
        let culprit: player::PlayerContainer = culprit.into();
        unsafe {
            sdk::IVehicle::SetTimedExplosion(self.raw_ptr()?, state, culprit.raw_ptr()?, time)
        }
        Ok(())
    }

    pub fn is_towing_disabled(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::IsTowingDisabled(self.raw_ptr()?) })
    }

    pub fn set_disable_towing(&self, disable: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetDisableTowing(self.raw_ptr()?, disable) }
        Ok(())
    }

    pub fn rocket_refuel_speed(&self) -> SomeResult<f32> {
        Ok(unsafe { sdk::IVehicle::GetRocketRefuelSpeed(self.raw_ptr()?) })
    }

    pub fn set_rocket_refuel_speed(&self, speed: f32) -> VoidResult {
        unsafe { sdk::IVehicle::SetRocketRefuelSpeed(self.raw_ptr()?, speed) }
        Ok(())
    }

    pub fn counter_measure_count(&self) -> SomeResult<u32> {
        Ok(unsafe { sdk::IVehicle::GetCounterMeasureCount(self.raw_ptr()?) })
    }

    pub fn set_counter_measure_count(&self, measure_count: u32) -> VoidResult {
        unsafe { sdk::IVehicle::SetCounterMeasureCount(self.raw_ptr()?, measure_count) }
        Ok(())
    }

    pub fn script_max_speed(&self) -> SomeResult<f32> {
        Ok(unsafe { sdk::IVehicle::GetScriptMaxSpeed(self.raw_ptr()?) })
    }

    pub fn set_script_max_speed(&self, speed: f32) -> VoidResult {
        unsafe { sdk::IVehicle::SetScriptMaxSpeed(self.raw_ptr()?, speed) }
        Ok(())
    }

    pub fn weapon_capacity(&self, index: u8) -> SomeResult<i32> {
        Ok(unsafe { sdk::IVehicle::GetWeaponCapacity(self.raw_ptr()?, index) })
    }

    pub fn set_weapon_capacity(&self, index: u8, state: i32) -> VoidResult {
        unsafe { sdk::IVehicle::SetWeaponCapacity(self.raw_ptr()?, index, state) }
        Ok(())
    }

    pub fn hybrid_extra_active(&self) -> SomeResult<bool> {
        Ok(unsafe { sdk::IVehicle::GetHybridExtraActive(self.raw_ptr()?) })
    }

    pub fn set_hybrid_extra_active(&self, toggle: bool) -> VoidResult {
        unsafe { sdk::IVehicle::SetHybridExtraActive(self.raw_ptr()?, toggle) }
        Ok(())
    }

    pub fn hybrid_extra_state(&self) -> SomeResult<u8> {
        Ok(unsafe { sdk::IVehicle::GetHybridExtraState(self.raw_ptr()?) })
    }

    pub fn set_hybrid_extra_state(&self, state: u8) -> VoidResult {
        unsafe { sdk::IVehicle::SetHybridExtraState(self.raw_ptr()?, state) }
        Ok(())
    }

    pub fn quaternion(&self) -> SomeResult<Quaternion> {
        Ok(helpers::read_cpp_quaternion(
            unsafe { sdk::IVehicle::GetQuaternion(self.raw_ptr()?) }.within_unique_ptr(),
        ))
    }

    pub fn set_quaternion(&self, quaternion: impl Into<Quaternion>) -> VoidResult {
        let quat = quaternion.into();
        unsafe {
            sdk::IVehicle::SetQuaternion(self.raw_ptr()?, quat.x(), quat.y(), quat.z(), quat.w())
        }
        Ok(())
    }

    pub fn velocity(&self) -> SomeResult<Vector3> {
        Ok(helpers::read_cpp_vector3(
            unsafe { sdk::IVehicle::GetVelocity(self.raw_ptr()?) }.within_unique_ptr(),
        ))
    }

    pub fn toggle_extra(&self, extra_id: u8, toggle: bool) -> VoidResult {
        unsafe { sdk::IVehicle::ToggleExtra(self.raw_ptr()?, extra_id, toggle) }
        Ok(())
    }

    pub fn set_mod(&self, category: u8, id: u8) -> VoidResult {
        if self.mod_kit()? == 0 {
            anyhow::bail!("Vehicle mod kit must be set before using set_mod");
        }

        let result = unsafe { sdk::IVehicle::SetMod(self.raw_ptr()?, category, id) };
        if !result {
            anyhow::bail!(
                "Failed to set mod category: {category}, id: {id} on vehicle for unknown reason"
            );
        }

        Ok(())
    }
}

impl StreamSyncedEntityMeta for vehicle::Vehicle {}