cpp-sdk
cpp-sdk copied to clipboard
`Expected` in ICore create methods
Currently SDK returns nullptr if it fails to create some base object, in some cases not even printing reason of it to console.
Suggestion
Make use of Expected in ICore base objects create methods, so modules implementing alt:V API can provide more info right in code to server developers.
Rust API example (Rust's Result<Ok, Err> is very similar to Expected type in SDK)
let result = altv::VoiceChannel::new(...);
match (result) {
Ok(channel) => {
// ...
}
Err(altv::VoiceChannelCreationError::VoiceChatIsNotEnabled) => {
// ...
}
}
SDK example
auto expected = alt::ICore::Instance().CreateVoiceChannel(...);
if(expected.success) {
// using expected.value
} else {
switch(expected.error) {
case alt::VoiceChannelCreationError::VoiceChatIsNotEnabled:
// ...
break;
}
}