Skip to content

Commit

Permalink
update cpp sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
xxshady committed Jun 15, 2023
1 parent 4fa6ab5 commit cb178f1
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 16 deletions.
2 changes: 1 addition & 1 deletion altv_sdk/cpp-sdk
2 changes: 1 addition & 1 deletion altv_sdk/cpp-sdk-version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once

#define ALT_SDK_VERSION "a926288"
#define ALT_SDK_VERSION "ab5f176"
12 changes: 11 additions & 1 deletion altv_sdk/src/alt_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,8 @@ void read_vehicle_model_info(
u8* out_interior_color,
u8* out_dashboard_color,
bool* out_modkits,
bool* out_has_auto_attach_trailer
bool* out_has_auto_attach_trailer,
bool* can_attach_cars
) {
*out_model_type = static_cast<u8>(ptr->modelType);
*out_wheels_count = ptr->wheelsCount;
Expand All @@ -901,6 +902,7 @@ void read_vehicle_model_info(
}

*out_has_auto_attach_trailer = ptr->hasAutoAttachTrailer;
*can_attach_cars = ptr->canAttachCars;
}

std::string read_vehicle_model_info_title(const alt::VehicleModelInfo* ptr) {
Expand Down Expand Up @@ -983,6 +985,14 @@ std::string read_weapon_model_info_ammo_type(const alt::WeaponModelInfo* ptr) {
return ptr->ammoType;
}

std::string read_weapon_model_info_model_name(const alt::WeaponModelInfo* ptr) {
return ptr->modelName;
}

std::string read_weapon_model_info_ammo_model_name(const alt::WeaponModelInfo* ptr) {
return ptr->ammoModelName;
}

namespace events
{
const alt::CConsoleCommandEvent* to_CConsoleCommandEvent(const alt::CEvent* event) {
Expand Down
3 changes: 3 additions & 0 deletions altv_sdk/src/alt_classes/IEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ bool IsFrozen(const alt::IEntity* ptr) {
void SetFrozen(alt::IEntity* ptr, bool state) {
return ptr->SetFrozen(state);
}
u32 GetTimestamp(const alt::IEntity* ptr) {
return ptr->GetTimestamp();
}
void SetNetworkOwner(alt::IEntity* ptr, alt::IPlayer* player, bool disableMigration) {
return ptr->SetNetworkOwner(player, disableMigration);
}
Expand Down
2 changes: 2 additions & 0 deletions altv_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ pub mod ffi {
generate!("read_weapon_model_info")
generate!("read_weapon_model_info_name")
generate!("read_weapon_model_info_ammo_type")
generate!("read_weapon_model_info_model_name")
generate!("read_weapon_model_info_ammo_model_name")

// alt::Quaternion
generate!("read_quaternion")
Expand Down
4 changes: 4 additions & 0 deletions core_resource/src/base_objects/extra_pools/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,8 @@ pub trait Entity<InheritPtrs: inherit_ptrs::traits::Entity>:
}
Ok(())
}

fn timestamp(&self) -> SomeResult<u32> {
Ok(unsafe { sdk::IEntity::GetTimestamp(self.raw_ptr()?) })
}
}
26 changes: 15 additions & 11 deletions core_resource/src/vehicle_model_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct VehicleModelInfo {
pub mod_kits: [bool; 2],
pub has_auto_attach_trailer: bool,
pub bones: Vec<structs::BoneInfo>,
pub can_attach_cars: bool,

ptr: *const sdk::alt::VehicleModelInfo,
}
Expand All @@ -38,21 +39,23 @@ impl VehicleModelInfo {
let mut dashboard_color = 0u8;
let mut mod_kits = [false; 2];
let mut has_auto_attach_trailer = false;
let mut can_attach_cars = false;

unsafe {
sdk::read_vehicle_model_info(
ptr,
&mut model_type as *mut u8,
&mut wheels_count as *mut u8,
&mut has_armored_windows as *mut bool,
&mut primary_color as *mut u8,
&mut secondary_color as *mut u8,
&mut pearl_color as *mut u8,
&mut wheels_color as *mut u8,
&mut interior_color as *mut u8,
&mut dashboard_color as *mut u8,
&mut mod_kits as *mut bool,
&mut has_auto_attach_trailer as *mut bool,
&mut model_type as *mut _,
&mut wheels_count as *mut _,
&mut has_armored_windows as *mut _,
&mut primary_color as *mut _,
&mut secondary_color as *mut _,
&mut pearl_color as *mut _,
&mut wheels_color as *mut _,
&mut interior_color as *mut _,
&mut dashboard_color as *mut _,
&mut mod_kits as *mut _,
&mut has_auto_attach_trailer as *mut _,
&mut can_attach_cars as *mut _,
)
};
let model_type = altv_sdk::VehicleModelType::try_from(model_type).unwrap();
Expand Down Expand Up @@ -87,6 +90,7 @@ impl VehicleModelInfo {
mod_kits,
has_auto_attach_trailer,
bones,
can_attach_cars,

ptr,
})
Expand Down
9 changes: 7 additions & 2 deletions core_resource/src/weapon_model_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ use crate::{helpers::IntoHash, sdk};
pub struct WeaponModelInfo {
pub hash: u32,
pub name: String,
pub ammo_type: String,
pub model_name: String,
pub model_hash: u32,
pub ammo_type_hash: u32,
pub ammo_type: String,
pub ammo_model_name: String,
pub ammo_model_hash: u32,
pub default_max_ammo_mp: i32,
pub skill_above_50_max_ammo_mp: i32,
Expand Down Expand Up @@ -48,9 +50,12 @@ impl WeaponModelInfo {
Some(Self {
hash,
name: unsafe { sdk::read_weapon_model_info_name(ptr) }.to_string(),
ammo_type: unsafe { sdk::read_weapon_model_info_ammo_type(ptr) }.to_string(),
model_name: unsafe { sdk::read_weapon_model_info_model_name(ptr) }.to_string(),
model_hash,
ammo_type_hash,
ammo_type: unsafe { sdk::read_weapon_model_info_ammo_type(ptr) }.to_string(),
ammo_model_name: unsafe { sdk::read_weapon_model_info_ammo_model_name(ptr) }
.to_string(),
ammo_model_hash,
default_max_ammo_mp,
skill_above_50_max_ammo_mp,
Expand Down

0 comments on commit cb178f1

Please sign in to comment.