altMP Module SDK
altmp / cpp-sdk Goto Github PK
View Code? Open in Web Editor NEWaltMP C++ SDK for Modules
License: MIT License
altMP C++ SDK for Modules
License: MIT License
altMP Module SDK
Don't you think that the getters in IVehicle should add the const
qualifier? And in general, all interfaces seem to need to add noexcept
.
Assign @LeonMrBonnie
I think the SDK.h is missing these headers:
#include <events/CFireEvent.h> #include <events/CStartProjectileEvent.h> #include <events/CPlayerWeaponChangeEvent.h> #include <events/CVehicleAttachEvent.h> #include <events/CVehicleDetachEvent.h> #include <events/CNetOwnerChangeEvent.h> #include <events/CPlayerEnteringVehicleEvent.h>
Maybe there are some more. But it seems like everything.
There will be a deep copying of the object, and here just moving it is enough. Change to:
newData[i] = std::move(data[i]);
causes bug in v2 js module: altmp/altv-js-module-v2#206
I just noticed that some of our old scripts were using IColshape::IsEntityIdIn through JavaScript module, and it got broken. I realized that the definition for the function is maybe wrong / outdated, because there can be entities sharing same id but having a different type.
At latest release version JS module still supports IColshape::IsEntityIdIn, but it doesn't work anymore, IsEntityIn still works.
The CPP-SDK code i'm talking about:
cpp-sdk/script-objects/IColShape.h
Line 32 in a8a6d03
Support inside Javascript module: https://github.com/altmp/altv-js-module/blob/5ddb005d367c09795c3c61a1523d85c7a1758911/shared/bindings/ColShape.cpp#L7
The compiler complains about the implicit conversion of double to float. Make it explicit so that there is no warning.
Change to:
return (float)(fmod(fmod(ang - PI, TWO_PI) + TWO_PI, TWO_PI) - PI);
The follow methods of the IBlip class have wrong return/arg types:
IBlip::SetScaleXY - Should take one arg that is a Vector2f instead of 2 args for x and y
IBlip::GetGxtName & IBlip::SetGxtName - Return / Arg type should be a StringView instead of const char*
IBlip::GetName & IBlip::SetName - Return / Arg type should be a StringView instead of const char*
Currently SDK returns nullptr
if it fails to create some base object, in some cases not even printing reason of it to console.
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;
}
}
Every kind of event gets triggered for every resource, for no good reason other than "the resource might want to handle the event", which leads to duplicative processing (eg. deserialization) of the event when it can be done once if managed from the ScriptRuntime's point of view.
A smarter and more efficient method would be to have ScriptRuntime handle the event. The ScriptHandler would keep track of all event subscriptions in a hash table of handlers and trigger all the handlers for the event in question, once rather that multiple times.
This would also strengthen the reason and possibility of cancelling triggered events.
For my current Java module, I'll need to keep an updated HashMap with the key being the pointer to the BaseObject and the value being the java BaseObject as there will be a main .jar module. However there is no way for me to update that list on entity creation/deletion if there is currently no resource loaded as I can't subscribe to BaseObject creation/deletion. The only way for me to achieve this would be to use a callback from each resource, which would mean:
I see there is already a RemoveEntityEvent, that could be changed to RemoveBaseObjectEvent and then add another one for CreateBaseObjectEvent, which would allow to use server->SubscribeEvent on both of them, that way I'll be sure I can keep the hashmap up to date even if there is currently no resource loaded.
If you move an Array into itself (let's say by a pointer), there will be a memory leak.
You need to add a check.
if (this != &that)
For copying, too, would not hurt.
The Permission
and PermissionState
enum are in PascalCase instead of the rest of the enums which use UPPER_SNAKE_CASE
https://github.com/altmp/cpp-sdk/blob/master/types/Permissions.h#L8-L28
cpp-sdk/events/CPlayerConnectEvent.h
Line 19 in fbdc139
The getter should be const, otherwise modules need a const_cast
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.