├── .gitattributes ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CRefCountable.h ├── ICore.h ├── IDiscordManager.h ├── ILocalStorage.h ├── IPackage.h ├── IResource.h ├── IScriptRuntime.h ├── LICENSE ├── README.md ├── Ref.h ├── SDK.h ├── common └── Order.h ├── deps ├── ConfigBase.h └── alt-math │ └── alt-math.h ├── events ├── CAudioEvent.h ├── CClientDeleteObjectEvent.h ├── CClientRequestObjectEvent.h ├── CClientScriptEvent.h ├── CColShapeEvent.h ├── CConnectionComplete.h ├── CConnectionQueueAddEvent.h ├── CConnectionQueueRemoveEvent.h ├── CConsoleCommandEvent.h ├── CCreateBaseObjectEvent.h ├── CDisconnectEvent.h ├── CEntityHitEntityEvent.h ├── CEvent.h ├── CExplosionEvent.h ├── CFireEvent.h ├── CGameEntityCreateEvent.h ├── CGameEntityDestroyEvent.h ├── CGivePedScriptedTaskEvent.h ├── CGlobalMetaDataChangeEvent.h ├── CGlobalSyncedMetaDataChangeEvent.h ├── CKeyboardEvent.h ├── CLocalMetaDataChangeEvent.h ├── CMetaDataChangeEvent.h ├── CNetOwnerChangeEvent.h ├── CPedDamageEvent.h ├── CPedDeathEvent.h ├── CPedHealEvent.h ├── CPlayerBulletHitEvent.h ├── CPlayerChangeAnimationEvent.h ├── CPlayerChangeInteriorEvent.h ├── CPlayerChangeVehicleSeatEvent.h ├── CPlayerConnectDeniedEvent.h ├── CPlayerConnectEvent.h ├── CPlayerDamageEvent.h ├── CPlayerDeathEvent.h ├── CPlayerDimensionChangeEvent.h ├── CPlayerDisconnectEvent.h ├── CPlayerEnterVehicleEvent.h ├── CPlayerEnteringVehicleEvent.h ├── CPlayerHealEvent.h ├── CPlayerLeaveVehicleEvent.h ├── CPlayerRequestControlEvent.h ├── CPlayerSpawnEvent.h ├── CPlayerStartEnterVehicleEvent.h ├── CPlayerStartLeaveVehicleEvent.h ├── CPlayerStartTalkingEvent.h ├── CPlayerStopTalkingEvent.h ├── CPlayerWeaponChangeEvent.h ├── CPlayerWeaponShootEvent.h ├── CRemoveBaseObjectEvent.h ├── CRequestSyncedSceneEvent.h ├── CResourceErrorEvent.h ├── CResourceStartEvent.h ├── CResourceStopEvent.h ├── CRmlEvent.h ├── CScriptRPCAnswerEvent.h ├── CScriptRPCEvent.h ├── CServerScriptEvent.h ├── CServerStartedEvent.h ├── CSpawnedEvent.h ├── CStartProjectileEvent.h ├── CStartSyncedSceneEvent.h ├── CStopSyncedSceneEvent.h ├── CStreamSyncedMetaDataChangeEvent.h ├── CSyncedMetaDataChangeEvent.h ├── CTaskChangeEvent.h ├── CUpdateSyncedSceneEvent.h ├── CVehicleAttachEvent.h ├── CVehicleDamageEvent.h ├── CVehicleDestroyEvent.h ├── CVehicleDetachEvent.h ├── CVehicleHornEvent.h ├── CVehicleSirenEvent.h ├── CVoiceConnectionEvent.h ├── CWeaponDamageEvent.h ├── CWebSocketClientEvent.h ├── CWebViewEvent.h ├── CWindowFocusChangeEvent.h ├── CWindowResolutionChangeEvent.h ├── CWorldObjectPositonChangeEvent.h ├── CWorldObjectStreamInEvent.h └── CWorldObjectStreamOutEvent.h ├── objects ├── IBaseObject.h ├── IEntity.h ├── ILocalPlayer.h ├── IObject.h ├── IPed.h ├── IPlayer.h ├── IVehicle.h └── IWorldObject.h ├── script-objects ├── IAudio.h ├── IAudioAttachedOutput.h ├── IAudioCategory.h ├── IAudioFilter.h ├── IAudioFrontendOutput.h ├── IAudioOutput.h ├── IAudioWorldOutput.h ├── IBlip.h ├── ICheckpoint.h ├── IColShape.h ├── IConnectionInfo.h ├── ICustomTexture.h ├── IFont.h ├── IHandlingData.h ├── IHttpClient.h ├── IInterior.h ├── IInteriorPortal.h ├── IInteriorRoom.h ├── ILocalObject.h ├── ILocalPed.h ├── ILocalVehicle.h ├── IMapData.h ├── IMarker.h ├── INative.h ├── IRml.h ├── IStatData.h ├── ITextLabel.h ├── IVirtualEntity.h ├── IVirtualEntityGroup.h ├── IVoiceChannel.h ├── IWeaponData.h ├── IWebSocketClient.h └── IWebView.h ├── types ├── AABB.h ├── AmmoFlags.h ├── AmmoSpecialType.h ├── Benefit.h ├── BoneInfo.h ├── Cloth.h ├── CloudAuthResult.h ├── ConfigError.h ├── Decoration.h ├── DlcCloth.h ├── DlcProp.h ├── Expected.h ├── HeadBlendData.h ├── HeadOverlay.h ├── KeyState.h ├── MValue.h ├── Metric.h ├── PedModelInfo.h ├── Permissions.h ├── Prop.h ├── RGBA.h ├── SyncInfo.h ├── Types.h ├── VehicleBadgePosition.h ├── VehicleModelInfo.h ├── VoiceChat.h ├── Weapon.h ├── WeaponModelInfo.h └── WebView.h └── version ├── get-version.bat └── get-version.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | version/version.h -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "deps/alt-config"] 2 | path = deps/alt-config 3 | url = https://github.com/altmp/alt-config.git 4 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT SDK_PROJECT_NAME) 2 | set(SDK_PROJECT_NAME alt-sdk) 3 | endif() 4 | 5 | if (CMAKE_HOST_WIN32) 6 | add_custom_target(${SDK_PROJECT_NAME} 7 | call get-version.bat 8 | WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/version 9 | ) 10 | else() 11 | add_custom_target(${SDK_PROJECT_NAME} 12 | bash get-version.sh 13 | WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/version 14 | ) 15 | endif() 16 | -------------------------------------------------------------------------------- /CRefCountable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace alt 9 | { 10 | template class WeakRefStore; 11 | 12 | class IWeakRef 13 | { 14 | public: 15 | virtual void OnDestroy() = 0; 16 | }; 17 | 18 | class CRefCountable 19 | { 20 | public: 21 | virtual uint64_t GetRefCount() const { return refCount; } 22 | 23 | virtual void AddRef() const { ++refCount; } 24 | 25 | virtual bool AddRefIfExists() const 26 | { 27 | for (;;) 28 | { 29 | uint_fast64_t cur = refCount; 30 | if (cur == 0) 31 | { 32 | return false; 33 | } 34 | if (refCount.compare_exchange_strong(cur, cur + 1)) 35 | { 36 | break; 37 | } 38 | } 39 | return true; 40 | } 41 | 42 | virtual void RemoveRef() const 43 | { 44 | if (--refCount == 0) 45 | { 46 | { 47 | std::unique_lock lock{ weakRefsMutex }; 48 | for (auto ref : weakRefs) 49 | ref->OnDestroy(); 50 | } 51 | 52 | delete this; 53 | } 54 | } 55 | 56 | virtual const std::type_info& GetTypeInfo() const = 0; 57 | 58 | protected: 59 | virtual ~CRefCountable() = default; 60 | 61 | virtual void AddWeakRef(IWeakRef* ref) const 62 | { 63 | std::unique_lock lock{ weakRefsMutex }; 64 | weakRefs.insert(ref); 65 | } 66 | 67 | virtual void RemoveWeakRef(IWeakRef* ref) const 68 | { 69 | std::unique_lock lock{ weakRefsMutex }; 70 | weakRefs.erase(ref); 71 | } 72 | 73 | private: 74 | mutable std::atomic_uint64_t refCount{ 0 }; 75 | mutable std::mutex weakRefsMutex; 76 | mutable std::unordered_set weakRefs; 77 | 78 | template friend class WeakRefStore; 79 | }; 80 | } 81 | -------------------------------------------------------------------------------- /IDiscordManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace alt 4 | { 5 | class IDiscordManager 6 | { 7 | protected: 8 | virtual ~IDiscordManager() = default; 9 | 10 | public: 11 | virtual bool IsUserDataReady() = 0; 12 | virtual int64_t GetUserID() = 0; 13 | virtual std::string GetUsername() = 0; 14 | virtual std::string GetDiscriminator() = 0; 15 | virtual std::string GetAvatar() = 0; 16 | }; 17 | } // namespace alt 18 | -------------------------------------------------------------------------------- /ILocalStorage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "types/MValue.h" 5 | 6 | namespace alt 7 | { 8 | class ILocalStorage 9 | { 10 | protected: 11 | virtual ~ILocalStorage() = default; 12 | 13 | public: 14 | virtual MValueConst Get(const std::string& key) const = 0; 15 | virtual void Set(const std::string& key, MValue value) = 0; 16 | virtual void Delete(const std::string& key) = 0; 17 | virtual bool Has(const std::string& key) const = 0; 18 | virtual void Clear() = 0; 19 | virtual bool Save() = 0; 20 | }; 21 | } // namespace alt 22 | -------------------------------------------------------------------------------- /IPackage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace alt 5 | { 6 | class IPackage 7 | { 8 | public: 9 | struct PathInfo 10 | { 11 | alt::IPackage *pkg = nullptr; 12 | std::string fileName; 13 | std::string prefix; 14 | }; 15 | 16 | enum class Mode 17 | { 18 | READ, 19 | WRITE 20 | }; 21 | 22 | enum class SeekOrigin 23 | { 24 | SET = 0, 25 | CUR = 1, 26 | END = 2 27 | }; 28 | 29 | class File 30 | { 31 | public: 32 | virtual ~File() = default; 33 | }; 34 | 35 | virtual ~IPackage() = default; 36 | 37 | virtual Mode GetMode() const = 0; 38 | 39 | virtual bool FileExists(const std::string& path) = 0; 40 | 41 | virtual File *OpenFile(const std::string& path) = 0; 42 | virtual void CloseFile(File *file) = 0; 43 | 44 | virtual uint64_t GetFileSize(File *file) = 0; 45 | virtual void SeekFile(File *file, uint64_t offset, SeekOrigin origin) = 0; 46 | virtual uint64_t TellFile(File *file) = 0; 47 | 48 | virtual uint64_t ReadFile(File *file, void *buffer, uint64_t size) = 0; 49 | virtual uint64_t WriteFile(File *file, void *buffer, uint64_t size) = 0; 50 | 51 | protected: 52 | IPackage() = default; 53 | 54 | private: 55 | IPackage(const IPackage &that) = delete; 56 | IPackage &operator=(const IPackage &that) = delete; 57 | }; 58 | } // namespace alt 59 | -------------------------------------------------------------------------------- /IResource.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/MValue.h" 4 | #include "types/Permissions.h" 5 | #include "ILocalStorage.h" 6 | #include "script-objects/IWebView.h" 7 | #include "script-objects/IWebSocketClient.h" 8 | #include "script-objects/IBlip.h" 9 | #include "script-objects/ICheckpoint.h" 10 | #include "script-objects/INative.h" 11 | #include "deps/alt-config/alt-config.h" 12 | #include 13 | #include 14 | #include 15 | 16 | #include "deps/ConfigBase.h" 17 | 18 | namespace alt 19 | { 20 | class IScriptRuntime; 21 | class IPackage; 22 | class CEvent; 23 | 24 | class IResource 25 | { 26 | protected: 27 | virtual ~IResource() = default; 28 | 29 | public: 30 | struct CreationInfo 31 | { 32 | std::string type; 33 | std::string name; 34 | std::string main; 35 | IPackage *pkg; 36 | }; 37 | 38 | class Impl 39 | { 40 | public: 41 | #ifdef ALT_SERVER_API 42 | virtual bool MakeClient(CreationInfo *info, std::vector files) 43 | { 44 | return true; 45 | } 46 | #endif 47 | virtual bool Start() 48 | { 49 | return true; 50 | } 51 | virtual bool Stop() { return true; } 52 | virtual bool Mount() { return true; } 53 | 54 | virtual void OnEvent(const CEvent *ev) { } 55 | 56 | /** 57 | * Clientside: 58 | * If natives are enabled, it is not necessary to call PushNatives() to make natives invokable. 59 | * */ 60 | virtual void OnTick(){} 61 | 62 | virtual void OnCreateBaseObject(IBaseObject* object){} 63 | virtual void OnRemoveBaseObject(IBaseObject* object){} 64 | 65 | virtual ~Impl() = default; 66 | }; 67 | 68 | virtual IScriptRuntime *GetRuntime() const = 0; 69 | virtual Impl *GetImpl() const = 0; 70 | 71 | virtual bool IsStarted() const = 0; 72 | 73 | virtual const std::string& GetType() const = 0; 74 | virtual const std::string& GetName() const = 0; 75 | virtual const std::string& GetPath() const = 0; 76 | virtual const std::string& GetMain() const = 0; 77 | virtual IPackage *GetPackage() const = 0; 78 | virtual MValueDict GetExports() const = 0; 79 | virtual const std::vector GetDependencies() const = 0; 80 | virtual const std::vector GetDependants() const = 0; 81 | virtual const std::vector GetRequiredPermissions() const = 0; 82 | virtual const std::vector GetOptionalPermissions() const = 0; 83 | 84 | virtual void SetExports(MValueDict exports) = 0; 85 | 86 | #ifdef ALT_SERVER_API 87 | virtual std::string GetClientType() const = 0; 88 | virtual std::string GetClientMain() const = 0; 89 | virtual const std::vector& GetClientFiles() const = 0; 90 | #endif 91 | 92 | virtual Config::Value::ValuePtr GetConfig() const = 0; 93 | 94 | #ifdef ALT_SERVER_API 95 | virtual std::set GetMatchedFiles(const std::vector& patterns) = 0; 96 | #endif 97 | 98 | #ifdef ALT_CLIENT_API 99 | virtual void EnableNatives() = 0; 100 | [[nodiscard]] 101 | virtual std::shared_ptr CreateNativesContext() const = 0; 102 | [[nodiscard]] 103 | virtual std::shared_ptr PushNativesScope() = 0; 104 | 105 | virtual ILocalStorage *GetLocalStorage() = 0; 106 | 107 | virtual void AddGxtText(uint32_t hash, const std::string& text) = 0; 108 | virtual void RemoveGxtText(uint32_t hash) = 0; 109 | virtual const std::string& GetGxtText(uint32_t hash) = 0; 110 | virtual bool ToggleCursor(bool state) = 0; 111 | virtual void ToggleGameControls(bool state) = 0; 112 | virtual bool CursorVisible() = 0; 113 | virtual bool GameControlsActive() = 0; 114 | #endif 115 | }; 116 | } // namespace alt 117 | -------------------------------------------------------------------------------- /IScriptRuntime.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IResource.h" 4 | 5 | #include 6 | #include 7 | 8 | namespace alt 9 | { 10 | enum InitState: uint8_t 11 | { 12 | DownloadingResources = 0, 13 | ValidatingResources, 14 | DownloadingRuntime, 15 | ValidatingRuntime, 16 | DownloadingAdditionalResources 17 | }; 18 | 19 | class IPackage; 20 | 21 | class IScriptRuntime 22 | { 23 | public: 24 | virtual ~IScriptRuntime() = default; 25 | 26 | virtual bool RequiresMain() const { return true; } 27 | 28 | virtual IResource::Impl* CreateImpl(IResource* resource) = 0; 29 | virtual void DestroyImpl(IResource::Impl* impl) = 0; 30 | 31 | virtual void OnTick() { }; 32 | virtual void OnDispose() { }; 33 | 34 | #ifdef ALT_SERVER_API 35 | virtual bool GetProcessClientType(std::string& clientType) { return false; } 36 | virtual void ProcessClientFile(IResource* resource, IPackage* clientPackage) { }; 37 | #endif 38 | 39 | #ifdef ALT_CLIENT_API 40 | // Called every time when connecting to a server 41 | virtual void Init(std::function next, std::function setProgress) 42 | { 43 | next(true, ""); 44 | } 45 | #endif 46 | }; 47 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 altMP Team 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # alt:V Module SDK 2 | 3 | [Documentation](https://docs.altv.mp/sdk/index.html) 4 | 5 | ## Naming style 6 | 7 | ### Enums 8 | 9 | `PascalCase` for name and `UPPER_CASE` for enumerators, for example: 10 | ```cpp 11 | enum class AmmoSpecialType : uint32_t 12 | { 13 | NONE, 14 | ARMOR_PIERCING, 15 | EXPLOSIVE, 16 | FULL_METAL_JACKET, 17 | HOLLOW_POINT, 18 | INCENDIARY, 19 | TRACER 20 | }; 21 | ``` 22 | -------------------------------------------------------------------------------- /Ref.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "CRefCountable.h" 8 | 9 | namespace alt 10 | { 11 | template 12 | class RefBase : public MyStore 13 | { 14 | public: 15 | using ValueType = typename MyStore::ValueType; 16 | 17 | RefBase() = default; 18 | RefBase(ValueType* _ptr) { this->Assign(_ptr); } 19 | 20 | RefBase(const RefBase& other) : 21 | RefBase(const_cast(other.Get())) { } 22 | 23 | RefBase(RefBase&& other) noexcept 24 | { 25 | this->Move(std::move(other)); 26 | } 27 | 28 | template 29 | RefBase(const RefBase& other) : 30 | RefBase(const_cast(other.Get())) { } 31 | 32 | template 33 | RefBase(RefBase&& other) noexcept 34 | { 35 | this->template Move(std::move(other)); 36 | } 37 | 38 | RefBase(std::nullptr_t) : 39 | RefBase(static_cast(nullptr)) { } 40 | 41 | ~RefBase() 42 | { 43 | this->Free(); 44 | } 45 | 46 | RefBase& operator=(const RefBase& that) 47 | { 48 | if (this->Get() != that.Get()) 49 | { 50 | this->Free(); 51 | this->Assign(const_cast(that.Get())); 52 | } 53 | 54 | return *this; 55 | } 56 | 57 | bool IsEmpty() const { return this->Get() == nullptr; } 58 | operator bool() const { return !IsEmpty(); } 59 | 60 | ValueType* operator->() const { return this->Get(); } 61 | ValueType& operator*() const { return *this->Get(); } 62 | 63 | template 64 | bool operator==(RefBase rhs) const { return this->Get() == rhs.Get(); } 65 | 66 | template 67 | bool operator==(U* rhs) const { return this->Get() == rhs; } 68 | 69 | template 70 | bool operator!=(RefBase rhs) const { return this->Get() != rhs.Get(); } 71 | 72 | template 73 | bool operator!=(U* rhs) const { return this->Get() != rhs; } 74 | 75 | template 76 | static RefBase New(const Args&... args) 77 | { 78 | return RefBase(new ValueType(args...)); 79 | } 80 | }; 81 | 82 | template 83 | class RefStore 84 | { 85 | public: 86 | using ValueType = T; 87 | 88 | template 89 | using OtherType = RefStore; 90 | 91 | void Assign(T* _ptr) 92 | { 93 | if (_ptr) _ptr->AddRef(); 94 | ptr = _ptr; 95 | } 96 | 97 | void Free() 98 | { 99 | if (ptr) 100 | { 101 | ptr->RemoveRef(); 102 | ptr = nullptr; 103 | } 104 | } 105 | 106 | template 107 | void Move(RefStore&& other) 108 | { 109 | ptr = other.ptr; 110 | other.ptr = nullptr; 111 | } 112 | 113 | inline T* Get() const { return ptr; } 114 | 115 | template 116 | std::enable_if_t, RefBase>> 117 | As() const { return RefBase>(dynamic_cast(Get())); } 118 | 119 | template 120 | std::enable_if_t, RefBase>> 121 | As() const { return RefBase>(dynamic_cast(Get())); } 122 | 123 | private: 124 | template friend class RefStore; 125 | 126 | T* ptr = nullptr; 127 | }; 128 | 129 | template using Ref = RefBase>; 130 | template using ConstRef = RefBase>; 131 | 132 | template 133 | class AtomicRefStore 134 | { 135 | public: 136 | using ValueType = T; 137 | 138 | void Assign(T* _ptr) 139 | { 140 | if (_ptr) _ptr->AddRef(); 141 | ptr = _ptr; 142 | } 143 | 144 | void Free() 145 | { 146 | T* oldPtr = ptr.exchange(nullptr); 147 | if (oldPtr) oldPtr->RemoveRef(); 148 | } 149 | 150 | template 151 | void Move(AtomicRefStore&& other) 152 | { 153 | ptr = other.ptr.exchange(nullptr); 154 | } 155 | 156 | inline T* Get() const { return ptr; } 157 | 158 | Ref Load() const { return Ref(ptr); } 159 | 160 | private: 161 | template friend class AtomicRefStore; 162 | 163 | std::atomic ptr = nullptr; 164 | }; 165 | 166 | template using AtomicRef = RefBase>; 167 | template using ConstAtomicRef = RefBase>; 168 | 169 | template 170 | class WeakRefStore : public IWeakRef 171 | { 172 | public: 173 | using ValueType = T; 174 | 175 | void Assign(T* _ptr) 176 | { 177 | if (_ptr) _ptr->AddWeakRef(this); 178 | ptr = _ptr; 179 | } 180 | 181 | void Free() 182 | { 183 | T* oldPtr = ptr.exchange(nullptr); 184 | if (oldPtr) oldPtr->RemoveWeakRef(this); 185 | } 186 | 187 | template 188 | void Move(WeakRefStore&& other) 189 | { 190 | Assign(other.ptr); 191 | other.Free(); 192 | } 193 | 194 | inline T* Get() const { return ptr; } 195 | 196 | void OnDestroy() override { ptr = nullptr; } 197 | 198 | Ref Load() const { return Ref(ptr); } 199 | 200 | private: 201 | template friend class WeakRefStore; 202 | 203 | std::atomic ptr = nullptr; 204 | }; 205 | 206 | template using WeakRef = RefBase>; 207 | template using ConstWeakRef = RefBase>; 208 | } 209 | 210 | namespace std 211 | { 212 | template 213 | struct hash> 214 | { 215 | hash _hash; 216 | hash() = default; 217 | 218 | size_t operator()(const alt::RefBase& ref) const 219 | { 220 | return _hash(ref.Get()); 221 | } 222 | }; 223 | } 224 | -------------------------------------------------------------------------------- /SDK.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | #define EXTERN extern "C" 5 | #else 6 | #define EXTERN 7 | #endif // __cplusplus 8 | 9 | #ifdef _WIN32 10 | 11 | #define EXPORT EXTERN __declspec(dllexport) 12 | #define IMPORT EXTERN __declspec(dllimport) 13 | 14 | #else 15 | 16 | #define EXPORT EXTERN __attribute__((visibility("default"))) 17 | #define IMPORT 18 | 19 | #endif // _WIN32 20 | 21 | #include "deps/alt-math/alt-math.h" 22 | #include "deps/alt-config/alt-config.h" 23 | 24 | #include "types/Types.h" 25 | #include "types/RGBA.h" 26 | #include "types/MValue.h" 27 | #include "types/VehicleModelInfo.h" 28 | #include "types/WeaponModelInfo.h" 29 | 30 | #include "objects/IBaseObject.h" 31 | #include "objects/IWorldObject.h" 32 | #include "objects/IEntity.h" 33 | #include "objects/IPlayer.h" 34 | #include "objects/IVehicle.h" 35 | 36 | #include "script-objects/ICheckpoint.h" 37 | #include "script-objects/IBlip.h" 38 | #include "script-objects/IVoiceChannel.h" 39 | #include "script-objects/IHttpClient.h" 40 | #include "script-objects/ILocalVehicle.h" 41 | #include "script-objects/ILocalPed.h" 42 | #include "script-objects/ICustomTexture.h" 43 | 44 | #include "events/CEvent.h" 45 | #include "events/CServerScriptEvent.h" 46 | #include "events/CClientScriptEvent.h" 47 | #include "events/CPlayerConnectEvent.h" 48 | #include "events/CPlayerDisconnectEvent.h" 49 | #include "events/CPlayerDamageEvent.h" 50 | #include "events/CPlayerDeathEvent.h" 51 | #include "events/CPlayerHealEvent.h" 52 | #include "events/CPlayerStartTalkingEvent.h" 53 | #include "events/CPlayerStopTalkingEvent.h" 54 | #include "events/CColShapeEvent.h" 55 | #include "events/CPlayerEnterVehicleEvent.h" 56 | #include "events/CPlayerLeaveVehicleEvent.h" 57 | #include "events/CPlayerChangeVehicleSeatEvent.h" 58 | #include "events/CConsoleCommandEvent.h" 59 | #include "events/CWeaponDamageEvent.h" 60 | #include "events/CExplosionEvent.h" 61 | #include "events/CResourceStartEvent.h" 62 | #include "events/CResourceStopEvent.h" 63 | #include "events/CResourceErrorEvent.h" 64 | #include "events/CMetaDataChangeEvent.h" 65 | #include "events/CSyncedMetaDataChangeEvent.h" 66 | #include "events/CStreamSyncedMetaDataChangeEvent.h" 67 | #include "events/CGlobalMetaDataChangeEvent.h" 68 | #include "events/CGlobalSyncedMetaDataChangeEvent.h" 69 | #include "events/CLocalMetaDataChangeEvent.h" 70 | #include "events/CVehicleDestroyEvent.h" 71 | #include "events/CCreateBaseObjectEvent.h" 72 | #include "events/CRemoveBaseObjectEvent.h" 73 | #include "events/CFireEvent.h" 74 | #include "events/CStartProjectileEvent.h" 75 | #include "events/CPlayerWeaponChangeEvent.h" 76 | #include "events/CVehicleAttachEvent.h" 77 | #include "events/CVehicleDetachEvent.h" 78 | #include "events/CNetOwnerChangeEvent.h" 79 | #include "events/CPlayerEnteringVehicleEvent.h" 80 | #include "events/CVehicleDamageEvent.h" 81 | #include "events/CConnectionQueueAddEvent.h" 82 | #include "events/CConnectionQueueRemoveEvent.h" 83 | #include "events/CPlayerRequestControlEvent.h" 84 | #include "events/CPlayerChangeAnimationEvent.h" 85 | #include "events/CPlayerChangeInteriorEvent.h" 86 | #include "events/CPlayerConnectDeniedEvent.h" 87 | #include "events/CPlayerDimensionChangeEvent.h" 88 | #include "events/CVehicleHornEvent.h" 89 | #include "events/CVehicleSirenEvent.h" 90 | #include "events/CPlayerSpawnEvent.h" 91 | #include "events/CWorldObjectPositonChangeEvent.h" 92 | #include "events/CWorldObjectStreamInEvent.h" 93 | #include "events/CWorldObjectStreamOutEvent.h" 94 | #include "events/CPlayerWeaponShootEvent.h" 95 | #include "events/CEntityHitEntityEvent.h" 96 | #include "events/CPlayerStartEnterVehicleEvent.h" 97 | #include "events/CPlayerStartLeaveVehicleEvent.h" 98 | #include "events/CPlayerBulletHitEvent.h" 99 | #include "events/CVoiceConnectionEvent.h" 100 | #include "events/CRequestSyncedSceneEvent.h" 101 | #include "events/CStartSyncedSceneEvent.h" 102 | #include "events/CStopSyncedSceneEvent.h" 103 | #include "events/CUpdateSyncedSceneEvent.h" 104 | #include "events/CPedDeathEvent.h" 105 | #include "events/CPedDamageEvent.h" 106 | #include "events/CPedHealEvent.h" 107 | #include "events/CScriptRPCEvent.h" 108 | #include "events/CScriptRPCAnswerEvent.h" 109 | 110 | #ifdef ALT_SERVER_API 111 | #include "events/CClientRequestObjectEvent.h" 112 | #include "events/CClientDeleteObjectEvent.h" 113 | #include "events/CGivePedScriptedTaskEvent.h" 114 | #endif 115 | 116 | #ifdef ALT_CLIENT_API 117 | #include "events/CConnectionComplete.h" 118 | #include "events/CDisconnectEvent.h" 119 | #include "events/CWebViewEvent.h" 120 | #include "events/CKeyboardEvent.h" 121 | #include "events/CGameEntityCreateEvent.h" 122 | #include "events/CGameEntityDestroyEvent.h" 123 | #include "events/CWebSocketClientEvent.h" 124 | #include "events/CTaskChangeEvent.h" 125 | #include "events/CSpawnedEvent.h" 126 | #include "events/CRmlEvent.h" 127 | #include "events/CWindowFocusChangeEvent.h" 128 | #include "events/CWindowResolutionChangeEvent.h" 129 | #include "events/CAudioEvent.h" 130 | #endif 131 | 132 | #include "IPackage.h" 133 | #include "IResource.h" 134 | #include "IScriptRuntime.h" 135 | 136 | #include "ICore.h" 137 | -------------------------------------------------------------------------------- /common/Order.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace alt { 4 | namespace common { 5 | 6 | /** 7 | * Sorting order 8 | */ 9 | enum class Order { 10 | kDefault = 0, 11 | kAsc = 1, 12 | kDesc = 2, 13 | }; 14 | 15 | } // namespace common 16 | } // namespace alt 17 | -------------------------------------------------------------------------------- /deps/ConfigBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace Config 11 | { 12 | namespace internal 13 | { 14 | template 15 | class ValueWrapper 16 | { 17 | public: 18 | ValueWrapper() : value(nullptr) {} 19 | ValueWrapper(std::shared_ptr _value) : value(_value) {} 20 | ValueWrapper(const typename T::String& val) 21 | { 22 | value = std::make_shared(val); 23 | } 24 | ValueWrapper(const typename T::Bool& val) 25 | { 26 | value = std::make_shared(val); 27 | } 28 | ValueWrapper(const typename T::Number& val) 29 | { 30 | value = std::make_shared(val); 31 | } 32 | ValueWrapper(const typename T::List& val) 33 | { 34 | value = std::make_shared(val); 35 | } 36 | ValueWrapper(const typename T::Dict& val) 37 | { 38 | value = std::make_shared(val); 39 | } 40 | template 41 | ValueWrapper(const std::vector& vector) 42 | { 43 | typename T::List list; 44 | list.reserve(vector.size()); 45 | for(auto& val : vector) 46 | { 47 | list.push_back(val); 48 | } 49 | value = std::make_shared(list); 50 | } 51 | template 52 | ValueWrapper(const std::map& map) 53 | { 54 | typename T::Dict dict; 55 | for (auto& pair : map) 56 | { 57 | dict.insert({ pair.first, pair.second }); 58 | } 59 | value = std::make_shared(map); 60 | } 61 | 62 | T* operator->() const 63 | { 64 | return value.get(); 65 | } 66 | 67 | ValueWrapper operator[](const char* key) 68 | { 69 | return value->Get(key); 70 | } 71 | ValueWrapper operator[](const std::string& key) 72 | { 73 | return value->Get(key); 74 | } 75 | ValueWrapper operator[](size_t index) 76 | { 77 | return value->Get(index); 78 | } 79 | 80 | operator bool() 81 | { 82 | return value && !value->IsNone(); 83 | } 84 | ValueWrapper& operator=(const ValueWrapper& other) 85 | { 86 | if (&other == this) return *this; 87 | value = other.value; 88 | return *this; 89 | } 90 | 91 | private: 92 | std::shared_ptr value; 93 | }; 94 | }; 95 | 96 | class Value 97 | { 98 | public: 99 | using ValuePtr = internal::ValueWrapper; 100 | 101 | enum class Type : uint8_t 102 | { 103 | NONE, 104 | STRING, 105 | BOOL, 106 | NUMBER, 107 | LIST, 108 | DICT 109 | }; 110 | using None = std::nullptr_t; 111 | using String = std::string; 112 | using Bool = bool; 113 | using Number = double; 114 | using List = std::vector; 115 | using Dict = std::map; 116 | using Any = std::variant; 117 | 118 | Value(Value&& _value) : type(_value.type), value(_value.value) {} 119 | Value(const Value& _value) : type(_value.type), value(_value.value) {} 120 | Value(Type _type, Any _value) : type(_type), value(_value) {} 121 | Value() : type(Type::NONE), value(nullptr) {} 122 | Value(const String& _value) : type(Type::STRING), value(_value) {} 123 | Value(const char* _value) : type(Type::STRING), value(_value) {} 124 | Value(Bool _value) : type(Type::BOOL), value(_value) {} 125 | Value(Number _value) : type(Type::NUMBER), value(_value) {} 126 | Value(const List& _value) : type(Type::LIST), value(_value) {} 127 | Value(const Dict& _value) : type(Type::DICT), value(_value) {} 128 | 129 | constexpr Type GetType() { return type; } 130 | constexpr bool IsNone() { return type == Type::NONE; } 131 | constexpr bool IsString() { return type == Type::STRING; } 132 | constexpr bool IsBool() { return type == Type::BOOL; } 133 | constexpr bool IsNumber() { return type == Type::NUMBER; } 134 | constexpr bool IsList() { return type == Type::LIST; } 135 | constexpr bool IsDict() { return type == Type::DICT; } 136 | 137 | template 138 | T As(const T& defaultValue = T()) 139 | { 140 | try 141 | { 142 | if constexpr (std::is_same_v) return std::get(value); 143 | if constexpr (std::is_same_v) return std::get(value); 144 | if constexpr (std::is_integral_v || std::is_floating_point_v) return std::get(value); 145 | if constexpr (std::is_same_v) return std::get(value); 146 | if constexpr (std::is_same_v) return std::get(value); 147 | return defaultValue; 148 | } 149 | catch (...) 150 | { 151 | return defaultValue; 152 | } 153 | } 154 | String AsString(const String& defaultValue = "") 155 | { 156 | if(!IsString()) return defaultValue; 157 | return As(defaultValue); 158 | } 159 | Bool AsBool(Bool defaultValue = false) 160 | { 161 | if(!IsBool()) return defaultValue; 162 | return As(defaultValue); 163 | } 164 | template 165 | T AsNumber(T defaultValue = 0) 166 | { 167 | if(!IsNumber()) return defaultValue; 168 | return (T)As(defaultValue); 169 | } 170 | List AsList(const List& defaultValue = {}) 171 | { 172 | if(!IsList()) return defaultValue; 173 | return As(defaultValue); 174 | } 175 | Dict AsDict(const Dict& defaultValue = {}) 176 | { 177 | if(!IsDict()) return defaultValue; 178 | return As(defaultValue); 179 | } 180 | 181 | ValuePtr Get(const std::string& key) 182 | { 183 | if (!IsDict()) return std::make_shared(Type::NONE, nullptr); 184 | Dict dict = As(); 185 | auto found = dict.find(key); 186 | if (found == dict.end()) return std::make_shared(Type::NONE, nullptr); 187 | return found->second; 188 | } 189 | 190 | ValuePtr Get(size_t index) 191 | { 192 | if (!IsList()) return std::make_shared(Type::NONE, nullptr); 193 | List list = As(); 194 | if (list.size() <= index) return std::make_shared(Type::NONE, nullptr); 195 | return list.at(index); 196 | } 197 | 198 | void Set(const std::string& key, ValuePtr val) 199 | { 200 | if (!IsDict()) return; 201 | std::get(value)[key] = val; 202 | } 203 | void Set(size_t index, ValuePtr val) 204 | { 205 | if (!IsList()) return; 206 | std::get(value)[index] = val; 207 | } 208 | 209 | size_t GetSize() 210 | { 211 | if (IsDict()) return As().size(); 212 | if (IsList()) return As().size(); 213 | return 0; 214 | } 215 | 216 | operator bool() 217 | { 218 | return IsNone(); 219 | } 220 | 221 | private: 222 | Type type; 223 | Any value; 224 | }; 225 | 226 | template 227 | class ConfigBase 228 | { 229 | public: 230 | using Value = Config::Value; 231 | using ValuePtr = Config::Value::ValuePtr; 232 | 233 | static ValuePtr Parse(const std::string& input, std::string& error) 234 | { 235 | return Derived::Parse(input, error); 236 | } 237 | static std::string Format(ValuePtr config) 238 | { 239 | return Derived::Format(config); 240 | } 241 | }; 242 | 243 | namespace Util 244 | { 245 | static std::string ConvertValueToString(Value::ValuePtr& value, uint32_t indentLevel = 0) 246 | { 247 | constexpr auto getIndent = [](uint32_t indentLevel) -> std::string { 248 | return std::string(indentLevel * 2, ' '); 249 | }; 250 | 251 | if (value->IsString()) 252 | { 253 | std::string str; 254 | str += "'"; 255 | str += value->AsString(); 256 | str += "'"; 257 | return str; 258 | } 259 | if (value->IsBool()) 260 | { 261 | bool val = value->AsBool(); 262 | return val ? "true" : "false"; 263 | } 264 | if (value->IsNumber()) 265 | { 266 | double val = value->AsNumber(); 267 | // Weird hack to check if the number has any decimal points 268 | if (abs(val - int64_t(val)) == 0) return std::to_string((int64_t)val); 269 | return std::to_string(val); 270 | } 271 | if (value->IsList()) 272 | { 273 | std::stringstream stream; 274 | stream << getIndent(indentLevel) << "[\n"; 275 | Value::List list = value->AsList(); 276 | for (size_t i = 0, size = list.size(); i < size; i++) 277 | { 278 | stream << getIndent(indentLevel + 1); 279 | if (list[i]->IsDict() || list[i]->IsList()) stream << "\n"; 280 | stream << ConvertValueToString(list[i], indentLevel + 1); 281 | if (i != size - 1) stream << ","; 282 | stream << "\n"; 283 | } 284 | stream << getIndent(indentLevel) << "]"; 285 | return stream.str(); 286 | } 287 | if (value->IsDict()) 288 | { 289 | std::stringstream stream; 290 | stream << getIndent(indentLevel) << "{\n"; 291 | Value::Dict dict = value->AsDict(); 292 | for (auto it = dict.begin(); it != dict.end(); it++) 293 | { 294 | stream << getIndent(indentLevel + 1) << it->first << ": "; 295 | if (it->second->IsDict() || it->second->IsList()) stream << "\n"; 296 | stream << ConvertValueToString(it->second, indentLevel + 1); 297 | if (it != --dict.end()) stream << ","; 298 | stream << "\n"; 299 | 300 | } 301 | stream << getIndent(indentLevel) << "}"; 302 | return stream.str(); 303 | } 304 | return ""; 305 | } 306 | } 307 | } 308 | -------------------------------------------------------------------------------- /events/CAudioEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../types/MValue.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IAudio; 10 | 11 | class CAudioEvent : public CEvent 12 | { 13 | public: 14 | CAudioEvent(const std::shared_ptr& _target, const std::string& _name, const MValueArgs& _args) : CEvent(Type::AUDIO_EVENT), 15 | target(_target), 16 | name(_name), 17 | args(_args) 18 | { 19 | } 20 | 21 | IAudio* GetTarget() const { return target.get(); } 22 | const std::string& GetName() const { return name; } 23 | const MValueArgs& GetArgs() const { return args; } 24 | 25 | private: 26 | std::shared_ptr target; 27 | std::string name; 28 | MValueArgs args; 29 | }; 30 | } // namespace alt -------------------------------------------------------------------------------- /events/CClientDeleteObjectEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef ALT_SERVER_API 3 | #include 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IPlayer; 10 | 11 | // cancellable 12 | class CClientDeleteObjectEvent : public CCancellableEvent 13 | { 14 | public: 15 | CClientDeleteObjectEvent(std::shared_ptr _target) : 16 | CCancellableEvent(Type::CLIENT_DELETE_OBJECT_EVENT), 17 | target(std::move(_target)) 18 | { 19 | 20 | } 21 | 22 | IPlayer* GetTarget() const { return target.get(); } 23 | 24 | private: 25 | std::shared_ptr target; 26 | }; 27 | } 28 | #endif -------------------------------------------------------------------------------- /events/CClientRequestObjectEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef ALT_SERVER_API 3 | #include 4 | #include 5 | #include "../deps/alt-math/alt-math.h" 6 | 7 | #include "CEvent.h" 8 | 9 | namespace alt 10 | { 11 | class IPlayer; 12 | 13 | // cancellable 14 | class CClientRequestObjectEvent : public CCancellableEvent 15 | { 16 | public: 17 | CClientRequestObjectEvent(std::shared_ptr _target, const uint32_t _model, const alt::Position& _position) : 18 | CCancellableEvent(Type::CLIENT_REQUEST_OBJECT_EVENT), 19 | target(std::move(_target)), 20 | model(_model), 21 | position(_position) 22 | { 23 | 24 | } 25 | 26 | IPlayer* GetTarget() const { return target.get(); } 27 | uint32_t GetModel() const { return model; } 28 | alt::Position GetPosition() const { return position; } 29 | 30 | private: 31 | std::shared_ptr target; 32 | uint32_t model; 33 | alt::Position position; 34 | }; 35 | } 36 | #endif 37 | -------------------------------------------------------------------------------- /events/CClientScriptEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../types/MValue.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | #ifdef ALT_SERVER_API 10 | class IPlayer; 11 | 12 | class CClientScriptEvent : public CEvent 13 | { 14 | public: 15 | CClientScriptEvent(const std::shared_ptr& _target, const std::string& _name, const MValueArgs&_args) : 16 | CEvent(Type::CLIENT_SCRIPT_EVENT), 17 | target(_target), 18 | name(_name), 19 | args(_args) 20 | { 21 | 22 | } 23 | 24 | IPlayer* GetTarget() const { return target.get(); } 25 | const std::string& GetName() const { return name; } 26 | const MValueArgs& GetArgs() const { return args; } 27 | 28 | private: 29 | std::shared_ptr target; 30 | std::string name; 31 | MValueArgs args; 32 | }; 33 | #else 34 | class CClientScriptEvent : public CEvent 35 | { 36 | public: 37 | CClientScriptEvent(const std::string& _name, const MValueArgs& _args) : 38 | CEvent(Type::CLIENT_SCRIPT_EVENT), 39 | name(_name), 40 | args(_args) 41 | { 42 | 43 | } 44 | 45 | const std::string& GetName() const { return name; } 46 | const MValueArgs& GetArgs() const { return args; } 47 | 48 | private: 49 | std::string name; 50 | MValueArgs args; 51 | }; 52 | #endif 53 | } 54 | -------------------------------------------------------------------------------- /events/CColShapeEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "CEvent.h" 5 | 6 | namespace alt 7 | { 8 | class IColShape; 9 | class IWorldObject; 10 | 11 | class CColShapeEvent : public CEvent 12 | { 13 | public: 14 | CColShapeEvent(const std::shared_ptr& _target, const std::shared_ptr& _entity, bool _state) : 15 | CEvent(Type::COLSHAPE_EVENT), 16 | target(_target), 17 | entity(_entity), 18 | state(_state) 19 | { 20 | 21 | } 22 | 23 | IColShape* GetTarget() const { return target.get(); } 24 | IWorldObject* GetEntity() const { return entity.get(); } 25 | bool GetState() const { return state; } 26 | 27 | private: 28 | std::shared_ptr target; 29 | std::shared_ptr entity; 30 | bool state; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /events/CConnectionComplete.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class CConnectionCompleteEvent : public CEvent 10 | { 11 | public: 12 | CConnectionCompleteEvent() : 13 | CEvent(Type::CONNECTION_COMPLETE) 14 | { 15 | 16 | } 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /events/CConnectionQueueAddEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../script-objects/IConnectionInfo.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IPlayer; 10 | 11 | class CConnectionQueueAddEvent : public CEvent 12 | { 13 | public: 14 | explicit CConnectionQueueAddEvent(const std::shared_ptr& _connectionInfo) : 15 | CEvent(Type::CONNECTION_QUEUE_ADD), 16 | connectionInfo(_connectionInfo) 17 | { 18 | } 19 | 20 | IConnectionInfo* GetConnectionInfo() const { return connectionInfo.get(); } 21 | 22 | private: 23 | std::shared_ptr connectionInfo; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /events/CConnectionQueueRemoveEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../script-objects/IConnectionInfo.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IPlayer; 10 | 11 | class CConnectionQueueRemoveEvent : public CEvent 12 | { 13 | public: 14 | CConnectionQueueRemoveEvent(const std::shared_ptr& _connectionInfo) : 15 | CEvent(Type::CONNECTION_QUEUE_REMOVE), 16 | connectionInfo(_connectionInfo) 17 | { 18 | } 19 | 20 | IConnectionInfo* GetConnectionInfo() const { return connectionInfo.get(); } 21 | 22 | private: 23 | std::shared_ptr connectionInfo; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /events/CConsoleCommandEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class CConsoleCommandEvent : public CCancellableEvent 10 | { 11 | public: 12 | CConsoleCommandEvent(const std::string& _name, const std::vector& _args) : 13 | CCancellableEvent(Type::CONSOLE_COMMAND_EVENT), 14 | name(_name), 15 | args(_args) 16 | { 17 | 18 | } 19 | 20 | std::string GetName() const { return name; } 21 | const std::vector& GetArgs() const { return args; } 22 | 23 | private: 24 | std::string name; 25 | std::vector args; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /events/CCreateBaseObjectEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | #include "../objects/IBaseObject.h" 5 | 6 | namespace alt 7 | { 8 | class CCreateBaseObjectEvent : public CEvent 9 | { 10 | public: 11 | CCreateBaseObjectEvent(const std::shared_ptr& _target) : 12 | CEvent(Type::CREATE_BASE_OBJECT_EVENT), 13 | target(_target) 14 | { 15 | 16 | } 17 | 18 | IBaseObject* GetObject() const { return target.get(); } 19 | 20 | private: 21 | std::shared_ptr target; 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /events/CDisconnectEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class CDisconnectEvent : public CEvent 8 | { 9 | public: 10 | CDisconnectEvent() : 11 | CEvent(Type::DISCONNECT_EVENT) 12 | { 13 | 14 | } 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /events/CEntityHitEntityEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IEntity; 10 | 11 | class CEntityHitEntityEvent : public CEvent 12 | { 13 | public: 14 | CEntityHitEntityEvent(const std::shared_ptr& _damager, const std::shared_ptr& _target, uint32_t _weaponHash) : 15 | CEvent(Type::ENTITY_HIT_ENTITY), 16 | damager(_damager), 17 | target(_target), 18 | weaponHash(_weaponHash) 19 | {} 20 | 21 | IEntity* GetTarget() const { return target.get(); } 22 | IEntity* GetDamager() const { return damager.get(); } 23 | uint32_t GetWeapon() const { return weaponHash; } 24 | 25 | private: 26 | std::shared_ptr damager; 27 | std::shared_ptr target; 28 | uint32_t weaponHash; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /events/CEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace alt 6 | { 7 | class CEvent 8 | { 9 | public: 10 | enum class Type : uint16_t 11 | { 12 | NONE, 13 | 14 | // Server 15 | SERVER_STARTED, 16 | CLIENT_REQUEST_OBJECT_EVENT, 17 | CLIENT_DELETE_OBJECT_EVENT, 18 | 19 | // Shared 20 | PLAYER_CONNECT, 21 | PLAYER_DISCONNECT, 22 | PLAYER_CONNECT_DENIED, 23 | PLAYER_SPAWN, 24 | 25 | CONNECTION_QUEUE_ADD, 26 | CONNECTION_QUEUE_REMOVE, 27 | 28 | RESOURCE_START, 29 | RESOURCE_STOP, 30 | RESOURCE_ERROR, 31 | 32 | SERVER_SCRIPT_EVENT, 33 | CLIENT_SCRIPT_EVENT, 34 | 35 | META_CHANGE, 36 | SYNCED_META_CHANGE, 37 | STREAM_SYNCED_META_CHANGE, 38 | GLOBAL_META_CHANGE, 39 | GLOBAL_SYNCED_META_CHANGE, 40 | LOCAL_SYNCED_META_CHANGE, 41 | 42 | PLAYER_DAMAGE, 43 | PLAYER_DEATH, 44 | PLAYER_HEAL, 45 | FIRE_EVENT, 46 | EXPLOSION_EVENT, 47 | START_PROJECTILE_EVENT, 48 | WEAPON_DAMAGE_EVENT, 49 | VEHICLE_DESTROY, 50 | VEHICLE_DAMAGE, 51 | 52 | REQUEST_SYNCED_SCENE, 53 | START_SYNCED_SCENE, 54 | STOP_SYNCED_SCENE, 55 | UPDATE_SYNCED_SCENE, 56 | 57 | COLSHAPE_EVENT, 58 | PLAYER_ENTER_VEHICLE, 59 | PLAYER_START_ENTER_VEHICLE, 60 | PLAYER_ENTERING_VEHICLE, 61 | PLAYER_LEAVE_VEHICLE, 62 | PLAYER_START_LEAVE_VEHICLE, 63 | PLAYER_CHANGE_VEHICLE_SEAT, 64 | PLAYER_WEAPON_CHANGE, 65 | PLAYER_REQUEST_CONTROL, 66 | PLAYER_START_TALKING, 67 | PLAYER_STOP_TALKING, 68 | 69 | VEHICLE_ATTACH, 70 | VEHICLE_DETACH, 71 | VEHICLE_HORN, 72 | VEHICLE_SIREN, 73 | NETOWNER_CHANGE, 74 | 75 | CREATE_BASE_OBJECT_EVENT, 76 | REMOVE_BASE_OBJECT_EVENT, 77 | 78 | CONSOLE_COMMAND_EVENT, 79 | 80 | PLAYER_CHANGE_ANIMATION_EVENT, 81 | 82 | PLAYER_CHANGE_INTERIOR_EVENT, 83 | 84 | PLAYER_WEAPON_SHOOT_EVENT, 85 | PLAYER_BULLET_HIT_EVENT, 86 | 87 | PLAYER_DIMENSION_CHANGE, 88 | 89 | GIVE_PED_SCRIPTED_TASK, 90 | 91 | SCRIPT_RPC_EVENT, 92 | SCRIPT_RPC_ANSWER_EVENT, 93 | 94 | // Client 95 | CONNECTION_COMPLETE, 96 | DISCONNECT_EVENT, 97 | WEB_VIEW_EVENT, 98 | KEYBOARD_EVENT, 99 | GAME_ENTITY_CREATE, 100 | GAME_ENTITY_DESTROY, 101 | WEB_SOCKET_CLIENT_EVENT, 102 | AUDIO_EVENT, 103 | TASK_CHANGE, 104 | SPAWNED, 105 | RMLUI_EVENT, 106 | WINDOW_FOCUS_CHANGE, 107 | WINDOW_RESOLUTION_CHANGE, 108 | ENTITY_HIT_ENTITY, 109 | 110 | WORLD_OBJECT_POSITION_CHANGE, 111 | WORLD_OBJECT_STREAM_IN, 112 | WORLD_OBJECT_STREAM_OUT, 113 | 114 | VOICE_CONNECTION_EVENT, 115 | 116 | PED_DAMAGE, 117 | PED_DEATH, 118 | PED_HEAL, 119 | 120 | ALL, 121 | SIZE 122 | }; 123 | 124 | CEvent(Type _type) :type(_type) { } 125 | virtual ~CEvent() = default; 126 | 127 | virtual bool IsCancellable() const { return false; } 128 | 129 | Type GetType() const { return type; }; 130 | 131 | private: 132 | Type type; 133 | }; 134 | 135 | class CCancellableEvent : public CEvent 136 | { 137 | public: 138 | CCancellableEvent(Type _type) : CEvent(_type) {} 139 | 140 | bool IsCancellable() const override { return true; } 141 | 142 | bool WasCancelled() const { return cancelled; } 143 | void Cancel() const { cancelled = true; } 144 | 145 | private: 146 | mutable bool cancelled = false; 147 | }; 148 | } 149 | -------------------------------------------------------------------------------- /events/CExplosionEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../deps/alt-math/alt-math.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IEntity; 10 | class IPlayer; 11 | 12 | class CExplosionEvent : public CCancellableEvent 13 | { 14 | public: 15 | enum class ExplosionType : int8_t 16 | { 17 | GRENADE, 18 | GRENADELAUNCHER, 19 | STICKYBOMB, 20 | MOLOTOV, 21 | ROCKET, 22 | TANKSHELL, 23 | HI_OCTANE, 24 | CAR, 25 | PLANE, 26 | PETROL_PUMP, 27 | BIKE, 28 | DIR_STEAM, 29 | DIR_FLAME, 30 | DIR_WATER_HYDRANT, 31 | DIR_GAS_CANISTER, 32 | BOAT, 33 | SHIP_DESTROY, 34 | TRUCK, 35 | BULLET, 36 | SMOKEGRENADELAUNCHER, 37 | SMOKEGRENADE, 38 | BZGAS, 39 | FLARE, 40 | GAS_CANISTER, 41 | EXTINGUISHER, 42 | PROGRAMMABLEAR, 43 | TRAIN, 44 | BARREL, 45 | PROPANE, 46 | BLIMP, 47 | DIR_FLAME_EXPLODE, 48 | TANKER, 49 | PLANE_ROCKET, 50 | VEHICLE_BULLET, 51 | GAS_TANK, 52 | FIREWORK, 53 | SNOWBALL, 54 | PROXMINE, 55 | VALKYRIE_CANNON, 56 | 57 | UNKNOWN = -1 58 | }; 59 | 60 | CExplosionEvent(const std::shared_ptr& _source, ExplosionType _explosionType, Position _position, uint32_t _explosionFX, const std::shared_ptr& _target) : 61 | CCancellableEvent(Type::EXPLOSION_EVENT), 62 | source(_source), 63 | explosionType(_explosionType), 64 | position(_position), 65 | explosionFX(_explosionFX), 66 | target(_target) 67 | { 68 | 69 | } 70 | 71 | IPlayer* GetSource() const { return source.get(); } 72 | IEntity* GetTarget() const { return target.get(); } 73 | ExplosionType GetExplosionType() const { return explosionType; } 74 | Position GetPosition() const { return position; } 75 | uint32_t GetExplosionFX() const { return explosionFX; } 76 | 77 | private: 78 | std::shared_ptr source; 79 | std::shared_ptr target; 80 | ExplosionType explosionType; 81 | Position position; 82 | uint32_t explosionFX; 83 | }; 84 | } 85 | -------------------------------------------------------------------------------- /events/CFireEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../deps/alt-math/alt-math.h" 6 | 7 | #include "CEvent.h" 8 | 9 | namespace alt 10 | { 11 | class CFireEvent : public CCancellableEvent 12 | { 13 | public: 14 | struct FireInfo 15 | { 16 | Position position; 17 | uint32_t weaponHash; 18 | 19 | FireInfo(const Position& _position, uint32_t _weaponHash): position(_position), weaponHash(_weaponHash) {} 20 | 21 | FireInfo() = default; 22 | }; 23 | 24 | CFireEvent(const std::shared_ptr& _source, std::vector&& _fires) : 25 | CCancellableEvent(Type::FIRE_EVENT), 26 | source(_source), 27 | fires(std::move(_fires)) 28 | { 29 | 30 | } 31 | 32 | IPlayer* GetSource() const { return source.get(); } 33 | const std::vector& GetFires() const { return fires; } 34 | 35 | private: 36 | std::shared_ptr source; 37 | std::vector fires; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /events/CGameEntityCreateEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IEntity; 8 | 9 | class CGameEntityCreateEvent : public CEvent 10 | { 11 | public: 12 | CGameEntityCreateEvent(const std::shared_ptr& _target) : 13 | CEvent(Type::GAME_ENTITY_CREATE), 14 | target(_target) 15 | { 16 | 17 | } 18 | 19 | IEntity* GetTarget() const { return target.get(); } 20 | 21 | private: 22 | std::shared_ptr target; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /events/CGameEntityDestroyEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IEntity; 8 | 9 | class CGameEntityDestroyEvent : public CEvent 10 | { 11 | public: 12 | CGameEntityDestroyEvent(const std::shared_ptr& _target) : 13 | CEvent(Type::GAME_ENTITY_DESTROY), 14 | target(_target) 15 | { 16 | 17 | } 18 | 19 | IEntity* GetTarget() const { return target.get(); } 20 | 21 | private: 22 | std::shared_ptr target; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /events/CGivePedScriptedTaskEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef ALT_SERVER_API 3 | #include "../deps/alt-math/alt-math.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IEntity; 10 | class IPlayer; 11 | class IPed; 12 | 13 | class CGivePedScriptedTaskEvent : public CCancellableEvent 14 | { 15 | public: 16 | CGivePedScriptedTaskEvent(const std::shared_ptr _source, const std::shared_ptr _target, uint32_t _taskType) : 17 | CCancellableEvent(Type::GIVE_PED_SCRIPTED_TASK), 18 | source(_source), 19 | target(_target), 20 | taskType(_taskType) 21 | { 22 | 23 | } 24 | 25 | IPlayer* GetSource() const { return source.get(); } 26 | IPed* GetTarget() const { return target.get(); } 27 | uint32_t GetTaskType() const { return taskType; } 28 | 29 | private: 30 | std::shared_ptr source; 31 | std::shared_ptr target; 32 | uint32_t taskType; 33 | }; 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /events/CGlobalMetaDataChangeEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../types/MValue.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class CGlobalMetaDataChangeEvent : public CEvent 10 | { 11 | public: 12 | CGlobalMetaDataChangeEvent(const std::string _key, MValueConst _val, MValueConst _oldVal) : 13 | CEvent(Type::GLOBAL_META_CHANGE), 14 | key(_key), 15 | val(_val), 16 | oldVal(_oldVal) 17 | { 18 | 19 | } 20 | 21 | std::string GetKey() const { return key; } 22 | MValueConst GetVal() const { return val; } 23 | MValueConst GetOldVal() const { return oldVal; } 24 | 25 | private: 26 | std::string key; 27 | MValueConst val; 28 | MValueConst oldVal; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /events/CGlobalSyncedMetaDataChangeEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../types/MValue.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class CGlobalSyncedMetaDataChangeEvent : public CEvent 10 | { 11 | public: 12 | CGlobalSyncedMetaDataChangeEvent(const std::string _key, MValueConst _val, MValueConst _oldVal) : 13 | CEvent(Type::GLOBAL_SYNCED_META_CHANGE), 14 | key(_key), 15 | val(_val), 16 | oldVal(_oldVal) 17 | { 18 | 19 | } 20 | 21 | std::string GetKey() const { return key; } 22 | MValueConst GetVal() const { return val; } 23 | MValueConst GetOldVal() const { return oldVal; } 24 | 25 | private: 26 | std::string key; 27 | MValueConst val; 28 | MValueConst oldVal; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /events/CKeyboardEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class CKeyboardEvent : public CEvent 10 | { 11 | public: 12 | enum class KeyState 13 | { 14 | UP, 15 | DOWN 16 | }; 17 | 18 | CKeyboardEvent(uint32_t _keyCode, KeyState state) : 19 | CEvent(Type::KEYBOARD_EVENT), 20 | keyCode(_keyCode), 21 | keyState(state) 22 | { 23 | 24 | } 25 | 26 | uint32_t GetKeyCode() const { return keyCode; } 27 | KeyState GetKeyState() const { return keyState; } 28 | 29 | private: 30 | uint32_t keyCode; 31 | KeyState keyState; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /events/CLocalMetaDataChangeEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../types/MValue.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IPlayer; 10 | 11 | class CLocalMetaDataChangeEvent : public CEvent 12 | { 13 | public: 14 | CLocalMetaDataChangeEvent(const std::shared_ptr& _target, const std::string& _key, MValueConst _val, MValueConst _oldVal) : 15 | CEvent(Type::LOCAL_SYNCED_META_CHANGE), 16 | target(_target), 17 | key(_key), 18 | val(_val), 19 | oldVal(_oldVal) 20 | { 21 | 22 | } 23 | 24 | IPlayer* GetTarget() const { return target.get(); } 25 | std::string GetKey() const { return key; } 26 | MValueConst GetVal() const { return val; } 27 | MValueConst GetOldVal() const { return oldVal; } 28 | 29 | private: 30 | std::shared_ptr target; 31 | std::string key; 32 | MValueConst val; 33 | MValueConst oldVal; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /events/CMetaDataChangeEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../types/MValue.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IBaseObject; 10 | 11 | class CMetaChangeEvent : public CEvent 12 | { 13 | public: 14 | CMetaChangeEvent(const std::shared_ptr& _target, const std::string& _key, MValueConst _val, MValueConst _oldVal) : 15 | CEvent(Type::META_CHANGE), 16 | target(_target), 17 | key(_key), 18 | val(_val), 19 | oldVal(_oldVal) 20 | { 21 | 22 | } 23 | 24 | IBaseObject* GetTarget() const { return target.get(); } 25 | std::string GetKey() const { return key; } 26 | MValueConst GetVal() const { return val; } 27 | MValueConst GetOldVal() const { return oldVal; } 28 | 29 | private: 30 | std::shared_ptr target; 31 | std::string key; 32 | MValueConst val; 33 | MValueConst oldVal; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /events/CNetOwnerChangeEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IEntity; 8 | class IPlayer; 9 | 10 | class CNetOwnerChangeEvent : public CEvent 11 | { 12 | public: 13 | CNetOwnerChangeEvent(const std::shared_ptr& _target, const std::shared_ptr& _newowner, const std::shared_ptr& _oldowner) : 14 | CEvent(Type::NETOWNER_CHANGE), 15 | target(_target), 16 | newOwner(_newowner), 17 | oldOwner(_oldowner) 18 | { 19 | 20 | } 21 | 22 | IEntity* GetTarget() const { return target.get(); } 23 | IPlayer* GetNewOwner() const { return newOwner.get(); } 24 | IPlayer* GetOldOwner() const { return oldOwner.get(); } 25 | 26 | private: 27 | std::shared_ptr target; 28 | std::shared_ptr newOwner; 29 | std::shared_ptr oldOwner; 30 | }; 31 | } -------------------------------------------------------------------------------- /events/CPedDamageEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "CEvent.h" 7 | 8 | namespace alt 9 | { 10 | class IPed; 11 | class IEntity; 12 | 13 | class CPedDamageEvent : public CEvent 14 | { 15 | public: 16 | CPedDamageEvent(const std::shared_ptr& _target, const std::shared_ptr& _attacker, uint16_t _healthDamage, uint16_t _armourDamage, uint32_t _weapon) : 17 | CEvent(Type::PED_DAMAGE), 18 | target(_target), 19 | attacker(_attacker), 20 | healthDamage(_healthDamage), 21 | armourDamage(_armourDamage), 22 | weapon(_weapon) 23 | { 24 | 25 | } 26 | 27 | IPed* GetTarget() const { return target.get(); } 28 | IEntity* GetAttacker() const { return attacker.get(); } 29 | uint16_t GetHealthDamage() const { return healthDamage; } 30 | uint16_t GetArmourDamage() const { return armourDamage; } 31 | uint32_t GetWeapon() const { return weapon; } 32 | 33 | private: 34 | std::shared_ptr target; 35 | std::shared_ptr attacker; 36 | uint16_t healthDamage; 37 | uint16_t armourDamage; 38 | uint32_t weapon; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /events/CPedDeathEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "CEvent.h" 7 | 8 | namespace alt 9 | { 10 | class IPed; 11 | class IEntity; 12 | 13 | class CPedDeathEvent : public CEvent 14 | { 15 | public: 16 | CPedDeathEvent(const std::shared_ptr& _target, const std::shared_ptr& _killer, uint32_t _weapon) : 17 | CEvent(Type::PED_DEATH), 18 | target(_target), 19 | killer(_killer), 20 | weapon(_weapon) 21 | { 22 | 23 | } 24 | 25 | IPed* GetTarget() const { return target.get(); } 26 | IEntity* GetKiller() const { return killer.get(); } 27 | uint32_t GetWeapon() const { return weapon; } 28 | 29 | private: 30 | std::shared_ptr target; 31 | std::shared_ptr killer; 32 | uint32_t weapon; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /events/CPedHealEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #ifdef ALT_SERVER_API 4 | #include 5 | 6 | #include "CEvent.h" 7 | 8 | namespace alt 9 | { 10 | class IPed; 11 | 12 | // not cancelable 13 | class CPedHealEvent : public CEvent 14 | { 15 | public: 16 | CPedHealEvent(const std::shared_ptr& _target, uint16_t _oldHealth, uint16_t _newHealth, uint16_t _oldArmour, uint16_t _newArmour) : 17 | CEvent(Type::PED_HEAL), 18 | target(_target), 19 | oldHealth(_oldHealth), 20 | newHealth(_newHealth), 21 | oldArmour(_oldArmour), 22 | newArmour(_newArmour) 23 | { 24 | 25 | } 26 | 27 | IPed* GetTarget() const { return target.get(); } 28 | uint16_t GetOldHealth() const { return oldHealth; } 29 | uint16_t GetNewHealth() const { return newHealth; } 30 | uint16_t GetOldArmour() const { return oldArmour; } 31 | uint16_t GetNewArmour() const { return newArmour; } 32 | 33 | private: 34 | std::shared_ptr target; 35 | uint16_t oldHealth; 36 | uint16_t newHealth; 37 | uint16_t oldArmour; 38 | uint16_t newArmour; 39 | }; 40 | } 41 | #endif -------------------------------------------------------------------------------- /events/CPlayerBulletHitEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class CPlayerBulletHitEvent : public CEvent 8 | { 9 | public: 10 | CPlayerBulletHitEvent(uint32_t _weapon, const std::shared_ptr& _victim, alt::Position _pos) : 11 | CEvent(Type::PLAYER_BULLET_HIT_EVENT), 12 | weapon(_weapon), 13 | victim(_victim), 14 | pos(_pos) 15 | {} 16 | 17 | uint32_t GetWeapon() const { return weapon; } 18 | IEntity* GetVictim() const { return victim.get(); } 19 | alt::Position GetPosition() const { return pos; } 20 | 21 | private: 22 | uint32_t weapon; 23 | std::shared_ptr victim; 24 | alt::Position pos; 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /events/CPlayerChangeAnimationEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #pragma once 4 | 5 | #include "CEvent.h" 6 | #include "../objects/IPlayer.h" 7 | 8 | namespace alt 9 | { 10 | class CPlayerChangeAnimationEvent : public CEvent 11 | { 12 | public: 13 | CPlayerChangeAnimationEvent(const std::shared_ptr& _target, uint32_t _oldAnimationDict, uint32_t _oldAnimationName, uint32_t _newAnimationDict, uint32_t _newAnimationName) : 14 | CEvent(Type::PLAYER_CHANGE_ANIMATION_EVENT), 15 | target(_target), 16 | oldAnimationDict(_oldAnimationDict), 17 | oldAnimationName(_oldAnimationName), 18 | newAnimationDict(_newAnimationDict), 19 | newAnimationName(_newAnimationName) 20 | {} 21 | 22 | IPlayer* GetTarget() const { return target.get(); } 23 | uint32_t GetOldAnimationDict() const { return oldAnimationDict; } 24 | uint32_t GetOldAnimationName() const { return oldAnimationName; } 25 | uint32_t GetNewAnimationDict() const { return newAnimationDict; } 26 | uint32_t GetNewAnimationName() const { return newAnimationName; } 27 | 28 | private: 29 | std::shared_ptr target; 30 | uint32_t oldAnimationDict; 31 | uint32_t oldAnimationName; 32 | uint32_t newAnimationDict; 33 | uint32_t newAnimationName; 34 | }; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /events/CPlayerChangeInteriorEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #pragma once 4 | 5 | #include "CEvent.h" 6 | #include "../objects/IPlayer.h" 7 | 8 | namespace alt 9 | { 10 | class CPlayerChangeInteriorEvent : public CEvent 11 | { 12 | public: 13 | CPlayerChangeInteriorEvent(const std::shared_ptr& _target, uint32_t _oldInteriorLocation, uint32_t _newInteriorLocation) : 14 | CEvent(Type::PLAYER_CHANGE_INTERIOR_EVENT), 15 | target(_target), 16 | oldInteriorLocation(_oldInteriorLocation), 17 | newInteriorLocation(_newInteriorLocation) 18 | {} 19 | 20 | IPlayer* GetTarget() const { return target.get(); } 21 | uint32_t GetOldInteriorLocation() const { return oldInteriorLocation; } 22 | uint32_t GetNewInteriorLocation() const { return newInteriorLocation; } 23 | 24 | private: 25 | std::shared_ptr target; 26 | uint32_t oldInteriorLocation; 27 | uint32_t newInteriorLocation; 28 | }; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /events/CPlayerChangeVehicleSeatEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IVehicle; 8 | class IPlayer; 9 | 10 | class CPlayerChangeVehicleSeatEvent : public CEvent 11 | { 12 | public: 13 | CPlayerChangeVehicleSeatEvent(const std::shared_ptr& _target, const std::shared_ptr& _player, uint8_t _oldSeat, uint8_t _newSeat) : 14 | CEvent(Type::PLAYER_CHANGE_VEHICLE_SEAT), 15 | target(_target), 16 | player(_player), 17 | oldSeat(_oldSeat), 18 | newSeat(_newSeat) 19 | { 20 | 21 | } 22 | 23 | IVehicle* GetTarget() const { return target.get(); } 24 | IPlayer* GetPlayer() const { return player.get(); } 25 | uint8_t GetOldSeat() const { return oldSeat; } 26 | uint8_t GetNewSeat() const { return newSeat; } 27 | 28 | private: 29 | std::shared_ptr target; 30 | std::shared_ptr player; 31 | uint8_t oldSeat; 32 | uint8_t newSeat; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /events/CPlayerConnectDeniedEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class CPlayerConnectDeniedEvent : public CEvent 8 | { 9 | public: 10 | enum Reason: uint8_t 11 | { 12 | WRONG_VERSION, 13 | WRONG_BRANCH, 14 | DEBUG_NOT_ALLOWED, 15 | WRONG_PASSWORD, 16 | WRONG_CDN_URL 17 | }; 18 | 19 | CPlayerConnectDeniedEvent(Reason _reason, const std::string& _name, const std::string& _ip, uint64_t _passwordHash, bool _isDebug, const std::string& _branch, uint16_t _versionMajor, uint16_t _versionMinor, const std::string& _cdnUrl, int64_t _discordId) : 20 | CEvent(Type::PLAYER_CONNECT_DENIED), reason(_reason), name(_name), ip(_ip), passwordHash(_passwordHash), isDebug(_isDebug), branch(_branch), versionMajor(_versionMajor), versionMinor(_versionMinor), cdnUrl(_cdnUrl), discordId(_discordId) 21 | { 22 | } 23 | 24 | Reason GetReason() const { return reason; } 25 | const std::string& GetName() const { return name; } 26 | const std::string& GetIp() const { return ip; } 27 | uint64_t GetPasswordHash() const { return passwordHash; } 28 | bool IsDebug() const { return isDebug; } 29 | const std::string& GetBranch() const { return branch; } 30 | uint16_t GetVersionMajor() const { return versionMajor; } 31 | uint16_t GetVersionMinor() const { return versionMinor; } 32 | const std::string& GetCdnUrl() const { return cdnUrl; } 33 | int64_t GetDiscordId() const { return discordId; } 34 | 35 | private: 36 | Reason reason; 37 | std::string name; 38 | std::string ip; 39 | uint64_t passwordHash; 40 | bool isDebug; 41 | std::string branch; 42 | uint16_t versionMajor; 43 | uint16_t versionMinor; 44 | std::string cdnUrl; 45 | int64_t discordId; 46 | }; 47 | } 48 | -------------------------------------------------------------------------------- /events/CPlayerConnectEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IPlayer; 8 | 9 | class CPlayerConnectEvent : public CCancellableEvent 10 | { 11 | public: 12 | CPlayerConnectEvent(const std::shared_ptr& _target) : 13 | CCancellableEvent(Type::PLAYER_CONNECT), 14 | target(_target) 15 | { 16 | } 17 | 18 | IPlayer* GetTarget() const { return target.get(); } 19 | const std::string& GetReason() const { return reason; } 20 | 21 | void Cancel(const std::string& _reason) 22 | { 23 | reason = _reason; 24 | CCancellableEvent::Cancel(); 25 | } 26 | 27 | private: 28 | std::shared_ptr target; 29 | std::string reason; 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /events/CPlayerDamageEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IPlayer; 10 | class IEntity; 11 | 12 | class CPlayerDamageEvent : public CEvent 13 | { 14 | public: 15 | CPlayerDamageEvent(const std::shared_ptr& _target, const std::shared_ptr& _attacker, uint16_t _healthDamage, uint16_t _armourDamage, uint32_t _weapon) : 16 | CEvent(Type::PLAYER_DAMAGE), 17 | target(_target), 18 | attacker(_attacker), 19 | healthDamage(_healthDamage), 20 | armourDamage(_armourDamage), 21 | weapon(_weapon) 22 | { 23 | 24 | } 25 | 26 | IPlayer* GetTarget() const { return target.get(); } 27 | IEntity* GetAttacker() const { return attacker.get(); } 28 | uint16_t GetHealthDamage() const { return healthDamage; } 29 | uint16_t GetArmourDamage() const { return armourDamage; } 30 | uint32_t GetWeapon() const { return weapon; } 31 | 32 | private: 33 | std::shared_ptr target; 34 | std::shared_ptr attacker; 35 | uint16_t healthDamage; 36 | uint16_t armourDamage; 37 | uint32_t weapon; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /events/CPlayerDeathEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IPlayer; 10 | class IEntity; 11 | 12 | class CPlayerDeathEvent : public CEvent 13 | { 14 | public: 15 | CPlayerDeathEvent(const std::shared_ptr& _target, const std::shared_ptr& _killer, uint32_t _weapon) : 16 | CEvent(Type::PLAYER_DEATH), 17 | target(_target), 18 | killer(_killer), 19 | weapon(_weapon) 20 | { 21 | 22 | } 23 | 24 | IPlayer* GetTarget() const { return target.get(); } 25 | IEntity* GetKiller() const { return killer.get(); } 26 | uint32_t GetWeapon() const { return weapon; } 27 | 28 | private: 29 | std::shared_ptr target; 30 | std::shared_ptr killer; 31 | uint32_t weapon; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /events/CPlayerDimensionChangeEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IPlayer; 8 | 9 | class CPlayerDimensionChangeEvent : public CEvent 10 | { 11 | public: 12 | CPlayerDimensionChangeEvent(const std::shared_ptr& _target, int32_t _oldDimension, int32_t _newDimension) : 13 | CEvent(Type::PLAYER_DIMENSION_CHANGE), 14 | target(_target), 15 | oldDimension(_oldDimension), 16 | newDimension(_newDimension) 17 | { 18 | } 19 | 20 | IPlayer* GetTarget() const { return target.get(); } 21 | int32_t GetOldDimension() const { return oldDimension; } 22 | int32_t GetNewDimension() const { return newDimension; } 23 | 24 | private: 25 | std::shared_ptr target; 26 | int32_t oldDimension; 27 | int32_t newDimension; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /events/CPlayerDisconnectEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IPlayer; 8 | 9 | class CPlayerDisconnectEvent : public CEvent 10 | { 11 | public: 12 | CPlayerDisconnectEvent(const std::shared_ptr& _target, const std::string& _reason) : 13 | CEvent(Type::PLAYER_DISCONNECT), 14 | target(_target), 15 | reason(_reason) 16 | { 17 | 18 | } 19 | 20 | IPlayer* GetTarget() const { return target.get(); } 21 | const std::string& GetReason() const { return reason; } 22 | 23 | private: 24 | std::shared_ptr target; 25 | std::string reason; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /events/CPlayerEnterVehicleEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IVehicle; 8 | class IPlayer; 9 | 10 | class CPlayerEnterVehicleEvent : public CEvent 11 | { 12 | public: 13 | CPlayerEnterVehicleEvent(const std::shared_ptr& _target, const std::shared_ptr& _player, uint8_t _seat) : 14 | CEvent(Type::PLAYER_ENTER_VEHICLE), 15 | target(_target), 16 | player(_player), 17 | seat(_seat) 18 | { 19 | 20 | } 21 | 22 | IVehicle* GetTarget() const { return target.get(); } 23 | IPlayer* GetPlayer() const { return player.get(); } 24 | uint8_t GetSeat() const { return seat; } 25 | 26 | private: 27 | std::shared_ptr target; 28 | std::shared_ptr player; 29 | uint8_t seat; 30 | }; 31 | } -------------------------------------------------------------------------------- /events/CPlayerEnteringVehicleEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IVehicle; 8 | class IPlayer; 9 | 10 | class CPlayerEnteringVehicleEvent : public CEvent 11 | { 12 | public: 13 | CPlayerEnteringVehicleEvent(const std::shared_ptr& _target, const std::shared_ptr& _player, uint8_t _seat) : 14 | CEvent(Type::PLAYER_ENTERING_VEHICLE), 15 | target(_target), 16 | player(_player), 17 | seat(_seat) 18 | { 19 | 20 | } 21 | 22 | IVehicle* GetTarget() const { return target.get(); } 23 | IPlayer* GetPlayer() const { return player.get(); } 24 | uint8_t GetSeat() const { return seat; } 25 | 26 | private: 27 | std::shared_ptr target; 28 | std::shared_ptr player; 29 | uint8_t seat; 30 | }; 31 | } -------------------------------------------------------------------------------- /events/CPlayerHealEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef ALT_SERVER_API 3 | #include 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IPlayer; 10 | 11 | // not cancelable 12 | class CPlayerHealEvent : public CEvent 13 | { 14 | public: 15 | CPlayerHealEvent(const std::shared_ptr& _target, uint16_t _oldHealth, uint16_t _newHealth, uint16_t _oldArmour, uint16_t _newArmour) : 16 | CEvent(Type::PLAYER_HEAL), 17 | target(_target), 18 | oldHealth(_oldHealth), 19 | newHealth(_newHealth), 20 | oldArmour(_oldArmour), 21 | newArmour(_newArmour) 22 | { 23 | 24 | } 25 | 26 | IPlayer* GetTarget() const { return target.get(); } 27 | uint16_t GetOldHealth() const { return oldHealth; } 28 | uint16_t GetNewHealth() const { return newHealth; } 29 | uint16_t GetOldArmour() const { return oldArmour; } 30 | uint16_t GetNewArmour() const { return newArmour; } 31 | 32 | private: 33 | std::shared_ptr target; 34 | uint16_t oldHealth; 35 | uint16_t newHealth; 36 | uint16_t oldArmour; 37 | uint16_t newArmour; 38 | }; 39 | } 40 | #endif -------------------------------------------------------------------------------- /events/CPlayerLeaveVehicleEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IVehicle; 8 | class IPlayer; 9 | 10 | class CPlayerLeaveVehicleEvent : public CEvent 11 | { 12 | public: 13 | CPlayerLeaveVehicleEvent(const std::shared_ptr& _target, const std::shared_ptr& _player, uint8_t _seat) : 14 | CEvent(Type::PLAYER_LEAVE_VEHICLE), 15 | target(_target), 16 | player(_player), 17 | seat(_seat) 18 | { 19 | 20 | } 21 | 22 | IVehicle* GetTarget() const { return target.get(); } 23 | IPlayer* GetPlayer() const { return player.get(); } 24 | uint8_t GetSeat() const { return seat; } 25 | 26 | private: 27 | std::shared_ptr target; 28 | std::shared_ptr player; 29 | uint8_t seat; 30 | }; 31 | } -------------------------------------------------------------------------------- /events/CPlayerRequestControlEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IEntity; 8 | class IPlayer; 9 | 10 | class CPlayerRequestControlEvent : public CCancellableEvent 11 | { 12 | public: 13 | CPlayerRequestControlEvent(const std::shared_ptr& _target, const std::shared_ptr& _player) : 14 | CCancellableEvent(Type::PLAYER_REQUEST_CONTROL), 15 | target(_target), 16 | player(_player) 17 | { 18 | 19 | } 20 | 21 | IEntity* GetTarget() const { return target.get(); } 22 | IPlayer* GetPlayer() const { return player.get(); } 23 | 24 | private: 25 | std::shared_ptr target; 26 | std::shared_ptr player; 27 | }; 28 | } -------------------------------------------------------------------------------- /events/CPlayerSpawnEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IPlayer; 10 | 11 | class CPlayerSpawnEvent : public CEvent 12 | { 13 | public: 14 | CPlayerSpawnEvent(const std::shared_ptr& _player) : 15 | CEvent(Type::PLAYER_SPAWN), 16 | player(_player) 17 | { 18 | 19 | } 20 | 21 | IPlayer* GetPlayer() const { return player.get(); } 22 | 23 | private: 24 | std::shared_ptr player; 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /events/CPlayerStartEnterVehicleEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IVehicle; 8 | class IPlayer; 9 | 10 | class CPlayerStartEnterVehicleEvent : public CCancellableEvent 11 | { 12 | public: 13 | CPlayerStartEnterVehicleEvent(const std::shared_ptr& _target, const std::shared_ptr& _player, uint8_t _seat) : 14 | CCancellableEvent(Type::PLAYER_START_ENTER_VEHICLE), 15 | target(_target), 16 | player(_player), 17 | seat(_seat) 18 | { 19 | 20 | } 21 | 22 | IVehicle* GetTarget() const { return target.get(); } 23 | IPlayer* GetPlayer() const { return player.get(); } 24 | uint8_t GetSeat() const { return seat; } 25 | 26 | private: 27 | std::shared_ptr target; 28 | std::shared_ptr player; 29 | uint8_t seat; 30 | }; 31 | } -------------------------------------------------------------------------------- /events/CPlayerStartLeaveVehicleEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IVehicle; 8 | class IPlayer; 9 | 10 | class CPlayerStartLeaveVehicleEvent : public CCancellableEvent 11 | { 12 | public: 13 | CPlayerStartLeaveVehicleEvent(const std::shared_ptr& _target, const std::shared_ptr& _player, uint8_t _seat) : 14 | CCancellableEvent(Type::PLAYER_START_LEAVE_VEHICLE), 15 | target(_target), 16 | player(_player), 17 | seat(_seat) 18 | { 19 | 20 | } 21 | 22 | IVehicle* GetTarget() const { return target.get(); } 23 | IPlayer* GetPlayer() const { return player.get(); } 24 | uint8_t GetSeat() const { return seat; } 25 | 26 | private: 27 | std::shared_ptr target; 28 | std::shared_ptr player; 29 | uint8_t seat; 30 | }; 31 | } -------------------------------------------------------------------------------- /events/CPlayerStartTalkingEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IPlayer; 8 | 9 | class CPlayerStartTalkingEvent : public CEvent 10 | { 11 | public: 12 | CPlayerStartTalkingEvent(const std::shared_ptr& _player) : 13 | CEvent(Type::PLAYER_START_TALKING), 14 | player(_player) 15 | { 16 | 17 | } 18 | 19 | IPlayer* GetPlayer() const { return player.get(); } 20 | 21 | private: 22 | std::shared_ptr player; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /events/CPlayerStopTalkingEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IPlayer; 8 | 9 | class CPlayerStopTalkingEvent : public CEvent 10 | { 11 | public: 12 | CPlayerStopTalkingEvent(const std::shared_ptr& _player) : 13 | CEvent(Type::PLAYER_STOP_TALKING), 14 | player(_player) 15 | { 16 | 17 | } 18 | 19 | IPlayer* GetPlayer() const { return player.get(); } 20 | 21 | private: 22 | std::shared_ptr player; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /events/CPlayerWeaponChangeEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IPlayer; 8 | 9 | class CPlayerWeaponChangeEvent : public CEvent 10 | { 11 | public: 12 | #ifdef ALT_SERVER_API 13 | CPlayerWeaponChangeEvent(const std::shared_ptr& _target, uint32_t _oldWeapon, uint32_t _newWeapon) : 14 | CEvent(Type::PLAYER_WEAPON_CHANGE), 15 | target(_target), 16 | oldWeapon(_oldWeapon), 17 | newWeapon(_newWeapon) 18 | {} 19 | #endif 20 | #ifdef ALT_CLIENT_API 21 | CPlayerWeaponChangeEvent(uint32_t _oldWeapon, uint32_t _newWeapon) : 22 | CEvent(Type::PLAYER_WEAPON_CHANGE), 23 | oldWeapon(_oldWeapon), 24 | newWeapon(_newWeapon) 25 | {} 26 | #endif 27 | 28 | #ifdef ALT_SERVER_API 29 | IPlayer* GetTarget() const { return target.get(); } 30 | #endif 31 | uint32_t GetOldWeapon() const { return oldWeapon; } 32 | uint32_t GetNewWeapon() const { return newWeapon; } 33 | 34 | private: 35 | #ifdef ALT_SERVER_API 36 | std::shared_ptr target; 37 | #endif 38 | uint32_t oldWeapon; 39 | uint32_t newWeapon; 40 | }; 41 | } -------------------------------------------------------------------------------- /events/CPlayerWeaponShootEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class CPlayerWeaponShootEvent : public CEvent 8 | { 9 | public: 10 | CPlayerWeaponShootEvent(uint32_t _weapon, uint16_t _totalAmmo, uint16_t _ammoInClip) : 11 | CEvent(Type::PLAYER_WEAPON_SHOOT_EVENT), 12 | weapon(_weapon), 13 | totalAmmo(_totalAmmo), 14 | ammoInClip(_ammoInClip) 15 | {} 16 | 17 | uint32_t GetWeapon() const { return weapon; } 18 | uint16_t GetTotalAmmo() const { return totalAmmo; } 19 | uint16_t GetAmmoInClip() const { return ammoInClip; } 20 | 21 | private: 22 | uint32_t weapon; 23 | uint16_t totalAmmo; 24 | uint16_t ammoInClip; 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /events/CRemoveBaseObjectEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | #include "../objects/IBaseObject.h" 5 | 6 | namespace alt 7 | { 8 | class CRemoveBaseObjectEvent : public CEvent 9 | { 10 | public: 11 | CRemoveBaseObjectEvent(const std::shared_ptr& _target) : 12 | CEvent(Type::REMOVE_BASE_OBJECT_EVENT), 13 | target(_target) 14 | { 15 | 16 | } 17 | 18 | IBaseObject* GetObject() const { return target.get(); } 19 | 20 | private: 21 | std::shared_ptr target; 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /events/CRequestSyncedSceneEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../deps/alt-math/alt-math.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IEntity; 10 | class IPlayer; 11 | 12 | class CRequestSyncedSceneEvent : public CCancellableEvent 13 | { 14 | public: 15 | CRequestSyncedSceneEvent(const std::shared_ptr _source, int32_t _sceneID) : 16 | CCancellableEvent(Type::REQUEST_SYNCED_SCENE), 17 | source(_source), 18 | sceneID(_sceneID) 19 | { 20 | 21 | } 22 | 23 | IPlayer* GetSource() const { return source.get(); } 24 | int32_t GetSceneID() const { return sceneID; } 25 | 26 | private: 27 | std::shared_ptr source; 28 | int32_t sceneID; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /events/CResourceErrorEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../IResource.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class CResourceErrorEvent : public CEvent 10 | { 11 | public: 12 | CResourceErrorEvent(IResource* _resource) : 13 | CEvent(Type::RESOURCE_ERROR), 14 | resource(_resource) 15 | { 16 | 17 | } 18 | 19 | IResource* GetResource() const { return resource; } 20 | 21 | private: 22 | IResource* resource; 23 | }; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /events/CResourceStartEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../IResource.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class CResourceStartEvent : public CEvent 10 | { 11 | public: 12 | CResourceStartEvent(IResource* _resource) : 13 | CEvent(Type::RESOURCE_START), 14 | resource(_resource) 15 | { 16 | 17 | } 18 | 19 | IResource* GetResource() const { return resource; } 20 | 21 | private: 22 | IResource* resource; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /events/CResourceStopEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../IResource.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class CResourceStopEvent : public CEvent 10 | { 11 | public: 12 | CResourceStopEvent(IResource* _resource) : 13 | CEvent(Type::RESOURCE_STOP), 14 | resource(_resource) 15 | { 16 | 17 | } 18 | 19 | IResource* GetResource() const { return resource; } 20 | 21 | private: 22 | IResource* resource; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /events/CRmlEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | #include "../types/MValue.h" 5 | #include "../script-objects/IRml.h" 6 | 7 | namespace alt 8 | { 9 | class CRmlEvent : public CCancellableEvent 10 | { 11 | public: 12 | CRmlEvent(const std::shared_ptr& _element, const std::string& _name, const MValueDict& _args) : 13 | CCancellableEvent(Type::RMLUI_EVENT), 14 | element(_element), 15 | name(_name), 16 | args(_args) 17 | { 18 | 19 | } 20 | 21 | IRmlElement* GetElement() const { return element.get(); } 22 | std::string GetName() const { return name; } 23 | const MValueDict& GetArgs() const { return args; } 24 | 25 | private: 26 | std::shared_ptr element; 27 | std::string name; 28 | MValueDict args; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /events/CScriptRPCAnswerEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../types/MValue.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IPlayer; 10 | #ifdef ALT_CLIENT_API 11 | class CScriptRPCAnswerEvent : public CEvent 12 | { 13 | public: 14 | CScriptRPCAnswerEvent(uint16_t _answerID, const MValue& _answer, const std::string& _error) : 15 | CEvent(Type::SCRIPT_RPC_ANSWER_EVENT), 16 | answerID(_answerID), 17 | answer(_answer), 18 | answerError(_error) 19 | { 20 | 21 | } 22 | 23 | uint16_t GetAnswerID() const { return answerID; } 24 | MValue GetAnswer() const { return answer; } 25 | std::string GetAnswerError() const { return answerError; } 26 | 27 | private: 28 | uint16_t answerID; 29 | MValue answer; 30 | std::string answerError; 31 | }; 32 | #else 33 | class CScriptRPCAnswerEvent : public CEvent 34 | { 35 | public: 36 | CScriptRPCAnswerEvent(const std::shared_ptr& _target, uint16_t _answerID, const MValue& _answer, const std::string& _error) : 37 | CEvent(Type::SCRIPT_RPC_ANSWER_EVENT), 38 | target(_target), 39 | answerID(_answerID), 40 | answer(_answer), 41 | answerError(_error) 42 | { 43 | 44 | } 45 | 46 | IPlayer* GetTarget() const { return target.get(); } 47 | uint16_t GetAnswerID() const { return answerID; } 48 | MValue GetAnswer() const { return answer; } 49 | std::string GetAnswerError() const { return answerError; } 50 | 51 | private: 52 | std::shared_ptr target; 53 | uint16_t answerID; 54 | MValue answer; 55 | std::string answerError; 56 | }; 57 | #endif 58 | } 59 | -------------------------------------------------------------------------------- /events/CScriptRPCEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../types/MValue.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IPlayer; 10 | 11 | class CScriptRPCEvent : public CEvent 12 | { 13 | public: 14 | enum class State { 15 | NOT_ANSWERED, 16 | WILL_BE_ANSWERED, 17 | ANSWERED 18 | }; 19 | 20 | #ifdef ALT_SERVER_API 21 | CScriptRPCEvent(const std::shared_ptr& _target, const std::string& _name, const MValueArgs&_args, uint16_t _answerID) : 22 | CEvent(Type::SCRIPT_RPC_EVENT), 23 | target(_target), 24 | name(_name), 25 | args(_args), 26 | answerID(_answerID) 27 | { 28 | 29 | } 30 | #else 31 | CScriptRPCEvent(const std::string& _name, const MValueArgs&_args, uint16_t _answerID) : 32 | CEvent(Type::SCRIPT_RPC_EVENT), 33 | name(_name), 34 | args(_args), 35 | answerID(_answerID) 36 | { 37 | 38 | } 39 | #endif 40 | 41 | #ifdef ALT_SERVER_API 42 | IPlayer* GetTarget() const { return target.get(); } 43 | #endif 44 | const std::string& GetName() const { return name; } 45 | const MValueArgs& GetArgs() const { return args; } 46 | uint16_t GetAnswerID() const { return answerID; } 47 | 48 | bool WillAnswer() 49 | { 50 | if (state != State::NOT_ANSWERED) 51 | { 52 | return false; 53 | } 54 | state = State::WILL_BE_ANSWERED; 55 | return true; 56 | } 57 | 58 | bool Answer(MValue _answer) 59 | { 60 | if (state == State::ANSWERED) 61 | { 62 | return false; 63 | } 64 | state = State::ANSWERED; 65 | answer = _answer; 66 | return true; 67 | } 68 | 69 | bool AnswerWithError(const std::string& _error) 70 | { 71 | if (state == State::ANSWERED) 72 | { 73 | return false; 74 | } 75 | state = State::ANSWERED; 76 | answerError = _error; 77 | return true; 78 | } 79 | 80 | State GetState() const { return state; } 81 | 82 | MValue GetAnswer() const { return answer; } 83 | 84 | std::string GetAnswerError() const { return answerError; } 85 | 86 | private: 87 | State state = State::NOT_ANSWERED; 88 | #ifdef ALT_SERVER_API 89 | std::shared_ptr target; 90 | #endif 91 | std::string name; 92 | MValueArgs args; 93 | uint16_t answerID; 94 | MValue answer; 95 | std::string answerError; 96 | }; 97 | } 98 | -------------------------------------------------------------------------------- /events/CServerScriptEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../types/MValue.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IPlayer; 10 | 11 | class CServerScriptEvent : public CEvent 12 | { 13 | public: 14 | CServerScriptEvent(const std::string& _name, const MValueArgs& _args) : 15 | CEvent(Type::SERVER_SCRIPT_EVENT), 16 | name(_name), 17 | args(_args) 18 | { 19 | 20 | } 21 | 22 | const std::string& GetName() const { return name; } 23 | const MValueArgs& GetArgs() const { return args; } 24 | 25 | private: 26 | std::string name; 27 | MValueArgs args; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /events/CServerStartedEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class CServerStartedEvent : public CEvent 10 | { 11 | public: 12 | CServerStartedEvent() : CEvent(Type::SERVER_STARTED) {} 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /events/CSpawnedEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class CSpawnedEvent : public CEvent 10 | { 11 | public: 12 | CSpawnedEvent() : CEvent(Type::SPAWNED) {} 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /events/CStartProjectileEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../deps/alt-math/alt-math.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IEntity; 10 | class IPlayer; 11 | 12 | class CStartProjectileEvent : public CCancellableEvent 13 | { 14 | public: 15 | CStartProjectileEvent(const std::shared_ptr _source, Position _startPosition, Vector3f _direction, uint32_t _ammoHash, uint32_t _weaponHash) : 16 | CCancellableEvent(Type::START_PROJECTILE_EVENT), 17 | source(_source), 18 | startPosition(_startPosition), 19 | direction(_direction), 20 | ammoHash(_ammoHash), 21 | weaponHash(_weaponHash) 22 | { 23 | 24 | } 25 | 26 | IPlayer* GetSource() const { return source.get(); } 27 | Position GetStartPosition() const { return startPosition; } 28 | Vector3f GetDirection() const { return direction; } 29 | uint32_t GetAmmoHash() const { return ammoHash; } 30 | uint32_t GetWeaponHash() const { return weaponHash; } 31 | 32 | private: 33 | std::shared_ptr source; 34 | Position startPosition; 35 | Vector3f direction; 36 | uint32_t ammoHash; 37 | uint32_t weaponHash; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /events/CStartSyncedSceneEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../deps/alt-math/alt-math.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IEntity; 10 | class IPlayer; 11 | 12 | class CStartSyncedSceneEvent : public CCancellableEvent 13 | { 14 | public: 15 | CStartSyncedSceneEvent(const std::shared_ptr _source, int32_t _sceneID, Position _startPosition, Rotation _startRotation, uint32_t _animDictHash, std::unordered_map, uint32_t>& _entityAndAnimHashPairs) : 16 | CCancellableEvent(Type::START_SYNCED_SCENE), 17 | source(_source), 18 | sceneID(_sceneID), 19 | startPosition(_startPosition), 20 | startRotation(_startRotation), 21 | animDictHash(_animDictHash), 22 | entityAndAnimHashPairs(_entityAndAnimHashPairs) 23 | { 24 | 25 | } 26 | 27 | IPlayer* GetSource() const { return source.get(); } 28 | int32_t GetSceneID() const { return sceneID; } 29 | 30 | Position GetStartPosition() const { return startPosition; } 31 | Rotation GetStartRotation() const { return startRotation; } 32 | 33 | uint32_t GetAnimDictHash() const { return animDictHash; } 34 | 35 | std::unordered_map, uint32_t> GetEntityAndAnimHashPairs() const { return entityAndAnimHashPairs; } 36 | 37 | private: 38 | std::shared_ptr source; 39 | int32_t sceneID; 40 | 41 | Position startPosition; 42 | Rotation startRotation; 43 | 44 | uint32_t animDictHash; 45 | 46 | std::unordered_map, uint32_t> entityAndAnimHashPairs; 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /events/CStopSyncedSceneEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../deps/alt-math/alt-math.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IEntity; 10 | class IPlayer; 11 | 12 | class CStopSyncedSceneEvent : public CCancellableEvent 13 | { 14 | public: 15 | CStopSyncedSceneEvent(const std::shared_ptr _source, int32_t _sceneID) : 16 | CCancellableEvent(Type::STOP_SYNCED_SCENE), 17 | source(_source), 18 | sceneID(_sceneID) 19 | { 20 | 21 | } 22 | 23 | IPlayer* GetSource() const { return source.get(); } 24 | int32_t GetSceneID() const { return sceneID; } 25 | 26 | private: 27 | std::shared_ptr source; 28 | int32_t sceneID; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /events/CStreamSyncedMetaDataChangeEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../types/MValue.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IBaseObject; 10 | 11 | class CStreamSyncedMetaDataChangeEvent : public CEvent 12 | { 13 | public: 14 | CStreamSyncedMetaDataChangeEvent(const std::shared_ptr& _target, const std::string& _key, MValueConst _val, MValueConst _oldVal) : 15 | CEvent(Type::STREAM_SYNCED_META_CHANGE), 16 | target(_target), 17 | key(_key), 18 | val(_val), 19 | oldVal(_oldVal) 20 | { 21 | 22 | } 23 | 24 | IBaseObject* GetTarget() const { return target.get(); } 25 | std::string GetKey() const { return key; } 26 | MValueConst GetVal() const { return val; } 27 | MValueConst GetOldVal() const { return oldVal; } 28 | 29 | private: 30 | std::shared_ptr target; 31 | std::string key; 32 | MValueConst val; 33 | MValueConst oldVal; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /events/CSyncedMetaDataChangeEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../types/MValue.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IBaseObject; 10 | 11 | class CSyncedMetaDataChangeEvent : public CEvent 12 | { 13 | public: 14 | CSyncedMetaDataChangeEvent(const std::shared_ptr& _target, const std::string& _key, MValueConst _val, MValueConst _oldVal) : 15 | CEvent(Type::SYNCED_META_CHANGE), 16 | target(_target), 17 | key(_key), 18 | val(_val), 19 | oldVal(_oldVal) 20 | { 21 | 22 | } 23 | 24 | IBaseObject* GetTarget() const { return target.get(); } 25 | std::string GetKey() const { return key; } 26 | MValueConst GetVal() const { return val; } 27 | MValueConst GetOldVal() const { return oldVal; } 28 | 29 | private: 30 | std::shared_ptr target; 31 | std::string key; 32 | MValueConst val; 33 | MValueConst oldVal; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /events/CTaskChangeEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IPlayer; 8 | 9 | class CTaskChangeEvent : public CCancellableEvent 10 | { 11 | public: 12 | CTaskChangeEvent(const std::shared_ptr _target, uint32_t _oldTask, uint32_t _newTask) : 13 | CCancellableEvent(Type::TASK_CHANGE), 14 | target(_target), 15 | oldTask(_oldTask), 16 | newTask(_newTask) 17 | { 18 | } 19 | 20 | IPlayer* GetTarget() const { return target.get(); } 21 | uint32_t GetOldTask() const { return oldTask; } 22 | uint32_t GetNewTask() const { return newTask; } 23 | 24 | private: 25 | std::shared_ptr target; 26 | uint32_t oldTask; 27 | uint32_t newTask; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /events/CUpdateSyncedSceneEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../deps/alt-math/alt-math.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IEntity; 10 | class IPlayer; 11 | 12 | class CUpdateSyncedSceneEvent : public CCancellableEvent 13 | { 14 | public: 15 | CUpdateSyncedSceneEvent(const std::shared_ptr _source, int32_t _sceneID, float _startRate) : 16 | CCancellableEvent(Type::STOP_SYNCED_SCENE), 17 | source(_source), 18 | sceneID(_sceneID), 19 | startRate(_startRate) 20 | { 21 | 22 | } 23 | 24 | IPlayer* GetSource() const { return source.get(); } 25 | float GetStartRate() const { return startRate; } 26 | int32_t GetSceneID() const { return sceneID; } 27 | 28 | private: 29 | std::shared_ptr source; 30 | int32_t sceneID; 31 | float startRate; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /events/CVehicleAttachEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IVehicle; 8 | 9 | class CVehicleAttachEvent : public CEvent 10 | { 11 | public: 12 | CVehicleAttachEvent(const std::shared_ptr& _target, const std::shared_ptr& _attached) : 13 | CEvent(Type::VEHICLE_ATTACH), 14 | target(_target), 15 | attached(_attached) 16 | { 17 | 18 | } 19 | 20 | IVehicle* GetTarget() const { return target.get(); } 21 | IVehicle* GetAttached() const { return attached.get(); } 22 | 23 | private: 24 | std::shared_ptr target; 25 | std::shared_ptr attached; 26 | }; 27 | } -------------------------------------------------------------------------------- /events/CVehicleDamageEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IVehicle; 10 | class IEntity; 11 | 12 | class CVehicleDamageEvent : public CEvent 13 | { 14 | public: 15 | CVehicleDamageEvent(const std::shared_ptr& _target, const std::shared_ptr& _damager, 16 | uint32_t _bodyHealthDamage, uint32_t _bodyAdditionalHealthDamage, 17 | uint32_t _engineHealthDamage, uint32_t _petrolTankHealthDamage, uint32_t _damagedWith) : 18 | CEvent(Type::VEHICLE_DAMAGE), 19 | target(_target), 20 | damager(_damager), 21 | bodyHealthDamage(_bodyHealthDamage), 22 | bodyAdditionalHealthDamage(_bodyAdditionalHealthDamage), 23 | engineHealthDamage(_engineHealthDamage), 24 | petrolTankHealthDamage(_petrolTankHealthDamage), 25 | damagedWith(_damagedWith) 26 | { 27 | 28 | } 29 | 30 | IVehicle* GetTarget() const { return target.get(); } 31 | 32 | IEntity* GetDamager() const { return damager.get(); } 33 | 34 | uint32_t GetBodyHealthDamage() const { return bodyHealthDamage; } 35 | 36 | uint32_t GetBodyAdditionalHealthDamage() const { return bodyAdditionalHealthDamage; } 37 | 38 | uint32_t GetEngineHealthDamage() const { return engineHealthDamage; } 39 | 40 | uint32_t GetPetrolTankHealthDamage() const { return petrolTankHealthDamage; } 41 | 42 | uint32_t GetDamagedWith() const { return damagedWith; } 43 | 44 | private: 45 | std::shared_ptr target; 46 | std::shared_ptr damager; 47 | uint32_t bodyHealthDamage; 48 | uint32_t bodyAdditionalHealthDamage; 49 | uint32_t engineHealthDamage; 50 | uint32_t petrolTankHealthDamage; 51 | uint32_t damagedWith; 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /events/CVehicleDestroyEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IVehicle; 10 | class IEntity; 11 | 12 | class CVehicleDestroyEvent : public CEvent 13 | { 14 | public: 15 | CVehicleDestroyEvent(const std::shared_ptr& _target) : 16 | CEvent(Type::VEHICLE_DESTROY), 17 | target(_target) 18 | { 19 | 20 | } 21 | 22 | IVehicle* GetTarget() const { return target.get(); } 23 | 24 | private: 25 | std::shared_ptr target; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /events/CVehicleDetachEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IVehicle; 8 | 9 | class CVehicleDetachEvent : public CEvent 10 | { 11 | public: 12 | CVehicleDetachEvent(const std::shared_ptr& _target, const std::shared_ptr& _detached) : 13 | CEvent(Type::VEHICLE_DETACH), 14 | target(_target), 15 | detached(_detached) 16 | { 17 | 18 | } 19 | 20 | IVehicle* GetTarget() const { return target.get(); } 21 | IVehicle* GetDetached() const { return detached.get(); } 22 | 23 | private: 24 | std::shared_ptr target; 25 | std::shared_ptr detached; 26 | }; 27 | } -------------------------------------------------------------------------------- /events/CVehicleHornEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "CEvent.h" 6 | #include "../objects/IPlayer.h" 7 | #include "../objects/IVehicle.h" 8 | 9 | namespace alt 10 | { 11 | class CVehicleHornEvent : public CCancellableEvent 12 | { 13 | public: 14 | CVehicleHornEvent(const std::shared_ptr& _target, const std::shared_ptr& _reporter, bool _toggle) : 15 | CCancellableEvent(Type::VEHICLE_HORN), 16 | target(_target), 17 | reporter(_reporter), 18 | toggle(_toggle) 19 | { 20 | 21 | } 22 | 23 | IVehicle* GetTarget() const { return target.get(); } 24 | IPlayer* GetReporter() const { return reporter.get(); } 25 | bool GetToggle() const { return toggle; } 26 | 27 | private: 28 | std::shared_ptr target; 29 | std::shared_ptr reporter; 30 | bool toggle; 31 | }; 32 | } -------------------------------------------------------------------------------- /events/CVehicleSirenEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "CEvent.h" 6 | #include "../objects/IVehicle.h" 7 | 8 | namespace alt 9 | { 10 | class CVehicleSirenEvent : public CEvent 11 | { 12 | public: 13 | CVehicleSirenEvent(const std::shared_ptr& _target, bool _toggle) : 14 | CEvent(Type::VEHICLE_SIREN), 15 | target(_target), 16 | toggle(_toggle) 17 | { 18 | 19 | } 20 | 21 | IVehicle* GetTarget() const { return target.get(); } 22 | bool GetToggle() const { return toggle; } 23 | 24 | private: 25 | std::shared_ptr target; 26 | bool toggle; 27 | }; 28 | } -------------------------------------------------------------------------------- /events/CVoiceConnectionEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | #include 6 | 7 | namespace alt 8 | { 9 | class CVoiceConnectionEvent : public CEvent 10 | { 11 | public: 12 | enum class State: uint8_t 13 | { 14 | DISCONNECTED, 15 | CONNECTING, 16 | REQUESTING_CONNECT, 17 | REDIRECTING, 18 | REQUESTING_REDIRECT_CONNECT, 19 | CONNECTED 20 | }; 21 | 22 | explicit CVoiceConnectionEvent(const State _state) : 23 | CEvent(Type::VOICE_CONNECTION_EVENT), 24 | state(_state) 25 | { 26 | 27 | } 28 | 29 | State GetState() const { return state; } 30 | 31 | private: 32 | State state; 33 | }; 34 | } -------------------------------------------------------------------------------- /events/CWeaponDamageEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../deps/alt-math/alt-math.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IPlayer; 10 | class IEntity; 11 | 12 | class CWeaponDamageEvent : public CCancellableEvent 13 | { 14 | public: 15 | enum class BodyPart : int8_t 16 | { 17 | PELVIS, 18 | LEFT_HIP, 19 | LEFT_LEG, 20 | LEFT_FOOT, 21 | RIGHT_HIP, 22 | RIGHT_LEG, 23 | RIGHT_FOOT, 24 | LOWER_TORSO, 25 | UPPER_TORSO, 26 | CHEST, 27 | UNDER_NECK, 28 | LEFT_SHOULDER, 29 | LEFT_UPPER_ARM, 30 | LEFT_ELBROW, 31 | LEFT_WRIST, 32 | RIGHT_SHOULDER, 33 | RIGHT_UPPER_ARM, 34 | RIGHT_ELBROW, 35 | RIGHT_WRIST, 36 | NECK, 37 | HEAD, 38 | 39 | UNKNOWN = -1 40 | }; 41 | 42 | CWeaponDamageEvent(const std::shared_ptr& _source, const std::shared_ptr& _target, uint32_t _weaponHash, uint32_t _damageValue, Vector3f _shotOffset, BodyPart _bodyPart, const std::shared_ptr& _sourceEntity = nullptr) : 43 | CCancellableEvent(Type::WEAPON_DAMAGE_EVENT), 44 | source(_source), 45 | target(_target), 46 | weaponHash(_weaponHash), 47 | damageValue(_damageValue), 48 | shotOffset(_shotOffset), 49 | bodyPart(_bodyPart), 50 | sourceEntity(_sourceEntity) 51 | { 52 | 53 | } 54 | 55 | IPlayer* GetSource() const { return source.get(); } 56 | IEntity* GetTarget() const { return target.get(); } 57 | uint32_t GetWeaponHash() const { return weaponHash; } 58 | uint32_t GetDamageValue() const { return damageValue; } 59 | Vector3f GetShotOffset() const { return shotOffset; } 60 | BodyPart GetBodyPart() const { return bodyPart; } 61 | IEntity* GetSourceEntity() const { return sourceEntity.get(); } 62 | 63 | void SetDamageValue(uint32_t _damageValue) 64 | { 65 | damageValue = _damageValue; 66 | } 67 | 68 | private: 69 | std::shared_ptr source; 70 | std::shared_ptr target; 71 | std::shared_ptr sourceEntity; 72 | uint32_t weaponHash; 73 | uint32_t damageValue; 74 | Vector3f shotOffset; 75 | BodyPart bodyPart; 76 | }; 77 | } 78 | -------------------------------------------------------------------------------- /events/CWebSocketClientEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../types/MValue.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IWebSocketClient; 10 | 11 | class CWebSocketClientEvent : public CEvent 12 | { 13 | public: 14 | CWebSocketClientEvent(const std::shared_ptr& _target, const std::string& _name, const MValueArgs& _args) : CEvent(Type::WEB_SOCKET_CLIENT_EVENT), 15 | target(_target), 16 | name(_name), 17 | args(_args) 18 | { 19 | } 20 | 21 | IWebSocketClient* GetTarget() const { return target.get(); } 22 | const std::string& GetName() const { return name; } 23 | const MValueArgs& GetArgs() const { return args; } 24 | 25 | private: 26 | std::shared_ptr target; 27 | std::string name; 28 | MValueArgs args; 29 | }; 30 | } // namespace alt 31 | -------------------------------------------------------------------------------- /events/CWebViewEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../types/MValue.h" 4 | 5 | #include "CEvent.h" 6 | 7 | namespace alt 8 | { 9 | class IWebView; 10 | 11 | class CWebViewEvent : public CEvent 12 | { 13 | public: 14 | CWebViewEvent(const std::shared_ptr& _target, const std::string& _name, const MValueArgs &_args) : CEvent(Type::WEB_VIEW_EVENT), 15 | target(_target), 16 | name(_name), 17 | args(_args) 18 | { 19 | } 20 | 21 | IWebView* GetTarget() const { return target.get(); } 22 | const std::string& GetName() const { return name; } 23 | const MValueArgs &GetArgs() const { return args; } 24 | 25 | private: 26 | std::shared_ptr target; 27 | std::string name; 28 | MValueArgs args; 29 | }; 30 | } // namespace alt 31 | -------------------------------------------------------------------------------- /events/CWindowFocusChangeEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | 5 | namespace alt 6 | { 7 | class IPlayer; 8 | 9 | class CWindowFocusChangeEvent : public CEvent 10 | { 11 | public: 12 | CWindowFocusChangeEvent(bool _state) : 13 | CEvent(Type::WINDOW_FOCUS_CHANGE), 14 | state(_state) 15 | { 16 | } 17 | 18 | bool GetState() const { return state; } 19 | 20 | private: 21 | bool state; 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /events/CWindowResolutionChangeEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CEvent.h" 4 | #include "../deps/alt-math/alt-math.h" 5 | 6 | namespace alt 7 | { 8 | class CWindowResolutionChangeEvent : public CEvent 9 | { 10 | public: 11 | CWindowResolutionChangeEvent(Vector2i _oldResolution, Vector2i _newResolution) : 12 | CEvent(Type::WINDOW_RESOLUTION_CHANGE), 13 | oldResolution(_oldResolution), 14 | newResolution(_newResolution) 15 | { 16 | } 17 | 18 | Vector2i GetOldResolution() const { return oldResolution; } 19 | Vector2i GetNewResolution() const { return newResolution; } 20 | 21 | private: 22 | Vector2i oldResolution; 23 | Vector2i newResolution; 24 | }; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /events/CWorldObjectPositonChangeEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "CEvent.h" 7 | 8 | #include "../deps/alt-math/alt-math.h" 9 | 10 | namespace alt 11 | { 12 | class IWorldObject; 13 | 14 | class CWorldObjectPositionChangeEvent : public CEvent 15 | { 16 | public: 17 | CWorldObjectPositionChangeEvent(const std::shared_ptr& _worldObject, const alt::Position& _oldPosition) : 18 | CEvent(Type::WORLD_OBJECT_POSITION_CHANGE), 19 | worldObject(_worldObject), 20 | oldPosition(_oldPosition) 21 | { 22 | 23 | } 24 | 25 | IWorldObject* GetWorldObject() const { return worldObject.get(); } 26 | const alt::Position& GetOldPosition() const { return oldPosition; } 27 | 28 | private: 29 | std::shared_ptr worldObject; 30 | alt::Position oldPosition; 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /events/CWorldObjectStreamInEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "CEvent.h" 7 | 8 | #include "../deps/alt-math/alt-math.h" 9 | 10 | namespace alt 11 | { 12 | class IWorldObject; 13 | 14 | class CWorldObjectStreamInEvent : public CEvent 15 | { 16 | public: 17 | CWorldObjectStreamInEvent(const std::shared_ptr& _worldObject) : 18 | CEvent(Type::WORLD_OBJECT_STREAM_IN), 19 | worldObject(_worldObject) 20 | { 21 | 22 | } 23 | 24 | IWorldObject* GetWorldObject() const { return worldObject.get(); } 25 | 26 | private: 27 | std::shared_ptr worldObject; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /events/CWorldObjectStreamOutEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "CEvent.h" 7 | 8 | #include "../deps/alt-math/alt-math.h" 9 | 10 | namespace alt 11 | { 12 | class IWorldObject; 13 | 14 | class CWorldObjectStreamOutEvent : public CEvent 15 | { 16 | public: 17 | CWorldObjectStreamOutEvent(const std::shared_ptr& _worldObject) : 18 | CEvent(Type::WORLD_OBJECT_STREAM_OUT), 19 | worldObject(_worldObject) 20 | { 21 | 22 | } 23 | 24 | IWorldObject* GetWorldObject() const { return worldObject.get(); } 25 | 26 | private: 27 | std::shared_ptr worldObject; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /objects/IBaseObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../types/MValue.h" 4 | #include 5 | #include 6 | 7 | namespace alt 8 | { 9 | class IBaseObject: public std::enable_shared_from_this 10 | { 11 | protected: 12 | virtual ~IBaseObject() = default; 13 | 14 | public: 15 | enum class Type : uint8_t 16 | { 17 | PLAYER, 18 | VEHICLE, 19 | PED, 20 | OBJECT, 21 | BLIP, 22 | WEBVIEW, 23 | VOICE_CHANNEL, 24 | COLSHAPE, 25 | CHECKPOINT, 26 | WEBSOCKET_CLIENT, 27 | HTTP_CLIENT, 28 | AUDIO, 29 | AUDIO_OUTPUT, 30 | AUDIO_OUTPUT_WORLD, 31 | AUDIO_OUTPUT_ATTACHED, 32 | AUDIO_OUTPUT_FRONTEND, 33 | RML_ELEMENT, 34 | RML_DOCUMENT, 35 | LOCAL_PLAYER, 36 | LOCAL_OBJECT, 37 | VIRTUAL_ENTITY, 38 | VIRTUAL_ENTITY_GROUP, 39 | MARKER, 40 | TEXT_LABEL, 41 | LOCAL_PED, 42 | LOCAL_VEHICLE, 43 | AUDIO_FILTER, 44 | CONNECTION_INFO, 45 | CUSTOM_TEXTURE, 46 | FONT, 47 | SIZE 48 | }; 49 | 50 | virtual Type GetType() const = 0; 51 | 52 | virtual uint32_t GetID() const = 0; 53 | 54 | virtual bool HasMetaData(const std::string& key) const = 0; 55 | virtual MValueConst GetMetaData(const std::string& key) const = 0; 56 | virtual void SetMetaData(const std::string& key, MValue val) = 0; 57 | virtual void SetMultipleMetaData(const std::unordered_map& values) = 0; 58 | virtual void DeleteMetaData(const std::string& key) = 0; 59 | virtual std::vector GetMetaDataKeys() const = 0; 60 | 61 | virtual bool HasSyncedMetaData(const std::string& key) const = 0; 62 | virtual MValueConst GetSyncedMetaData(const std::string& key) const = 0; 63 | virtual std::vector GetSyncedMetaDataKeys() const = 0; 64 | 65 | #ifdef ALT_SERVER_API 66 | virtual void SetSyncedMetaData(const std::string& key, MValue val) = 0; 67 | virtual void SetMultipleSyncedMetaData(const std::unordered_map& values) = 0; 68 | virtual void DeleteSyncedMetaData(const std::string& key) = 0; 69 | #endif 70 | #ifdef ALT_CLIENT_API 71 | virtual uint32_t GetRemoteID() const = 0; 72 | virtual bool IsRemote() const = 0; 73 | #endif // ALT_CLIENT_API 74 | 75 | virtual bool IsRemoved() const = 0; 76 | 77 | template 78 | std::shared_ptr SharedAs() 79 | { 80 | try 81 | { 82 | Derived* derived = dynamic_cast(this); 83 | if (!derived) 84 | { 85 | static std::shared_ptr empty; 86 | return empty; 87 | } 88 | std::shared_ptr shared = derived->shared_from_this(); 89 | return std::dynamic_pointer_cast(shared); 90 | } 91 | catch (std::bad_weak_ptr&) 92 | { 93 | static std::shared_ptr empty; 94 | return empty; 95 | } 96 | } 97 | 98 | template 99 | Derived* As() 100 | { 101 | return dynamic_cast(this); 102 | } 103 | }; 104 | } // namespace alt 105 | -------------------------------------------------------------------------------- /objects/IEntity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../deps/alt-math/alt-math.h" 4 | #include "../types/MValue.h" 5 | #include "../types/SyncInfo.h" 6 | #include "IWorldObject.h" 7 | 8 | #include 9 | 10 | namespace alt 11 | { 12 | class IPlayer; 13 | 14 | /// @brief Game entity interface 15 | /// @warning Should use client-safe methods on client side 16 | class IEntity : public virtual IWorldObject 17 | { 18 | protected: 19 | ~IEntity() noexcept override = default; 20 | 21 | public: 22 | virtual uint16_t GetSyncID() const = 0; 23 | 24 | virtual IPlayer* GetNetworkOwner() const = 0; 25 | 26 | virtual uint32_t GetModel() const = 0; 27 | 28 | virtual Rotation GetRotation() const = 0; 29 | virtual void SetRotation(Rotation rot) = 0; 30 | 31 | virtual bool HasStreamSyncedMetaData(const std::string& key) const = 0; 32 | virtual MValueConst GetStreamSyncedMetaData(const std::string& key) const = 0; 33 | virtual std::vector GetStreamSyncedMetaDataKeys() const = 0; 34 | virtual bool GetVisible() const = 0; 35 | 36 | virtual bool IsFrozen() const = 0; 37 | virtual void SetFrozen(bool state) = 0; 38 | 39 | virtual bool IsStaticEntity() const = 0; 40 | 41 | #ifdef ALT_SERVER_API 42 | // Should not override and use server-only methods on the client 43 | virtual uint32_t GetTimestamp() const = 0; 44 | virtual void SetNetworkOwner(IPlayer* player, bool disableMigration) = 0; 45 | 46 | virtual void SetStreamSyncedMetaData(const std::string& key, MValue val) = 0; 47 | virtual void SetMultipleStreamSyncedMetaData(const std::unordered_map& values) = 0; 48 | virtual void DeleteStreamSyncedMetaData(const std::string& key) = 0; 49 | virtual void SetVisible(bool toggle) = 0; 50 | 51 | virtual void AttachToEntity(IEntity* entity, uint16_t otherBoneId, uint16_t myBoneId, Position position, Rotation rotation, bool collision, bool noFixedRotation) = 0; 52 | virtual void AttachToEntity(IEntity* entity, const std::string& otherBoneName, const std::string& myBoneName, Position position, Rotation rotation, bool collision, bool noFixedRotation) = 0; 53 | virtual void Detach() = 0; 54 | 55 | virtual void SetStreamed(bool toggle) = 0; 56 | virtual bool GetStreamed() const = 0; 57 | 58 | 59 | virtual bool HasCollision() const = 0; 60 | virtual void SetCollision(bool state) = 0; 61 | 62 | virtual uint32_t GetStreamingDistance() const = 0; 63 | virtual void SetStreamingDistance(uint32_t streamingDistance) = 0; 64 | 65 | virtual void SetStaticEntity(bool state) = 0; 66 | #endif // ALT_SERVER_API 67 | 68 | #ifdef ALT_CLIENT_API 69 | // Client-safe methods 70 | virtual uint32_t GetScriptID() const = 0; 71 | virtual SyncInfo GetSyncInfo() const = 0; 72 | 73 | virtual float GetMass() const = 0; 74 | virtual void SetMass(float mass) = 0; 75 | virtual void ResetMass() = 0; 76 | 77 | virtual alt::Vector3f GetAngInertia() const = 0; 78 | virtual void SetAngInertia(const alt::Vector3f& angInertia) = 0; 79 | virtual void ResetAngInertia() = 0; 80 | #endif // ALT_CLIENT_API 81 | }; 82 | } // namespace alt 83 | -------------------------------------------------------------------------------- /objects/ILocalPlayer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IPlayer.h" 4 | #include "../script-objects/IWeaponData.h" 5 | 6 | namespace alt 7 | { 8 | class ILocalPlayer : public virtual IPlayer 9 | { 10 | protected: 11 | virtual ~ILocalPlayer() = default; 12 | 13 | public: 14 | #ifdef ALT_CLIENT_API 15 | virtual uint16_t GetCurrentAmmo() const = 0; 16 | 17 | virtual uint16_t GetWeaponAmmo(uint32_t weaponHash) const = 0; 18 | virtual bool HasWeapon(uint32_t weaponHash) const = 0; 19 | virtual std::vector GetWeapons() const = 0; 20 | virtual std::vector GetWeaponComponents(uint32_t weaponHash) const = 0; 21 | 22 | virtual std::shared_ptr GetCurrentWeaponData() const = 0; 23 | 24 | virtual float GetStamina() const = 0; 25 | virtual void SetStamina(float value) = 0; 26 | virtual float GetMaxStamina() const = 0; 27 | virtual void SetMaxStamina(float value) = 0; 28 | #endif 29 | }; 30 | } // namespace alt 31 | -------------------------------------------------------------------------------- /objects/IObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IEntity.h" 4 | 5 | namespace alt 6 | { 7 | class IObject : public virtual IEntity 8 | { 9 | protected: 10 | virtual ~IObject() = default; 11 | 12 | public: 13 | virtual uint8_t GetAlpha() const = 0; 14 | virtual uint8_t GetTextureVariation() const = 0; 15 | virtual uint16_t GetLodDistance() const = 0; 16 | 17 | #ifdef ALT_SERVER_API 18 | virtual void ActivatePhysics() = 0; 19 | virtual void PlaceOnGroundProperly() = 0; 20 | virtual void SetAlpha(uint8_t alpha) = 0; 21 | virtual void SetTextureVariation(uint8_t textureVariation) = 0; 22 | virtual void SetLodDistance(uint16_t lodDistance) = 0; 23 | #endif 24 | }; 25 | } // namespace alt 26 | -------------------------------------------------------------------------------- /objects/IPed.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IEntity.h" 4 | 5 | namespace alt 6 | { 7 | class IPed : public virtual IEntity 8 | { 9 | protected: 10 | virtual ~IPed() = default; 11 | 12 | public: 13 | virtual uint16_t GetHealth() const = 0; 14 | virtual uint16_t GetMaxHealth() const = 0; 15 | 16 | virtual uint16_t GetArmour() const = 0; 17 | 18 | virtual uint32_t GetCurrentWeapon() const = 0; 19 | 20 | #ifdef ALT_SERVER_API 21 | virtual void SetHealth(uint16_t health) = 0; 22 | virtual void SetMaxHealth(uint16_t health) = 0; 23 | 24 | virtual void SetArmour(uint16_t armor) = 0; 25 | 26 | virtual void SetCurrentWeapon(uint32_t weapon) = 0; 27 | #endif 28 | 29 | }; 30 | } // namespace alt 31 | -------------------------------------------------------------------------------- /objects/IPlayer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "IEntity.h" 7 | #include "IVehicle.h" 8 | #include "../types/Cloth.h" 9 | #include "../types/DlcCloth.h" 10 | #include "../types/Prop.h" 11 | #include "../types/DlcProp.h" 12 | #include "../types/HeadBlendData.h" 13 | #include "../types/HeadOverlay.h" 14 | #include "../types/Weapon.h" 15 | #include "../types/AmmoSpecialType.h" 16 | #include "../types/AmmoFlags.h" 17 | #include "../types/Decoration.h" 18 | #include "../types/CloudAuthResult.h" 19 | 20 | namespace alt 21 | { 22 | class IAudioFilter; 23 | 24 | class IPlayer : public virtual IEntity 25 | { 26 | protected: 27 | virtual ~IPlayer() = default; 28 | 29 | public: 30 | virtual std::string GetName() const = 0; 31 | 32 | virtual uint16_t GetHealth() const = 0; 33 | virtual uint16_t GetMaxHealth() const = 0; 34 | 35 | virtual bool HasWeaponComponent(uint32_t weapon, uint32_t component) const = 0; 36 | virtual std::vector GetCurrentWeaponComponents() const = 0; 37 | 38 | virtual uint8_t GetWeaponTintIndex(uint32_t weapon) const = 0; 39 | virtual uint8_t GetCurrentWeaponTintIndex() const = 0; 40 | 41 | virtual uint32_t GetCurrentWeapon() const = 0; 42 | 43 | virtual bool IsDead() const = 0; 44 | 45 | virtual bool IsJumping() const = 0; 46 | virtual bool IsInRagdoll() const = 0; 47 | virtual bool IsAiming() const = 0; 48 | virtual bool IsShooting() const = 0; 49 | virtual bool IsReloading() const = 0; 50 | virtual bool IsEnteringVehicle() const = 0; 51 | virtual bool IsLeavingVehicle() const = 0; 52 | virtual bool IsOnLadder() const = 0; 53 | virtual bool IsInMelee() const = 0; 54 | virtual bool IsInCover() const = 0; 55 | virtual bool IsParachuting() const = 0; 56 | virtual bool IsInWater() const = 0; 57 | 58 | virtual uint16_t GetArmour() const = 0; 59 | virtual uint16_t GetMaxArmour() const = 0; 60 | 61 | virtual float GetMoveSpeed() const = 0; 62 | 63 | virtual Position GetAimPos() const = 0; 64 | virtual Rotation GetHeadRotation() const = 0; 65 | 66 | virtual bool IsInVehicle() const = 0; 67 | virtual IVehicle* GetVehicle() const = 0; 68 | virtual uint8_t GetSeat() const = 0; 69 | 70 | virtual IEntity* GetEntityAimingAt() const = 0; 71 | virtual Position GetEntityAimOffset() const = 0; 72 | 73 | virtual bool IsFlashlightActive() const = 0; 74 | 75 | virtual bool IsSuperJumpEnabled() const = 0; 76 | virtual bool IsCrouching() const = 0; 77 | virtual bool IsStealthy() const = 0; 78 | 79 | virtual uint32_t GetCurrentAnimationDict() const = 0; 80 | virtual uint32_t GetCurrentAnimationName() const = 0; 81 | 82 | virtual bool IsSpawned() const = 0; 83 | 84 | virtual float GetForwardSpeed() const = 0; 85 | virtual float GetStrafeSpeed() const = 0; 86 | 87 | #ifdef ALT_SERVER_API 88 | virtual bool IsConnected() const = 0; 89 | virtual uint32_t GetPing() const = 0; 90 | virtual std::string GetIP() const = 0; 91 | virtual uint64_t GetSocialID() const = 0; 92 | virtual std::string GetSocialClubName() const = 0; 93 | virtual uint64_t GetHwidHash() const = 0; 94 | virtual uint64_t GetHwidExHash() const = 0; 95 | virtual std::string GetHwid3() const = 0; 96 | virtual std::string GetAuthToken() const = 0; 97 | virtual int64_t GetDiscordId() const = 0; 98 | 99 | virtual void Spawn(Position pos, uint32_t delayMs) = 0; 100 | virtual void Despawn() = 0; 101 | virtual void SetModel(uint32_t model) = 0; 102 | virtual void SetArmour(uint16_t armor) = 0; 103 | virtual void SetMaxArmour(uint16_t armor) = 0; 104 | virtual void SetCurrentWeapon(uint32_t weapon) = 0; 105 | virtual void SetWeaponTintIndex(uint32_t weapon, uint8_t tintIndex) = 0; 106 | virtual void AddWeaponComponent(uint32_t weapon, uint32_t component) = 0; 107 | virtual void RemoveWeaponComponent(uint32_t weapon, uint32_t component) = 0; 108 | virtual void ClearBloodDamage() = 0; 109 | virtual void SetHealth(uint16_t health) = 0; 110 | virtual void SetMaxHealth(uint16_t health) = 0; 111 | virtual void GiveWeapon(uint32_t weapon, int32_t ammo, bool selectWeapon) = 0; 112 | virtual bool RemoveWeapon(uint32_t weapon) = 0; 113 | virtual void RemoveAllWeapons(bool removeAllAmmo) = 0; 114 | virtual void SetDateTime(int day, int month, int year, int hour, int minute, int second) = 0; 115 | virtual void SetWeather(uint32_t weather) = 0; 116 | virtual void Kick(const std::string& reason = "Kicked") = 0; 117 | virtual alt::Cloth GetClothes(uint8_t component) const = 0; 118 | virtual bool SetClothes(uint8_t component, uint16_t drawable, uint8_t texture, uint8_t palette) = 0; 119 | virtual alt::DlcCloth GetDlcClothes(uint8_t component) const = 0; 120 | virtual bool SetDlcClothes(uint8_t component, uint16_t drawable, uint8_t texture, uint8_t palette, uint32_t dlc) = 0; 121 | virtual bool ClearClothes(uint8_t component) = 0; 122 | virtual alt::Prop GetProps(uint8_t component) const = 0; 123 | virtual bool SetProps(uint8_t component, uint16_t drawable, uint8_t texture) = 0; 124 | virtual alt::DlcProp GetDlcProps(uint8_t component) const = 0; 125 | virtual bool SetDlcProps(uint8_t component, uint8_t drawable, uint8_t texture, uint32_t dlc) = 0; 126 | virtual void ClearProps(uint8_t component) = 0; 127 | virtual bool IsEntityInStreamingRange(uint16_t entityId) = 0; 128 | virtual void SetInvincible(bool toggle) = 0; 129 | virtual bool GetInvincible() const = 0; 130 | virtual void SetIntoVehicle(IVehicle* vehicle, uint8_t seat) = 0; 131 | virtual void PlayAmbientSpeech(const std::string& speechName, const std::string& speechParam, uint32_t speechDictHash) = 0; 132 | virtual bool SetHeadOverlay(uint8_t overlayID, uint8_t index, float opacity) = 0; 133 | virtual bool RemoveHeadOverlay(uint8_t overlayID) = 0; 134 | virtual bool SetHeadOverlayColor(uint8_t overlayID, uint8_t colorType, uint8_t colorIndex, uint8_t secondColorIndex) = 0; 135 | virtual HeadOverlay GetHeadOverlay(uint8_t overlayID) const = 0; 136 | virtual bool SetFaceFeature(uint8_t index, float scale) = 0; 137 | virtual float GetFaceFeatureScale(uint8_t index) const = 0; 138 | virtual bool RemoveFaceFeature(uint8_t index) = 0; 139 | virtual bool SetHeadBlendPaletteColor(uint8_t id, uint8_t red, uint8_t green, uint8_t blue) = 0; 140 | virtual void RemoveHeadBlendPaletteColor() = 0; 141 | virtual RGBA GetHeadBlendPaletteColor(uint8_t id) const = 0; 142 | virtual void SetHeadBlendData(uint32_t shapeFirstID, uint32_t shapeSecondID, uint32_t shapeThirdID, 143 | uint32_t skinFirstID, uint32_t skinSecondID, uint32_t skinThirdID, 144 | float shapeMix, float skinMix, float thirdMix) = 0; 145 | virtual void RemoveHeadBlendData() = 0; 146 | virtual HeadBlendData GetHeadBlendData() const = 0; 147 | virtual bool SetEyeColor(int16_t eyeColor) = 0; 148 | virtual int16_t GetEyeColor() const = 0; 149 | virtual void SetHairColor(uint8_t hairColor) = 0; 150 | virtual uint8_t GetHairColor() const = 0; 151 | virtual void SetHairHighlightColor(uint8_t hairHighlightColor) = 0; 152 | virtual uint8_t GetHairHighlightColor() const = 0; 153 | virtual std::vector GetWeapons() const = 0; 154 | virtual bool HasWeapon(uint32_t weapon) const = 0; 155 | 156 | virtual bool HasLocalMetaData(const std::string& key) const = 0; 157 | virtual void SetLocalMetaData(const std::string& key, MValue val) = 0; 158 | virtual MValueConst GetLocalMetaData(const std::string& key) const = 0; 159 | virtual void DeleteLocalMetaData(const std::string& key) = 0; 160 | virtual std::vector GetLocalMetaDataKeys() const = 0; 161 | 162 | virtual uint32_t GetInteriorLocation() const = 0; 163 | 164 | virtual uint32_t GetLastDamagedBodyPart() const = 0; 165 | virtual void SetLastDamagedBodyPart(uint32_t bodyPart) = 0; 166 | virtual void SetSendNames(bool state) = 0; 167 | virtual bool GetSendNames() const = 0; 168 | 169 | virtual void PlayAnimation(const std::string& animDict, const std::string& animName, float blendInSpeed, float blendOutSpeed, int duration, int flags, float playbackRate, bool lockX, bool lockY, bool lockZ) = 0; 170 | virtual void ClearTasks() = 0; 171 | virtual void PlayScenario(const std::string& name) = 0; 172 | 173 | virtual std::vector> GetStreamedEntities() const = 0; 174 | 175 | virtual void SetAmmo(uint32_t ammoHash, uint16_t ammo) = 0; 176 | virtual uint16_t GetAmmo(uint32_t ammoHash) const = 0; 177 | virtual void SetWeaponAmmo(uint32_t weaponHash, uint16_t ammo) = 0; 178 | virtual uint16_t GetWeaponAmmo(uint32_t weaponHash) const = 0; 179 | virtual void SetAmmoSpecialType(uint32_t ammoHash, AmmoSpecialType ammoSpecialType) = 0; 180 | virtual AmmoSpecialType GetAmmoSpecialType(uint32_t ammoHash) const = 0; 181 | virtual void SetAmmoFlags(uint32_t ammoHash, AmmoFlags ammoFlags) = 0; 182 | virtual AmmoFlags GetAmmoFlags(uint32_t ammoHash) const = 0; 183 | virtual void SetAmmoMax(uint32_t ammoHash, int32_t ammoMax) = 0; 184 | virtual int32_t GetAmmoMax(uint32_t ammoHash) const = 0; 185 | virtual void SetAmmoMax50(uint32_t ammoHash, int32_t ammoMax50) = 0; 186 | virtual int32_t GetAmmoMax50(uint32_t ammoHash) const = 0; 187 | virtual void SetAmmoMax100(uint32_t ammoHash, int32_t ammoMax100) = 0; 188 | virtual int32_t GetAmmoMax100(uint32_t ammoHash) const = 0; 189 | 190 | virtual void AddDecoration(uint32_t collection, uint32_t overlay, uint8_t count = 1) = 0; 191 | virtual void RemoveDecoration(uint32_t collection, uint32_t overlay) = 0; 192 | virtual void ClearDecorations() = 0; 193 | virtual std::vector GetDecorations() const = 0; 194 | 195 | virtual bool IsNetworkOwnershipDisabled() const = 0; 196 | virtual void SetNetworkOwnershipDisabled(bool disabled) = 0; 197 | 198 | virtual std::string GetCloudID() const = 0; 199 | virtual CloudAuthResult GetCloudAuthResult() const = 0; 200 | 201 | virtual std::string GetBloodDamageBase64() const = 0; 202 | virtual void SetBloodDamageBase64(const std::string& _base64) = 0; 203 | 204 | virtual bool IsOnVehicle() const = 0; 205 | #endif // ALT_SERVER_API 206 | 207 | #ifdef ALT_CLIENT_API 208 | virtual bool IsTalking() const = 0; 209 | virtual float GetMicLevel() const = 0; 210 | 211 | virtual float GetSpatialVolume() const = 0; 212 | virtual void SetSpatialVolume(float volume) = 0; 213 | virtual float GetNonSpatialVolume() const = 0; 214 | virtual void SetNonSpatialVolume(float volume) = 0; 215 | 216 | virtual void AddFilter(IAudioFilter* filter) = 0; 217 | virtual void RemoveFilter() = 0; 218 | virtual IAudioFilter* GetFilter() const = 0; 219 | virtual std::string GetTaskData() const = 0; 220 | #endif // ALT_CLIENT_API 221 | }; 222 | } // namespace alt 223 | -------------------------------------------------------------------------------- /objects/IWorldObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../deps/alt-math/alt-math.h" 6 | #include "IBaseObject.h" 7 | 8 | namespace alt 9 | { 10 | class IWorldObject : public virtual IBaseObject 11 | { 12 | protected: 13 | virtual ~IWorldObject() = default; 14 | 15 | public: 16 | virtual Position GetPosition() const = 0; 17 | virtual void SetPosition(Position pos) = 0; 18 | 19 | virtual int32_t GetDimension() const = 0; 20 | virtual void SetDimension(int32_t dimension) = 0; 21 | }; 22 | } // namespace alt 23 | -------------------------------------------------------------------------------- /script-objects/IAudio.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../objects/IBaseObject.h" 4 | #include "IAudioOutput.h" 5 | 6 | namespace alt 7 | { 8 | class IAudio : public virtual IBaseObject 9 | { 10 | public: 11 | virtual ~IAudio() = default; 12 | 13 | virtual void SetSource(const std::string& source) = 0; //data/file/url 14 | virtual const std::string& GetSource() const = 0; 15 | 16 | virtual void SetLoop(bool toggle) = 0; 17 | virtual void SetVolume(float volume) = 0; //0.0 - 1.0 range 18 | 19 | virtual bool IsLoop() const = 0; 20 | virtual float GetVolume() const = 0; 21 | 22 | virtual void AddOutput(IAudioOutput* output) = 0; 23 | virtual void RemoveOutput(IAudioOutput* output) = 0; 24 | virtual MValueList GetOutputs() = 0; 25 | 26 | virtual void Play() = 0; 27 | virtual void Pause() = 0; 28 | virtual void Reset() = 0; 29 | virtual double GetCurrentTime() const = 0; //seconds 30 | virtual double GetMaxTime() const = 0; //seconds 31 | virtual void Seek(double time) = 0; //seconds 32 | virtual bool IsPlaying() const = 0; 33 | }; 34 | } -------------------------------------------------------------------------------- /script-objects/IAudioAttachedOutput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IAudioOutput.h" 4 | 5 | namespace alt 6 | { 7 | class IAudioAttachedOutput : public virtual IAudioOutput 8 | { 9 | public: 10 | virtual void SetEntity(IWorldObject* entity) = 0; 11 | virtual IWorldObject* GetEntity() const = 0; 12 | }; 13 | } -------------------------------------------------------------------------------- /script-objects/IAudioCategory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../objects/IBaseObject.h" 4 | 5 | namespace alt 6 | { 7 | class IAudioCategory 8 | { 9 | public: 10 | virtual ~IAudioCategory() = default; 11 | 12 | virtual std::string GetName() const = 0; 13 | 14 | virtual float GetVolume() const = 0; 15 | virtual float GetDistanceRolloffScale() const = 0; 16 | virtual float GetPlateauRolloffScale() const = 0; 17 | virtual float GetOcclusionDamping() const = 0; 18 | virtual float GetEnvironmentalFilterDamping() const = 0; 19 | virtual float GetSourceReverbDamping() const = 0; 20 | virtual float GetDistanceReverbDamping() const = 0; 21 | virtual float GetInteriorReverbDamping() const = 0; 22 | virtual float GetEnvironmentalLoudness() const = 0; 23 | virtual float GetUnderwaterWetLevel() const = 0; 24 | virtual float GetStonedWetLevel() const = 0; 25 | virtual int16_t GetPitch() const = 0; 26 | virtual int16_t GetLowPassFilterCutoff() const = 0; 27 | virtual int16_t GetHighPassFilterCutoff() const = 0; 28 | 29 | virtual void SetVolume(float value) = 0; 30 | virtual void SetDistanceRolloffScale(float value) = 0; 31 | virtual void SetPlateauRolloffScale(float value) = 0; 32 | virtual void SetOcclusionDamping(float value) = 0; 33 | virtual void SetEnvironmentalFilterDamping(float value) = 0; 34 | virtual void SetSourceReverbDamping(float value) = 0; 35 | virtual void SetDistanceReverbDamping(float value) = 0; 36 | virtual void SetInteriorReverbDamping(float value) = 0; 37 | virtual void SetEnvironmentalLoudness(float value) = 0; 38 | virtual void SetUnderwaterWetLevel(float value) = 0; 39 | virtual void SetStonedWetLevel(float value) = 0; 40 | virtual void SetPitch(int16_t value) = 0; 41 | virtual void SetLowPassFilterCutoff(int16_t value) = 0; 42 | virtual void SetHighPassFilterCutoff(int16_t value) = 0; 43 | 44 | virtual void Reset() = 0; 45 | }; 46 | } -------------------------------------------------------------------------------- /script-objects/IAudioFilter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../objects/IBaseObject.h" 4 | 5 | namespace alt 6 | { 7 | class IAudioFilter : public virtual IBaseObject 8 | { 9 | public: 10 | virtual ~IAudioFilter() = default; 11 | 12 | virtual uint32_t GetHash() const = 0; 13 | 14 | virtual uint32_t GetAudCategory() const = 0; 15 | virtual void SetAudCategory(uint32_t category) = 0; 16 | 17 | virtual uint32_t AddRotateEffect(float fRate, int priority) const = 0; 18 | virtual uint32_t AddVolumeEffect(float fVolume, int priority, int channel = -1) const = 0; 19 | virtual uint32_t AddPeakeqEffect(int lBand, float fBandwidth, float fQ, float fCenter, float fGain, int priority) const = 0; 20 | virtual uint32_t AddDampEffect(float fTarget, float fQuiet, float fRate, float fGain, float fDelay, int priority) const = 0; 21 | virtual uint32_t AddAutowahEffect(float fDryMix, float fWetMix, float fFeedback, float fRate, float fRange, float fFreq, int priority) const = 0; 22 | virtual uint32_t AddPhaserEffect(float fDryMix, float fWetMix, float fFeedback, float fRate, float fRange, float fFreq, int priority) const = 0; 23 | virtual uint32_t AddChorusEffect(float fDryMix, float fWetMix, float fFeedback, float fMinSweep, float fMaxSweep, float fRate, int priority) const = 0; 24 | virtual uint32_t AddDistortionEffect(float fDrive, float fDryMix, float fWetMix, float fFeedback, float fVolume, int priority) const = 0; 25 | virtual uint32_t AddCompressor2Effect(float fGain, float fThreshold, float fRatio, float fAttack, float fRelease, int priority) const = 0; 26 | virtual uint32_t AddBqfEffect(int lFilter, float fCenter, float fGain, float fBandwidth, float fQ, float fS, int priority) const = 0; 27 | virtual uint32_t AddEcho4Effect(float fDryMix, float fWetMix, float fFeedback, float fDelay, int priority) const = 0; 28 | virtual uint32_t AddPitchshiftEffect(float fPitchShift, float fSemitones, long lFFTsize, long lOsamp, int priority) const = 0; 29 | virtual uint32_t AddFreeverbEffect(float fDryMix, float fWetMix, float fRoomSize, float fDamp, float fWidth, uint32_t lMode, int priority) const = 0; 30 | 31 | virtual bool RemoveEffect(uint32_t hfxHandler) const = 0; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /script-objects/IAudioFrontendOutput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IAudioOutput.h" 4 | 5 | namespace alt 6 | { 7 | class IAudioFrontendOutput : public virtual IAudioOutput 8 | { 9 | public: 10 | 11 | }; 12 | } -------------------------------------------------------------------------------- /script-objects/IAudioOutput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../objects/IBaseObject.h" 4 | 5 | namespace alt 6 | { 7 | class IAudio; 8 | class IAudioFilter; 9 | class IAudioOutput : public virtual IBaseObject 10 | { 11 | public: 12 | virtual void SetVolume(float vol) = 0; 13 | virtual float GetVolume() const = 0; 14 | 15 | virtual void SetMuted(bool toggle) = 0; 16 | virtual bool IsMuted() const = 0; 17 | 18 | virtual uint32_t GetCategory() const = 0; 19 | 20 | virtual IBaseObject* GetOwner() const = 0; 21 | 22 | virtual void AddFilter(IAudioFilter* filter) = 0; 23 | virtual void RemoveFilter() = 0; 24 | virtual IAudioFilter* GetFilter() const = 0; 25 | }; 26 | } -------------------------------------------------------------------------------- /script-objects/IAudioWorldOutput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IAudioOutput.h" 4 | 5 | namespace alt 6 | { 7 | class IAudioWorldOutput : public virtual IAudioOutput 8 | { 9 | public: 10 | virtual void SetPosition(alt::Position pos) = 0; 11 | virtual alt::Position GetPosition() const = 0; 12 | }; 13 | } -------------------------------------------------------------------------------- /script-objects/IBlip.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "../objects/IWorldObject.h" 5 | 6 | namespace alt 7 | { 8 | class IEntity; 9 | class IPlayer; 10 | 11 | class IBlip : public virtual IWorldObject 12 | { 13 | public: 14 | enum class BlipType 15 | { 16 | VEHICLE = 1, 17 | PED = 2, 18 | OBJECT = 3, 19 | DESTINATION = 4, 20 | CONT = 5, 21 | PICKUP_UNK = 6, 22 | RADIUS = 7, 23 | PICKUP = 8, 24 | COP = 9, 25 | AREA = 11, 26 | GALLERY = 12, 27 | PICKUP_OBJECT = 13 28 | }; 29 | 30 | virtual ~IBlip() = default; 31 | 32 | virtual void SetVisible(bool toggle) = 0; 33 | virtual bool IsVisible() const = 0; 34 | 35 | virtual bool IsGlobal() const = 0; 36 | virtual bool IsAttached() const = 0; 37 | virtual IEntity* AttachedTo() const = 0; 38 | virtual void AttachTo(IEntity* entity) = 0; 39 | virtual BlipType GetBlipType() const = 0; 40 | virtual void SetBlipType(BlipType blipType) = 0; 41 | 42 | virtual Vector2f GetScaleXY() const = 0; 43 | virtual void SetScaleXY(Vector2f scale) = 0; 44 | virtual uint32_t GetDisplay() const = 0; 45 | virtual void SetDisplay(uint32_t display) = 0; 46 | virtual uint32_t GetSprite() const = 0; 47 | virtual uint32_t GetColor() const = 0; 48 | virtual alt::RGBA GetSecondaryColor() const = 0; 49 | virtual uint32_t GetAlpha() const = 0; 50 | virtual int GetFlashTimer() const = 0; 51 | virtual int GetFlashInterval() const = 0; 52 | virtual bool GetAsFriendly() const = 0; 53 | virtual bool GetRoute() const = 0; 54 | virtual bool GetBright() const = 0; 55 | virtual int GetNumber() const = 0; 56 | virtual bool GetShowCone() const = 0; 57 | virtual bool GetFlashes() const = 0; 58 | virtual bool GetFlashesAlternate() const = 0; 59 | virtual bool GetAsShortRange() const = 0; 60 | virtual uint32_t GetPriority() const = 0; 61 | virtual float GetRotation() const = 0; 62 | virtual std::string GetGxtName() const = 0; 63 | virtual std::string GetName() const = 0; 64 | virtual alt::RGBA GetRouteColor() const = 0; 65 | virtual bool GetPulse() const = 0; 66 | virtual bool GetAsMissionCreator() const = 0; 67 | virtual bool GetTickVisible() const = 0; 68 | virtual bool GetHeadingIndicatorVisible() const = 0; 69 | virtual bool GetOutlineIndicatorVisible() const = 0; 70 | virtual bool GetFriendIndicatorVisible() const = 0; 71 | virtual bool GetCrewIndicatorVisible() const = 0; 72 | virtual uint32_t GetCategory() const = 0; 73 | virtual bool GetAsHighDetail() const = 0; 74 | virtual bool GetShrinked() const = 0; 75 | #ifdef ALT_CLIENT_API 76 | virtual uint32_t GetGameID() const = 0; 77 | virtual bool IsStreamedIn() const = 0; 78 | #endif 79 | 80 | #ifdef ALT_SERVER_API 81 | virtual void SetGlobal(bool state) = 0; 82 | virtual void AddTargetPlayer(IPlayer* player) = 0; 83 | virtual void RemoveTargetPlayer(IPlayer* player) = 0; 84 | virtual std::vector GetTargets() const = 0; 85 | #endif 86 | 87 | virtual void SetSprite(uint32_t sprite) = 0; 88 | virtual void SetColor(uint32_t color) = 0; 89 | virtual void SetRoute(bool state) = 0; 90 | virtual void SetRouteColor(alt::RGBA color) = 0; 91 | virtual void SetSecondaryColor(alt::RGBA color) = 0; 92 | virtual void SetAlpha(uint32_t alpha) = 0; 93 | virtual void SetFlashTimer(int timer) = 0; 94 | virtual void SetFlashInterval(int interval) = 0; 95 | virtual void SetAsFriendly(bool friendly) = 0; 96 | virtual void SetBright(bool bright) = 0; 97 | virtual void SetNumber(int number) = 0; 98 | virtual void SetShowCone(bool state) = 0; 99 | virtual void SetFlashes(bool state) = 0; 100 | virtual void SetFlashesAlternate(bool state) = 0; 101 | virtual void SetAsShortRange(bool state) = 0; 102 | virtual void SetPriority(uint32_t state) = 0; 103 | virtual void SetRotation(float rot) = 0; 104 | virtual void SetGxtName(const std::string& name) = 0; 105 | virtual void SetName(const std::string& name) = 0; 106 | virtual void SetPulse(bool val) = 0; 107 | virtual void SetAsMissionCreator(bool val) = 0; 108 | virtual void SetTickVisible(bool val) = 0; 109 | virtual void SetHeadingIndicatorVisible(bool val) = 0; 110 | virtual void SetOutlineIndicatorVisible(bool val) = 0; 111 | virtual void SetFriendIndicatorVisible(bool val) = 0; 112 | virtual void SetCrewIndicatorVisible(bool val) = 0; 113 | virtual void SetCategory(uint32_t val) = 0; 114 | virtual void SetAsHighDetail(bool val) = 0; 115 | virtual void SetShrinked(bool val) = 0; 116 | virtual void Fade(uint32_t opacity, uint32_t duration) = 0; 117 | 118 | virtual bool IsHiddenOnLegend() const = 0; 119 | virtual void SetHiddenOnLegend(bool state) = 0; 120 | 121 | virtual bool IsMinimalOnEdge() const = 0; 122 | virtual void SetMinimalOnEdge(bool state) = 0; 123 | 124 | virtual bool IsUseHeightIndicatorOnEdge() const = 0; 125 | virtual void SetUseHeightIndicatorOnEdge(bool state) = 0; 126 | 127 | virtual bool IsShortHeightThreshold() const = 0; 128 | virtual void SetShortHeightThreshold(bool state) = 0; 129 | }; 130 | } // namespace alt 131 | -------------------------------------------------------------------------------- /script-objects/ICheckpoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "../types/RGBA.h" 7 | #include "IColShape.h" 8 | 9 | namespace alt 10 | { 11 | class IPlayer; 12 | 13 | class ICheckpoint : public virtual IColShape 14 | { 15 | public: 16 | virtual ~ICheckpoint() = default; 17 | 18 | virtual uint8_t GetCheckpointType() const = 0; 19 | virtual float GetHeight() const = 0; 20 | virtual float GetRadius() const = 0; 21 | virtual RGBA GetColor() const = 0; 22 | virtual RGBA GetIconColor() const = 0; 23 | virtual alt::Position GetNextPosition() const = 0; 24 | 25 | virtual void SetCheckpointType(uint8_t type) = 0; 26 | virtual void SetHeight(float height) = 0; 27 | virtual void SetRadius(float radius) = 0; 28 | virtual void SetColor(RGBA color) = 0; 29 | virtual void SetIconColor(RGBA color) = 0; 30 | virtual void SetNextPosition(alt::Position pos) = 0; 31 | 32 | virtual uint32_t GetStreamingDistance() const = 0; 33 | 34 | virtual void SetVisible(bool toggle) = 0; 35 | virtual bool IsVisible() const = 0; 36 | #ifdef ALT_CLIENT_API 37 | virtual bool IsStreamedIn() const = 0; 38 | virtual uint32_t GetGameID() const = 0; 39 | #endif 40 | #ifdef ALT_SERVER_API 41 | virtual bool HasStreamSyncedMetaData(const std::string& key) const = 0; 42 | virtual MValueConst GetStreamSyncedMetaData(const std::string& key) const = 0; 43 | virtual std::vector GetStreamSyncedMetaDataKeys() const = 0; 44 | 45 | virtual void SetStreamSyncedMetaData(const std::string& key, MValue val) = 0; 46 | virtual void SetMultipleStreamSyncedMetaData(const std::unordered_map& values) = 0; 47 | virtual void DeleteStreamSyncedMetaData(const std::string& key) = 0; 48 | #endif 49 | }; 50 | } 51 | -------------------------------------------------------------------------------- /script-objects/IColShape.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../types/RGBA.h" 6 | #include "../objects/IWorldObject.h" 7 | #include "../objects/IEntity.h" 8 | 9 | namespace alt 10 | { 11 | class IEntity; 12 | 13 | class IColShape : public virtual IWorldObject 14 | { 15 | public: 16 | enum class ColShapeType : uint8_t 17 | { 18 | SPHERE, 19 | CYLINDER, 20 | CIRCLE, 21 | CUBOID, 22 | RECT, 23 | CHECKPOINT_CYLINDER, 24 | POLYGON 25 | }; 26 | 27 | virtual ~IColShape() = default; 28 | 29 | virtual ColShapeType GetColshapeType() const = 0; 30 | 31 | virtual bool IsEntityIn(IEntity* ent) const = 0; 32 | virtual bool IsEntityIdIn(uint16_t id) const = 0; 33 | virtual bool IsPointIn(Position p) const = 0; 34 | virtual void SetPlayersOnly(bool state) = 0; 35 | virtual bool IsPlayersOnly() const = 0; 36 | }; 37 | 38 | class IColShapeSphere : public virtual IColShape 39 | { 40 | public: 41 | virtual float GetRadius() const = 0; 42 | }; 43 | 44 | class IColShapeCylinder : public virtual IColShape 45 | { 46 | public: 47 | virtual float GetRadius() const = 0; 48 | virtual float GetHeight() const = 0; 49 | }; 50 | 51 | class IColShapeCircle : public virtual IColShape 52 | { 53 | public: 54 | virtual float GetRadius() const = 0; 55 | }; 56 | 57 | class IColShapeCuboid : public virtual IColShape 58 | { 59 | public: 60 | virtual Position GetMin() const = 0; 61 | virtual Position GetMax() const = 0; 62 | }; 63 | 64 | class IColShapeRect : public virtual IColShape 65 | { 66 | public: 67 | virtual Vector2f GetMin() const = 0; 68 | virtual Vector2f GetMax() const = 0; 69 | }; 70 | 71 | class IColShapePoly : public virtual IColShape 72 | { 73 | public: 74 | virtual float GetMinZ() const = 0; 75 | virtual float GetMaxZ() const = 0; 76 | 77 | virtual std::vector GetPoints() const = 0; 78 | }; 79 | 80 | } // namespace alt 81 | -------------------------------------------------------------------------------- /script-objects/IConnectionInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "../types/CloudAuthResult.h" 7 | 8 | #include "../objects/IBaseObject.h" 9 | 10 | namespace alt 11 | { 12 | class IConnectionInfo : public virtual IBaseObject 13 | { 14 | protected: 15 | virtual ~IConnectionInfo() = default; 16 | 17 | public: 18 | virtual std::string GetName() const = 0; 19 | virtual uint64_t GetSocialId() const = 0; 20 | virtual std::string GetSocialName() const = 0; 21 | virtual uint64_t GetHwIdHash() const = 0; 22 | virtual uint64_t GetHwIdExHash() const = 0; 23 | virtual std::string GetHwid3() const = 0; 24 | virtual std::string GetAuthToken() const = 0; 25 | virtual bool GetIsDebug() const = 0; 26 | virtual std::string GetBranch() const = 0; 27 | virtual uint16_t GetVersionMajor() const = 0; 28 | virtual uint16_t GetVersionMinor() const = 0; 29 | virtual std::string GetCdnUrl() const = 0; 30 | virtual uint64_t GetPasswordHash() const = 0; 31 | virtual std::string GetIp() const = 0; 32 | virtual int64_t GetDiscordUserID() const = 0; 33 | virtual std::string GetText() const = 0; 34 | virtual std::string GetCloudID() const = 0; 35 | virtual CloudAuthResult GetCloudAuthResult() const = 0; 36 | 37 | virtual void Accept(bool sendNames) = 0; 38 | virtual void Decline(const std::string& reason) = 0; 39 | virtual bool IsAccepted() const = 0; 40 | virtual void SetText(const std::string& text) = 0; 41 | }; 42 | } -------------------------------------------------------------------------------- /script-objects/ICustomTexture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../objects/IBaseObject.h" 6 | 7 | namespace alt 8 | { 9 | class ICustomTexture : public virtual IBaseObject 10 | { 11 | protected: 12 | virtual ~ICustomTexture() = default; 13 | 14 | public: 15 | 16 | }; 17 | } -------------------------------------------------------------------------------- /script-objects/IFont.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../objects/IBaseObject.h" 6 | 7 | namespace alt 8 | { 9 | class IFont : public virtual IBaseObject 10 | { 11 | protected: 12 | virtual ~IFont() = default; 13 | 14 | public: 15 | 16 | }; 17 | } -------------------------------------------------------------------------------- /script-objects/IHandlingData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../deps/alt-math/alt-math.h" 4 | 5 | namespace alt 6 | { 7 | class IHandlingData 8 | { 9 | protected: 10 | virtual ~IHandlingData() = default; 11 | 12 | public: 13 | virtual uint32_t GetHandlingNameHash() const = 0; 14 | virtual float GetMass() const = 0; 15 | virtual float GetInitialDragCoeff() const = 0; 16 | virtual float GetDownforceModifier() const = 0; 17 | virtual float GetunkFloat1() const = 0; 18 | virtual float GetunkFloat2() const = 0; 19 | virtual Vector3f GetCentreOfMassOffset() const = 0; 20 | virtual Vector3f GetInertiaMultiplier() const = 0; 21 | virtual float GetPercentSubmerged() const = 0; 22 | virtual float GetPercentSubmergedRatio() const = 0; 23 | virtual float GetDriveBiasFront() const = 0; 24 | virtual float GetDriveBiasRear() const = 0; 25 | virtual float GetAcceleration() const = 0; // Deprecated(wrong name), use GetDriveBiasRear() 26 | virtual uint32_t GetInitialDriveGears() const = 0; 27 | virtual float GetDriveInertia() const = 0; 28 | virtual float GetClutchChangeRateScaleUpShift() const = 0; 29 | virtual float GetClutchChangeRateScaleDownShift() const = 0; 30 | virtual float GetInitialDriveForce() const = 0; 31 | virtual float GetDriveMaxFlatVel() const = 0; // Deprecated(wrong name), use GetInitialDriveMaxVel() 32 | virtual float GetInitialDriveMaxVel() const = 0; 33 | virtual float GetInitialDriveMaxFlatVel() const = 0; 34 | virtual float GetBrakeForce() const = 0; 35 | virtual float GetunkFloat4() const = 0; 36 | virtual float GetBrakeBiasFront() const = 0; 37 | virtual float GetBrakeBiasRear() const = 0; 38 | virtual float GetHandBrakeForce() const = 0; 39 | virtual float GetSteeringLock() const = 0; 40 | virtual float GetSteeringLockRatio() const = 0; 41 | virtual float GetTractionCurveMax() const = 0; 42 | virtual float GetTractionCurveMaxRatio() const = 0; 43 | virtual float GetTractionCurveMin() const = 0; 44 | virtual float GetTractionCurveMinRatio() const = 0; 45 | virtual float GetTractionCurveLateral() const = 0; 46 | virtual float GetTractionCurveLateralRatio() const = 0; 47 | virtual float GetTractionSpringDeltaMax() const = 0; 48 | virtual float GetTractionSpringDeltaMaxRatio() const = 0; 49 | virtual float GetLowSpeedTractionLossMult() const = 0; 50 | virtual float GetCamberStiffness() const = 0; 51 | virtual float GetTractionBiasFront() const = 0; 52 | virtual float GetTractionBiasRear() const = 0; 53 | virtual float GetTractionLossMult() const = 0; 54 | virtual float GetSuspensionForce() const = 0; 55 | virtual float GetSuspensionCompDamp() const = 0; 56 | virtual float GetSuspensionReboundDamp() const = 0; 57 | virtual float GetSuspensionUpperLimit() const = 0; 58 | virtual float GetSuspensionLowerLimit() const = 0; 59 | virtual float GetSuspensionRaise() const = 0; 60 | virtual float GetSuspensionBiasFront() const = 0; 61 | virtual float GetSuspensionBiasRear() const = 0; 62 | virtual float GetAntiRollBarForce() const = 0; 63 | virtual float GetAntiRollBarBiasFront() const = 0; 64 | virtual float GetAntiRollBarBiasRear() const = 0; 65 | virtual float GetRollCentreHeightFront() const = 0; 66 | virtual float GetRollCentreHeightRear() const = 0; 67 | virtual float GetCollisionDamageMult() const = 0; 68 | virtual float GetWeaponDamageMult() const = 0; 69 | virtual float GetDeformationDamageMult() const = 0; 70 | virtual float GetEngineDamageMult() const = 0; 71 | virtual float GetPetrolTankVolume() const = 0; 72 | virtual float GetOilVolume() const = 0; 73 | virtual float GetunkFloat5() const = 0; 74 | virtual float GetSeatOffsetDistX() const = 0; 75 | virtual float GetSeatOffsetDistY() const = 0; 76 | virtual float GetSeatOffsetDistZ() const = 0; 77 | virtual uint32_t GetMonetaryValue() const = 0; 78 | virtual uint32_t GetModelFlags() const = 0; 79 | virtual uint32_t GetHandlingFlags() const = 0; 80 | virtual uint32_t GetDamageFlags() const = 0; 81 | 82 | virtual void SetMass(float val) = 0; 83 | virtual void SetInitialDragCoeff(float val) = 0; 84 | virtual void SetDownforceModifier(float val) = 0; 85 | virtual void SetunkFloat1(float val) = 0; 86 | virtual void SetunkFloat2(float val) = 0; 87 | virtual void SetCentreOfMassOffset(Vector3f val) = 0; 88 | virtual void SetInertiaMultiplier(Vector3f val) = 0; 89 | virtual void SetPercentSubmerged(float val) = 0; 90 | virtual void SetPercentSubmergedRatio(float val) = 0; 91 | virtual void SetDriveBiasFront(float val) = 0; 92 | virtual void SetDriveBiasRear(float val) = 0; 93 | virtual void SetAcceleration(float val) = 0; // Deprecated(wrong name), use SetDriveBiasRear() 94 | virtual void SetInitialDriveGears(uint32_t val) = 0; 95 | virtual void SetDriveInertia(float val) = 0; 96 | virtual void SetClutchChangeRateScaleUpShift(float val) = 0; 97 | virtual void SetClutchChangeRateScaleDownShift(float val) = 0; 98 | virtual void SetInitialDriveForce(float val) = 0; 99 | virtual void SetDriveMaxFlatVel(float val) = 0; // Deprecated(wrong name), use SetInitialDriveMaxVel() 100 | virtual void SetInitialDriveMaxVel(float val) = 0; 101 | virtual void SetInitialDriveMaxFlatVel(float val) = 0; 102 | virtual void SetBrakeForce(float val) = 0; 103 | virtual void SetunkFloat4(float val) = 0; 104 | virtual void SetBrakeBiasFront(float val) = 0; 105 | virtual void SetBrakeBiasRear(float val) = 0; 106 | virtual void SetHandBrakeForce(float val) = 0; 107 | virtual void SetSteeringLock(float val) = 0; 108 | virtual void SetSteeringLockRatio(float val) = 0; 109 | virtual void SetTractionCurveMax(float val) = 0; 110 | virtual void SetTractionCurveMaxRatio(float val) = 0; 111 | virtual void SetTractionCurveMin(float val) = 0; 112 | virtual void SetTractionCurveMinRatio(float val) = 0; 113 | virtual void SetTractionCurveLateral(float val) = 0; 114 | virtual void SetTractionCurveLateralRatio(float val) = 0; 115 | virtual void SetTractionSpringDeltaMax(float val) = 0; 116 | virtual void SetTractionSpringDeltaMaxRatio(float val) = 0; 117 | virtual void SetLowSpeedTractionLossMult(float val) = 0; 118 | virtual void SetCamberStiffness(float val) = 0; 119 | virtual void SetTractionBiasFront(float val) = 0; 120 | virtual void SetTractionBiasRear(float val) = 0; 121 | virtual void SetTractionLossMult(float val) = 0; 122 | virtual void SetSuspensionForce(float val) = 0; 123 | virtual void SetSuspensionCompDamp(float val) = 0; 124 | virtual void SetSuspensionReboundDamp(float val) = 0; 125 | virtual void SetSuspensionUpperLimit(float val) = 0; 126 | virtual void SetSuspensionLowerLimit(float val) = 0; 127 | virtual void SetSuspensionRaise(float val) = 0; 128 | virtual void SetSuspensionBiasFront(float val) = 0; 129 | virtual void SetSuspensionBiasRear(float val) = 0; 130 | virtual void SetAntiRollBarForce(float val) = 0; 131 | virtual void SetAntiRollBarBiasFront(float val) = 0; 132 | virtual void SetAntiRollBarBiasRear(float val) = 0; 133 | virtual void SetRollCentreHeightFront(float val) = 0; 134 | virtual void SetRollCentreHeightRear(float val) = 0; 135 | virtual void SetCollisionDamageMult(float val) = 0; 136 | virtual void SetWeaponDamageMult(float val) = 0; 137 | virtual void SetDeformationDamageMult(float val) = 0; 138 | virtual void SetEngineDamageMult(float val) = 0; 139 | virtual void SetPetrolTankVolume(float val) = 0; 140 | virtual void SetOilVolume(float val) = 0; 141 | virtual void SetunkFloat5(float val) = 0; 142 | virtual void SetSeatOffsetDistX(float val) = 0; 143 | virtual void SetSeatOffsetDistY(float val) = 0; 144 | virtual void SetSeatOffsetDistZ(float val) = 0; 145 | virtual void SetMonetaryValue(uint32_t val) = 0; 146 | virtual void SetModelFlags(uint32_t val) = 0; 147 | virtual void SetHandlingFlags(uint32_t val) = 0; 148 | virtual void SetDamageFlags(uint32_t val) = 0; 149 | }; 150 | } // namespace alt 151 | -------------------------------------------------------------------------------- /script-objects/IHttpClient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../objects/IBaseObject.h" 4 | 5 | namespace alt 6 | { 7 | class IHttpClient : public virtual IBaseObject 8 | { 9 | public: 10 | struct HttpResponse 11 | { 12 | int statusCode; 13 | alt::MValueDict headers; 14 | std::string body; 15 | }; 16 | 17 | using HttpResponseCallback = void (*)(HttpResponse httpResponse, const void* userData); 18 | using HttpProgressCallback = bool (*)(int current, int total, const void* userData); 19 | 20 | virtual ~IHttpClient() = default; 21 | 22 | virtual void SetExtraHeader(const std::string& name, const std::string& value) = 0; 23 | virtual alt::MValueDict GetExtraHeaders() const = 0; 24 | 25 | virtual void Get(HttpResponseCallback httpResponseCallback, const std::string& url, void* userData, HttpProgressCallback httpProgressCallback = nullptr) const = 0; 26 | virtual void Head(HttpResponseCallback httpResponseCallback, const std::string& url, void* userData) const = 0; 27 | virtual void Post(HttpResponseCallback httpResponseCallback, const std::string& url, const std::string& body, void* userData) const = 0; 28 | virtual void Put(HttpResponseCallback httpResponseCallback, const std::string& url, const std::string& body, void* userData) const = 0; 29 | virtual void Delete(HttpResponseCallback httpResponseCallback, const std::string& url, const std::string& body, void* userData) const = 0; 30 | virtual void Connect(HttpResponseCallback httpResponseCallback, const std::string& url, const std::string& body, void* userData) const = 0; 31 | virtual void Options(HttpResponseCallback httpResponseCallback, const std::string& url, const std::string& body, void* userData) const = 0; 32 | virtual void Trace(HttpResponseCallback httpResponseCallback, const std::string& url, const std::string& body, void* userData) const = 0; 33 | virtual void Patch(HttpResponseCallback httpResponseCallback, const std::string& url, const std::string& body, void* userData) const = 0; 34 | }; 35 | } // namespace alt 36 | -------------------------------------------------------------------------------- /script-objects/IInterior.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../types/AABB.h" 5 | //#ifdef ALT_CLIENT_API 6 | 7 | namespace alt 8 | { 9 | class IInteriorRoom; 10 | class IInteriorPortal; 11 | 12 | class IInterior 13 | { 14 | protected: 15 | virtual ~IInterior() = default; 16 | 17 | public: 18 | virtual std::shared_ptr GetRoomByHash(uint32_t hash) const = 0; 19 | virtual std::shared_ptr GetRoomByIndex(uint32_t roomIndex) const = 0; 20 | virtual std::shared_ptr GetPortalByIndex(uint32_t portalIndex) const = 0; 21 | 22 | virtual uint16_t GetRoomCount() const = 0; 23 | virtual uint16_t GetPortalCount() const = 0; 24 | virtual alt::Position GetPosition() const = 0; 25 | virtual alt::Rotation GetRotation() const = 0; 26 | virtual alt::AABB GetEntitiesExtents() const = 0; 27 | }; 28 | } 29 | //##endif -------------------------------------------------------------------------------- /script-objects/IInteriorPortal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../deps/alt-math/alt-math.h" 5 | 6 | namespace alt 7 | { 8 | class IInteriorPortal 9 | { 10 | protected: 11 | virtual ~IInteriorPortal() = default; 12 | 13 | public: 14 | virtual uint32_t GetIndex() const = 0; 15 | virtual uint16_t GetCornerCount() const = 0; 16 | virtual Position GetCornerPosition(uint32_t cornerIndex) const = 0; 17 | virtual int32_t GetRoomFrom() const = 0; 18 | virtual int32_t GetRoomTo() const = 0; 19 | virtual int32_t GetFlag() const = 0; 20 | 21 | virtual uint16_t GetEntityCount() const = 0; 22 | virtual uint32_t GetEntityArcheType(uint32_t entityIndex) const = 0; 23 | virtual int32_t GetEntityFlag(uint32_t entityIndex) const = 0; 24 | virtual alt::Position GetEntityPosition(uint32_t entityIndex) const = 0; 25 | virtual alt::Rotation GetEntityRotation(uint32_t entityIndex) const = 0; 26 | 27 | 28 | virtual void SetCornerPosition(uint32_t cornerIndex, 29 | const alt::Position& position) = 0; 30 | virtual void SetRoomFrom(uint32_t roomFrom) = 0; 31 | virtual void SetRoomTo(uint32_t roomTo) = 0; 32 | virtual void SetFlag(uint32_t flag) = 0; 33 | virtual void SetEntityFlag(uint32_t entityIndex, uint32_t flag) = 0; 34 | 35 | }; 36 | } -------------------------------------------------------------------------------- /script-objects/IInteriorRoom.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "IInterior.h" 5 | 6 | namespace alt 7 | { 8 | class IInteriorRoom 9 | { 10 | protected: 11 | virtual ~IInteriorRoom() = default; 12 | public: 13 | virtual uint32_t GetIndex() const = 0; 14 | virtual std::string GetName() const = 0; 15 | virtual uint32_t GetNameHash() const = 0; 16 | virtual int32_t GetFlag() const = 0; 17 | virtual uint32_t GetTimecycle() const = 0; 18 | virtual alt::AABB GetExtents() const = 0; 19 | 20 | virtual void SetFlag(uint32_t flag) = 0; 21 | virtual void SetTimecycle(uint32_t timecycleHash) = 0; 22 | virtual void SetExtents(alt::AABB aabb) = 0; 23 | }; 24 | } -------------------------------------------------------------------------------- /script-objects/ILocalObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../objects/IObject.h" 4 | 5 | namespace alt 6 | { 7 | class ILocalObject : public virtual IObject 8 | { 9 | public: 10 | virtual void SetModel(uint32_t model) = 0; 11 | virtual void SetAlpha(uint8_t alpha) = 0; 12 | virtual void ResetAlpha() = 0; 13 | 14 | virtual bool IsDynamic() const = 0; 15 | 16 | virtual void SetLodDistance(uint16_t distance) = 0; 17 | 18 | virtual bool HasGravity() const = 0; 19 | virtual void ToggleGravity(bool toggle) = 0; 20 | 21 | virtual void AttachToEntity(IEntity* entity, int16_t boneIndex, alt::Position pos, alt::Rotation rot, bool useSoftPinning, bool collision, bool fixedRot) = 0; 22 | virtual void AttachToEntity(uint32_t scriptId, int16_t boneIndex, alt::Position pos, alt::Rotation rot, bool useSoftPinning, bool collision, bool fixedRot) = 0; 23 | virtual void Detach(bool dynamic) = 0; 24 | 25 | virtual bool IsCollisionEnabled() const = 0; 26 | virtual void ToggleCollision(bool toggle, bool keepPhysics) = 0; 27 | 28 | virtual void PlaceOnGroundProperly() = 0; 29 | 30 | virtual void SetPositionFrozen(bool toggle) = 0; 31 | virtual bool IsPositionFrozen() const = 0; 32 | 33 | virtual void ActivatePhysics() = 0; 34 | 35 | virtual void SetTextureVariation(uint8_t variation) = 0; 36 | 37 | // True = Created by GTA, False = Created by API 38 | virtual bool IsWorldObject() const = 0; 39 | 40 | virtual uint32_t GetStreamingDistance() const = 0; 41 | 42 | virtual void SetVisible(bool toggle) = 0; 43 | virtual bool IsVisible() const = 0; 44 | #ifdef ALT_CLIENT_API 45 | virtual bool IsStreamedIn() const = 0; 46 | virtual bool UsesStreaming() const = 0; 47 | 48 | virtual bool IsWeaponObject() const = 0; 49 | 50 | //weapon object only 51 | virtual void SetTintIndex(int tintIndex) = 0; 52 | virtual int GetTintIndex() const = 0; 53 | 54 | virtual void GiveComponent(int componentType) = 0; 55 | virtual void RemoveComponent(int componentType) = 0; 56 | 57 | virtual void SetComponentTintIndex(int componentType, int tintIndex) = 0; 58 | virtual int GetComponentTintIndex(int componentType) = 0; 59 | #endif 60 | }; 61 | } 62 | -------------------------------------------------------------------------------- /script-objects/ILocalPed.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef ALT_CLIENT_API 4 | 5 | #include 6 | 7 | #include "../objects/IPed.h" 8 | 9 | namespace alt 10 | { 11 | class ILocalPed : public virtual IPed 12 | { 13 | protected: 14 | virtual ~ILocalPed() = default; 15 | public: 16 | virtual void SetModel(uint32_t model) = 0; 17 | 18 | virtual uint32_t GetStreamingDistance() const = 0; 19 | 20 | virtual void SetVisible(bool toggle) = 0; 21 | virtual bool IsVisible() const = 0; 22 | 23 | virtual uint32_t GetScriptID() const = 0; 24 | 25 | virtual bool IsStreamedIn() const = 0; 26 | }; 27 | } 28 | 29 | #endif -------------------------------------------------------------------------------- /script-objects/ILocalVehicle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef ALT_CLIENT_API 4 | 5 | #include 6 | 7 | #include "../objects/IVehicle.h" 8 | 9 | namespace alt 10 | { 11 | class ILocalVehicle : public virtual IVehicle 12 | { 13 | protected: 14 | virtual ~ILocalVehicle() = default; 15 | public: 16 | virtual void SetModel(uint32_t model) = 0; 17 | 18 | virtual uint32_t GetStreamingDistance() const = 0; 19 | 20 | virtual void SetVisible(bool toggle) = 0; 21 | virtual bool IsVisible() const = 0; 22 | 23 | virtual uint32_t GetScriptID() const = 0; 24 | 25 | virtual bool IsStreamedIn() const = 0; 26 | }; 27 | } 28 | 29 | #endif -------------------------------------------------------------------------------- /script-objects/IMapData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../objects/IBaseObject.h" 4 | 5 | namespace alt 6 | { 7 | class IMapData 8 | { 9 | public: 10 | virtual ~IMapData() = default; 11 | 12 | virtual float GetZoomScale() const = 0; 13 | virtual float GetZoomSpeed() const = 0; 14 | virtual float GetScrollSpeed() const = 0; 15 | virtual float GetTilesCountX() const = 0; 16 | virtual float GetTilesCountY() const = 0; 17 | 18 | virtual void SetZoomScale(float scale) = 0; 19 | virtual void SetZoomSpeed(float scale) = 0; 20 | virtual void SetScrollSpeed(float scale) = 0; 21 | virtual void SetTilesCountX(float val) = 0; 22 | virtual void SetTilesCountY(float val) = 0; 23 | }; 24 | } // namespace alt 25 | -------------------------------------------------------------------------------- /script-objects/IMarker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "../objects/IWorldObject.h" 5 | 6 | namespace alt 7 | { 8 | class IMarker : public virtual IWorldObject 9 | { 10 | public: 11 | enum class MarkerType : uint32_t 12 | { 13 | MARKER_CONE = 0, 14 | MARKER_CYLINDER = 1, 15 | MARKER_ARROW = 2, 16 | MARKER_ARROW_FLAT = 3, 17 | MARKER_FLAG = 4, 18 | MARKER_RING_FLAG = 5, 19 | MARKER_RING = 6, 20 | MARKER_PLANE = 7, 21 | MARKER_BIKE_LOGO1 = 8, 22 | MARKER_BIKE_LOGO2 = 9, 23 | MARKER_NUM_0 = 10, 24 | MARKER_NUM_1 = 11, 25 | MARKER_NUM_2 = 12, 26 | MARKER_NUM_3 = 13, 27 | MARKER_NUM_4 = 14, 28 | MARKER_NUM_5 = 15, 29 | MARKER_NUM_6 = 16, 30 | MARKER_NUM_7 = 17, 31 | MARKER_NUM_8 = 18, 32 | MARKER_NUM_9 = 19, 33 | MARKER_CHEVRON_1 = 20, 34 | MARKER_CHEVRON_2 = 21, 35 | MARKER_CHEVRON_3 = 22, 36 | MARKER_RINGFLAT = 23, 37 | MARKER_LAP = 24, 38 | MARKER_HALO = 25, 39 | MARKER_HALO_POINT = 26, 40 | MARKER_HALO_ROTATE = 27, 41 | MARKER_SPHERE = 28, 42 | MARKER_MONEY = 29, 43 | MARKER_LINES = 30, 44 | MARKER_BEAST = 31, 45 | MARKER_QUESTION_MARK = 32, 46 | MARKER_TRANSFORM_PLANE = 33, 47 | MARKER_TRANSFORM_HELICOPTER = 34, 48 | MARKER_TRANSFORM_BOAT = 35, 49 | MARKER_TRANSFORM_CAR = 36, 50 | MARKER_TRANSFORM_BIKE = 37, 51 | MARKER_TRANSFORM_PUSH_BIKE = 38, 52 | MARKER_TRANSFORM_TRUCK = 39, 53 | MARKER_TRANSFORM_PARACHUTE = 40, 54 | MARKER_TRANSFORM_THRUSTER = 41, 55 | MARKER_WARP = 42, 56 | MARKER_BOXES = 43, 57 | MARKER_PIT_LANE = 44 58 | }; 59 | 60 | virtual ~IMarker() = default; 61 | 62 | #ifdef ALT_CLIENT_API 63 | virtual bool IsStreamedIn() const = 0; 64 | #endif 65 | 66 | virtual bool IsGlobal() const = 0; 67 | virtual IPlayer* GetTarget() const = 0; 68 | 69 | virtual alt::RGBA GetColor() const = 0; 70 | virtual void SetColor(alt::RGBA color) = 0; 71 | 72 | virtual bool IsVisible() const = 0; 73 | virtual void SetVisible(bool visible) = 0; 74 | 75 | virtual MarkerType GetMarkerType() const = 0; 76 | virtual void SetMarkerType(MarkerType type) = 0; 77 | 78 | virtual Position GetScale() const = 0; 79 | virtual void SetScale(Position scale) = 0; 80 | 81 | virtual Rotation GetRotation() const = 0; 82 | virtual void SetRotation(Rotation _rot) = 0; 83 | 84 | virtual Position GetDirection() const = 0; 85 | virtual void SetDirection(Position dir) = 0; 86 | 87 | virtual bool IsFaceCamera() const = 0; 88 | virtual void SetFaceCamera(bool faceCamera) = 0; 89 | 90 | virtual bool IsRotating() const = 0; 91 | virtual void SetRotating(bool rotating) = 0; 92 | 93 | virtual bool IsBobUpDown() const = 0; 94 | virtual void SetBobUpDown(bool bobUpDown) = 0; 95 | 96 | virtual uint32_t GetStreamingDistance() const = 0; 97 | }; 98 | } // namespace alt 99 | -------------------------------------------------------------------------------- /script-objects/INative.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "../IResource.h" 7 | 8 | namespace alt 9 | { 10 | class INative 11 | { 12 | protected: 13 | virtual ~INative() = default; 14 | 15 | public: 16 | enum class Type 17 | { 18 | ARG_BOOL, 19 | ARG_BOOL_PTR, 20 | ARG_INT32, 21 | ARG_INT32_PTR, 22 | ARG_UINT32, 23 | ARG_UINT32_PTR, 24 | ARG_FLOAT, 25 | ARG_FLOAT_PTR, 26 | ARG_VECTOR3, 27 | ARG_VECTOR3_PTR, 28 | ARG_STRING, 29 | ARG_STRUCT, 30 | ARG_VOID 31 | }; 32 | 33 | struct Vector3 34 | { 35 | float x, __padx, y, __pady, z, __padz; 36 | }; 37 | 38 | class Context 39 | { 40 | protected: 41 | virtual ~Context() = default; 42 | 43 | public: 44 | virtual void Reset() = 0; 45 | 46 | virtual void Push(bool val) = 0; 47 | virtual void Push(bool *val) = 0; 48 | virtual void Push(int32_t val) = 0; 49 | virtual void Push(int32_t *val) = 0; 50 | virtual void Push(uint32_t val) = 0; 51 | virtual void Push(uint32_t *val) = 0; 52 | virtual void Push(float val) = 0; 53 | virtual void Push(float *val) = 0; 54 | virtual void Push(Vector3 *val) = 0; 55 | virtual void Push(char *val) = 0; 56 | virtual void Push(void *val) = 0; 57 | 58 | virtual bool ResultBool() = 0; 59 | virtual int32_t ResultInt() = 0; 60 | virtual uint32_t ResultUint() = 0; 61 | virtual float ResultFloat() = 0; 62 | virtual Vector3 ResultVector3() = 0; 63 | virtual const char *ResultString() = 0; 64 | }; 65 | 66 | class Scope { 67 | public: 68 | virtual ~Scope() = default; 69 | }; 70 | 71 | virtual std::string GetName() const = 0; 72 | virtual Type GetRetnType() const = 0; 73 | virtual std::vector GetArgTypes() const = 0; 74 | virtual bool IsValid() const = 0; 75 | virtual bool Invoke(const std::shared_ptr& ctx) = 0; 76 | }; 77 | } // namespace alt 78 | -------------------------------------------------------------------------------- /script-objects/IRml.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace alt 7 | { 8 | class IRmlDocument; 9 | 10 | class IRmlElement : public virtual IBaseObject 11 | { 12 | public: 13 | virtual ~IRmlElement() = default; 14 | 15 | virtual bool AddClass(const std::string& name) = 0; 16 | virtual bool RemoveClass(const std::string& name) = 0; 17 | virtual bool HasClass(const std::string& name) const = 0; 18 | virtual const std::vector GetClassList() const = 0; 19 | 20 | virtual bool AddPseudoClass(const std::string& name) = 0; 21 | virtual bool RemovePseudoClass(const std::string& name) = 0; 22 | virtual bool HasPseudoClass(const std::string& name) const = 0; 23 | virtual const std::vector GetPseudoClassList() const = 0; 24 | 25 | virtual void SetOffset(IRmlElement* offsetParent, Vector2f offset, bool fixed = false) = 0; 26 | virtual Vector2f GetRelativeOffset() const = 0; 27 | virtual Vector2f GetAbsoluteOffset() const = 0; 28 | virtual float GetBaseline() const = 0; 29 | virtual float GetZIndex() const = 0; 30 | 31 | virtual bool IsPointWithinElement(Vector2f point) const = 0; 32 | 33 | virtual bool SetProperty(const std::string& name, const std::string& value) = 0; 34 | virtual bool RemoveProperty(const std::string& name) = 0; 35 | // Checks property for local element and all inherited from ancestors 36 | virtual bool HasProperty(const std::string& name) const = 0; 37 | // Only check property for local element 38 | virtual bool HasLocalProperty(const std::string& name) const = 0; 39 | virtual std::string GetProperty(const std::string& name) const = 0; 40 | virtual std::string GetLocalProperty(const std::string& name) const = 0; 41 | // Returns the relative unit (e.g. 'percent' or 'angle') as absolute value ('px' or 'rad') 42 | virtual float GetPropertyAbsoluteValue(const std::string& name) const = 0; 43 | 44 | virtual Vector2f GetContainingBlock() const = 0; 45 | 46 | virtual IRmlElement* GetFocusedElement() const = 0; 47 | 48 | virtual const std::string& GetTagName() const = 0; 49 | virtual const std::string& GetRmlID() const = 0; 50 | virtual void SetRmlID(const std::string& id) = 0; 51 | 52 | virtual bool IsOwned() const = 0; 53 | 54 | virtual void SetAttribute(const std::string& name, const std::string& value) = 0; 55 | virtual bool RemoveAttribute(const std::string& name) = 0; 56 | virtual bool HasAttribute(const std::string& name) const = 0; 57 | virtual std::string GetAttribute(const std::string& name) const = 0; 58 | virtual const std::unordered_map GetAttributes() const = 0; 59 | 60 | virtual float GetAbsoluteLeft() const = 0; 61 | virtual float GetAbsoluteTop() const = 0; 62 | virtual float GetClientLeft() const = 0; 63 | virtual float GetClientTop() const = 0; 64 | virtual float GetClientWidth() const = 0; 65 | virtual float GetClientHeight() const = 0; 66 | virtual IRmlElement* GetOffsetParent() const = 0; 67 | virtual float GetOffsetLeft() const = 0; 68 | virtual float GetOffsetTop() const = 0; 69 | virtual float GetOffsetWidth() const = 0; 70 | virtual float GetOffsetHeight() const = 0; 71 | 72 | virtual float GetScrollLeft() const = 0; 73 | virtual void SetScrollLeft(float value) = 0; 74 | virtual float GetScrollTop() const = 0; 75 | virtual void SetScrollTop(float value) = 0; 76 | virtual float GetScrollWidth() const = 0; 77 | virtual float GetScrollHeight() const = 0; 78 | 79 | virtual bool IsVisible() const = 0; 80 | 81 | virtual IRmlElement* GetParent() const = 0; 82 | virtual IRmlElement* GetClosest(const std::string& selectors) const = 0; 83 | virtual IRmlElement* GetNextSibling() const = 0; 84 | virtual IRmlElement* GetPreviousSibling() const = 0; 85 | virtual IRmlElement* GetFirstChild() const = 0; 86 | virtual IRmlElement* GetLastChild() const = 0; 87 | virtual IRmlElement* GetChild(int index) const = 0; 88 | virtual int GetChildCount() const = 0; 89 | virtual void AppendChild(IRmlElement* element) = 0; 90 | virtual void InsertBefore(IRmlElement* element, IRmlElement* adjacentElement) = 0; 91 | virtual void ReplaceChild(IRmlElement* newElement, IRmlElement* oldElement) = 0; 92 | virtual void RemoveChild(IRmlElement* element) = 0; 93 | virtual bool HasChildren() const = 0; 94 | 95 | virtual std::string GetInnerRML() const = 0; 96 | virtual void SetInnerRML(const std::string& value) = 0; 97 | 98 | virtual bool Focus() = 0; 99 | virtual void Blur() = 0; 100 | virtual void Click() = 0; 101 | virtual void ScrollIntoView(bool alignWithTop = true) = 0; 102 | 103 | virtual IRmlElement* GetElementByID(const std::string& id) const = 0; 104 | virtual const std::vector GetElementsByTagName(const std::string& tag) const = 0; 105 | virtual const std::vector GetElementsByClassName(const std::string& tag) const = 0; 106 | virtual IRmlElement* QuerySelector(const std::string& selector) const = 0; 107 | virtual const std::vector QuerySelectorAll(const std::string& selector) const = 0; 108 | 109 | virtual IRmlDocument* GetOwnerDocument() const = 0; 110 | }; 111 | 112 | class IRmlDocument : public virtual IRmlElement 113 | { 114 | public: 115 | struct CreateOptions 116 | { 117 | std::string url; 118 | std::string currentPath; 119 | bool isFullscreen { true }; 120 | Vector2i size { 0, 0 }; 121 | }; 122 | 123 | virtual ~IRmlDocument() = default; 124 | 125 | virtual void SetTitle(const std::string& title) = 0; 126 | virtual const std::string& GetTitle() const = 0; 127 | virtual const std::string& GetSourceUrl() const = 0; 128 | 129 | virtual IRmlElement* CreateElement(const std::string& name) = 0; 130 | virtual IRmlElement* CreateTextNode(const std::string& text) = 0; 131 | 132 | virtual void Hide() = 0; 133 | virtual void Show(bool isModal = false, bool focused = true) = 0; 134 | virtual bool IsVisible() const override = 0; 135 | virtual bool IsModal() const = 0; 136 | virtual bool IsFullscreen() const = 0; 137 | 138 | virtual IRmlElement* GetBody() const = 0; 139 | 140 | virtual void SetDrawOrigin(const alt::Vector3f& origin) = 0; 141 | virtual void ClearDrawOrigin() = 0; 142 | 143 | virtual void Update() = 0; 144 | }; 145 | } // namespace alt -------------------------------------------------------------------------------- /script-objects/IStatData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace alt 5 | { 6 | class IStatData 7 | { 8 | protected: 9 | virtual ~IStatData() = default; 10 | 11 | public: 12 | virtual void Reset() = 0; 13 | virtual void SetInt32Value(int32_t value) = 0; 14 | virtual void SetInt64Value(int64_t value) = 0; 15 | virtual void SetFloatValue(float value) = 0; 16 | virtual void SetBoolValue(bool value) = 0; 17 | virtual void SetUInt8Value(uint8_t value) = 0; 18 | virtual void SetUInt16Value(uint16_t value) = 0; 19 | virtual void SetUInt32Value(uint32_t value) = 0; 20 | virtual void SetUInt64Value(uint64_t value) = 0; 21 | virtual void SetStringValue(const char *value) = 0; 22 | 23 | private: 24 | virtual bool GetUnkBool() = 0; 25 | 26 | public: 27 | virtual int32_t GetInt32Value() = 0; 28 | virtual int64_t GetInt64Value() = 0; 29 | virtual float GetFloatValue() = 0; 30 | virtual bool GetBoolValue() = 0; 31 | virtual uint8_t GetUInt8Value() = 0; 32 | virtual uint16_t GetUInt16Value() = 0; 33 | virtual uint32_t GetUInt32Value() = 0; 34 | virtual uint64_t GetUInt64Value() = 0; 35 | virtual const char *GetStringValue() = 0; 36 | 37 | private: 38 | virtual bool GetUnkBool2() = 0; 39 | virtual bool GetUnkBool3() = 0; 40 | 41 | public: 42 | virtual bool IsEqual(void *ptr) = 0; 43 | 44 | private: 45 | virtual void unkFunc() = 0; 46 | 47 | public: 48 | virtual const char *GetStatType() = 0; 49 | virtual int GetSize() = 0; 50 | 51 | }; 52 | } // namespace alt 53 | -------------------------------------------------------------------------------- /script-objects/ITextLabel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "../objects/IWorldObject.h" 5 | 6 | namespace alt 7 | { 8 | class ITextLabel : public virtual IWorldObject 9 | { 10 | public: 11 | enum Alignment { 12 | ALIGN_LEFT, 13 | ALIGN_RIGHT, 14 | ALIGN_CENTER, 15 | ALIGN_JUSTIFY 16 | }; 17 | 18 | virtual ~ITextLabel() = default; 19 | 20 | #ifdef ALT_CLIENT_API 21 | virtual bool IsStreamedIn() const = 0; 22 | #endif 23 | 24 | virtual bool IsGlobal() const = 0; 25 | virtual IPlayer* GetTarget() const = 0; 26 | 27 | virtual alt::RGBA GetColor() const = 0; 28 | virtual void SetColor(alt::RGBA color) = 0; 29 | 30 | virtual alt::RGBA GetOutlineColor() const = 0; 31 | virtual void SetOutlineColor(alt::RGBA color) = 0; 32 | 33 | virtual float GetOutlineWidth() const = 0; 34 | virtual void SetOutlineWidth(float width) = 0; 35 | 36 | virtual float GetFontSize() const = 0; 37 | virtual void SetFontSize(float size) = 0; 38 | 39 | virtual Alignment GetAlign() const = 0; 40 | virtual void SetAlign(Alignment align) = 0; 41 | 42 | virtual std::string GetText() const = 0; 43 | virtual void SetText(const std::string& text) = 0; 44 | 45 | virtual std::string GetFont() const = 0; 46 | virtual void SetFont(const std::string& font) = 0; 47 | 48 | virtual bool IsVisible() const = 0; 49 | virtual void SetVisible(bool visible) = 0; 50 | 51 | virtual float GetScale() const = 0; 52 | virtual void SetScale(float scale) = 0; 53 | 54 | virtual Rotation GetRotation() const = 0; 55 | virtual void SetRotation(Rotation _rot) = 0; 56 | 57 | virtual void SetFaceCamera(bool state) = 0; 58 | virtual bool IsFacingCamera() const = 0; 59 | 60 | virtual uint32_t GetStreamingDistance() const = 0; 61 | }; 62 | } // namespace alt 63 | -------------------------------------------------------------------------------- /script-objects/IVirtualEntity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../types/MValue.h" 9 | 10 | #include "../objects/IWorldObject.h" 11 | #include "../script-objects/IVirtualEntityGroup.h" 12 | 13 | namespace alt 14 | { 15 | class IVirtualEntity : public virtual IWorldObject 16 | { 17 | public: 18 | virtual ~IVirtualEntity() = default; 19 | 20 | virtual IVirtualEntityGroup* GetGroup() const = 0; 21 | 22 | virtual bool HasStreamSyncedMetaData(const std::string& key) const = 0; 23 | virtual MValueConst GetStreamSyncedMetaData(const std::string& key) const = 0; 24 | virtual std::vector GetStreamSyncedMetaDataKeys() const = 0; 25 | 26 | virtual uint32_t GetStreamingDistance() const = 0; 27 | 28 | virtual void SetVisible(bool toggle) = 0; 29 | virtual bool IsVisible() const = 0; 30 | #ifdef ALT_CLIENT_API 31 | virtual bool IsStreamedIn() const = 0; 32 | #endif 33 | 34 | #ifdef ALT_SERVER_API 35 | virtual void SetStreamSyncedMetaData(const std::string& key, MValue val) = 0; 36 | virtual void SetMultipleStreamSyncedMetaData(const std::unordered_map& values) = 0; 37 | virtual void DeleteStreamSyncedMetaData(const std::string& key) = 0; 38 | #endif 39 | }; 40 | } // namespace alt 41 | -------------------------------------------------------------------------------- /script-objects/IVirtualEntityGroup.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../objects/IBaseObject.h" 6 | 7 | namespace alt 8 | { 9 | class IVirtualEntityGroup: public virtual IBaseObject 10 | { 11 | public: 12 | virtual ~IVirtualEntityGroup() = default; 13 | 14 | virtual uint32_t GetMaxEntitiesInStream() const = 0; 15 | }; 16 | } // namespace alt 17 | -------------------------------------------------------------------------------- /script-objects/IVoiceChannel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "../objects/IBaseObject.h" 6 | 7 | namespace alt 8 | { 9 | class IPlayer; 10 | 11 | class IVoiceChannel : public virtual IBaseObject 12 | { 13 | public: 14 | virtual ~IVoiceChannel() = default; 15 | 16 | virtual bool IsSpatial() const = 0; 17 | virtual float GetMaxDistance() const = 0; 18 | 19 | virtual bool HasPlayer(IPlayer* player) const = 0; 20 | virtual void AddPlayer(IPlayer* player) = 0; 21 | virtual void RemovePlayer(IPlayer* player) = 0; 22 | 23 | virtual bool IsPlayerMuted(IPlayer* player) const = 0; 24 | virtual void MutePlayer(IPlayer* player) = 0; 25 | virtual void UnmutePlayer(IPlayer* player) = 0; 26 | 27 | virtual const std::vector GetPlayers() const = 0; 28 | virtual size_t GetPlayerCount() const = 0; 29 | 30 | virtual uint32_t GetFilter() const = 0; 31 | virtual void SetFilter(uint32_t filter) = 0; 32 | 33 | virtual int32_t GetPriority() const = 0; 34 | virtual void SetPriority(int32_t priority) = 0; 35 | }; 36 | } // namespace alt 37 | -------------------------------------------------------------------------------- /script-objects/IWeaponData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace alt 4 | { 5 | class IWeaponData 6 | { 7 | protected: 8 | virtual ~IWeaponData() = default; 9 | 10 | public: 11 | virtual uint32_t GetNameHash() const = 0; 12 | virtual uint32_t GetModelHash() const = 0; 13 | virtual float GetRecoilShakeAmplitude() const = 0; 14 | virtual float GetRecoilAccuracyMax() const = 0; 15 | virtual float GetRecoilAccuracyToAllowHeadshotPlayer() const = 0; 16 | virtual float GetRecoilRecoveryRate() const = 0; 17 | virtual float GetAnimReloadRate() const = 0; 18 | virtual float GetVehicleReloadTime() const = 0; 19 | virtual float GetLockOnRange() const = 0; 20 | virtual float GetAccuracySpread() const = 0; 21 | virtual float GetRange() const = 0; 22 | virtual float GetDamage() const = 0; 23 | virtual uint32_t GetClipSize() const = 0; 24 | virtual float GetTimeBetweenShots() const = 0; 25 | virtual float GetHeadshotDamageModifier() const = 0; 26 | virtual float GetPlayerDamageModifier() const = 0; 27 | 28 | virtual void SetRecoilShakeAmplitude(float val) = 0; 29 | virtual void SetRecoilAccuracyMax(float val) = 0; 30 | virtual void SetRecoilAccuracyToAllowHeadshotPlayer(float val) = 0; 31 | virtual void SetRecoilRecoveryRate(float val) = 0; 32 | virtual void SetAnimReloadRate(float val) = 0; 33 | virtual void SetVehicleReloadTime(float val) = 0; 34 | virtual void SetLockOnRange(float val) = 0; 35 | virtual void SetAccuracySpread(float val) = 0; 36 | virtual void SetRange(float val) = 0; 37 | virtual void SetDamage(float val) = 0; 38 | virtual void SetHeadshotDamageModifier(float val) = 0; 39 | virtual void SetPlayerDamageModifier(float val) = 0; 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /script-objects/IWebSocketClient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../objects/IBaseObject.h" 4 | 5 | namespace alt 6 | { 7 | class IWebSocketClient : public virtual IBaseObject 8 | { 9 | public: 10 | virtual ~IWebSocketClient() = default; 11 | 12 | virtual const std::string& GetUrl() const = 0; 13 | virtual void SetUrl(const std::string& _url) = 0; 14 | 15 | virtual void AddSubProtocol(const std::string& protocol) = 0; 16 | virtual std::vector GetSubProtocols() const = 0; 17 | 18 | virtual void SetExtraHeader(const std::string& name, const std::string& value) = 0; 19 | virtual alt::MValueDict GetExtraHeaders() const = 0; 20 | 21 | virtual uint8_t GetReadyState() const = 0; 22 | 23 | virtual bool IsAutoReconnectEnabled() const = 0; 24 | virtual void SetAutoReconnectEnabled(bool toggle) = 0; 25 | 26 | virtual bool IsPerMessageDeflateEnabled() const = 0; 27 | virtual void SetPerMessageDeflateEnabled(bool toggle) = 0; 28 | 29 | virtual void Start() = 0; 30 | virtual void Stop() = 0; 31 | virtual bool Send(const std::string& message) = 0; 32 | virtual bool SendBinary(const std::string& message) = 0; 33 | 34 | virtual void SetPingInterval(uint16_t seconds) = 0; 35 | virtual uint16_t GetPingInterval() const = 0; 36 | }; 37 | } // namespace alt 38 | -------------------------------------------------------------------------------- /script-objects/IWebView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "../objects/IBaseObject.h" 5 | #include "../types/WebView.h" 6 | 7 | namespace alt 8 | { 9 | class IAudioOutput; 10 | 11 | class IWebView : public virtual IBaseObject 12 | { 13 | public: 14 | virtual ~IWebView() = default; 15 | virtual void Trigger(const std::string& eventname, const alt::MValueArgs &args) = 0; 16 | virtual void Focus() = 0; 17 | virtual void Unfocus() = 0; 18 | virtual bool IsFocused() const = 0; 19 | virtual const std::string& GetUrl() const = 0; 20 | virtual void SetUrl(const std::string& url) = 0; 21 | virtual bool IsVisible() const = 0; 22 | virtual void SetVisible(bool visible) = 0; 23 | virtual bool IsOverlay() const = 0; 24 | virtual bool IsLoaded() const = 0; 25 | virtual bool IsReady() const = 0; 26 | virtual void SetExtraHeader(const std::string& name, const std::string& value) = 0; 27 | virtual void SetCookie(const WebViewCookie& cookie) = 0; 28 | virtual void SetZoomLevel(double value) = 0; 29 | virtual Vector2i GetSize() const = 0; 30 | virtual void SetSize(Vector2i size) = 0; 31 | virtual Vector2i GetPosition() const = 0; 32 | virtual void SetPosition(Vector2i pos) = 0; 33 | virtual void Reload(bool ignoreCache) = 0; 34 | 35 | virtual void AddOutput(IAudioOutput* output) = 0; 36 | virtual void RemoveOutput(IAudioOutput* output) = 0; 37 | virtual MValueList GetOutputs() = 0; 38 | }; 39 | } // namespace alt 40 | -------------------------------------------------------------------------------- /types/AABB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../deps/alt-math/alt-math.h" 3 | 4 | namespace alt 5 | { 6 | struct AABB 7 | { 8 | alt::Position min; 9 | alt::Position max; 10 | }; 11 | } // namespace alt 12 | -------------------------------------------------------------------------------- /types/AmmoFlags.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace alt 4 | { 5 | struct AmmoFlags 6 | { 7 | bool infiniteAmmo : 1; 8 | bool addSmokeOnExplosion : 1; 9 | bool fuse : 1; 10 | bool fixedAfterExplosion : 1; 11 | }; 12 | } // namespace alt 13 | -------------------------------------------------------------------------------- /types/AmmoSpecialType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace alt 6 | { 7 | enum class AmmoSpecialType : uint32_t 8 | { 9 | NONE, 10 | ARMOR_PIERCING, 11 | EXPLOSIVE, 12 | FULL_METAL_JACKET, 13 | HOLLOW_POINT, 14 | INCENDIARY, 15 | TRACER 16 | }; 17 | } // namespace alt 18 | -------------------------------------------------------------------------------- /types/Benefit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace alt 6 | { 7 | enum class Benefit : uint8_t 8 | { 9 | NONE, 10 | CLOUD_AUTH 11 | }; 12 | } // namespace alt 13 | -------------------------------------------------------------------------------- /types/BoneInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace alt 6 | { 7 | struct BoneInfo 8 | { 9 | uint16_t id; 10 | uint16_t index; 11 | std::string name; 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /types/Cloth.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace alt 7 | { 8 | struct Cloth 9 | { 10 | uint16_t drawableId = 0; 11 | uint8_t textureId = 0; 12 | uint8_t paletteId = 0; 13 | 14 | Cloth() = default; 15 | 16 | Cloth(uint16_t _drawableId, uint8_t _textureId, uint8_t _paletteId) : 17 | drawableId(_drawableId), textureId(_textureId), paletteId(_paletteId) { } 18 | 19 | friend std::ostream &operator<<(std::ostream &stream, const Cloth &cloth) 20 | { 21 | stream << "Cloth{ " << (int) cloth.drawableId << ", " << (int) cloth.textureId << ", " 22 | << (int) cloth.paletteId << " }"; 23 | return stream; 24 | } 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /types/CloudAuthResult.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace alt 6 | { 7 | enum class CloudAuthResult : uint8_t 8 | { 9 | SUCCESS, 10 | NO_BENEFIT, 11 | VERIFY_FAILED, 12 | }; 13 | } // namespace alt 14 | -------------------------------------------------------------------------------- /types/ConfigError.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace alt 7 | { 8 | struct ConfigError 9 | { 10 | std::string error; 11 | uint64_t position; 12 | uint64_t line; 13 | uint64_t column; 14 | 15 | ConfigError(std::string _error, uint64_t _position, uint64_t _line, uint64_t _column) : 16 | error(_error), position(_position), line(_line), column(_column) { } 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /types/Decoration.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace alt 6 | { 7 | struct CDecoration 8 | { 9 | public: 10 | uint32_t collection; 11 | uint32_t overlay; 12 | uint8_t count; 13 | 14 | bool operator==(CDecoration other) const 15 | { 16 | return collection == other.collection && overlay == other.overlay && count == other.count; 17 | } 18 | }; 19 | } -------------------------------------------------------------------------------- /types/DlcCloth.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace alt 7 | { 8 | struct DlcCloth 9 | { 10 | uint32_t dlc = 0; 11 | uint16_t drawableId = 0; 12 | uint8_t textureId = 0; 13 | uint8_t paletteId = 0; 14 | 15 | DlcCloth() = default; 16 | 17 | DlcCloth(uint32_t _dlc, uint16_t _drawableId, uint8_t _textureId, uint8_t _paletteId) : 18 | dlc(_dlc), drawableId(_drawableId), textureId(_textureId), paletteId(_paletteId) { } 19 | 20 | friend std::ostream &operator<<(std::ostream &stream, const DlcCloth &cloth) 21 | { 22 | stream << "DlcCloth{ "<< (int)cloth.dlc << (int) cloth.drawableId << ", " << (int) cloth.textureId << ", " 23 | << (int) cloth.paletteId << " }"; 24 | return stream; 25 | } 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /types/DlcProp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace alt 7 | { 8 | struct DlcProp 9 | { 10 | uint32_t dlc = 0; 11 | uint8_t drawableId = 0; 12 | uint8_t textureId = 0; 13 | 14 | DlcProp() = default; 15 | 16 | DlcProp(uint32_t _dlc, uint8_t _drawableId, uint8_t _textureId) : 17 | dlc(_dlc), drawableId(_drawableId), textureId(_textureId) { } 18 | 19 | friend std::ostream &operator<<(std::ostream &stream, const DlcProp &prop) 20 | { 21 | stream << "DlcProp{ "<< (int)prop.dlc << (int)prop.drawableId << ", " << (int)prop.textureId << " }"; 22 | return stream; 23 | } 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /types/Expected.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace alt 4 | { 5 | template 6 | struct Expected 7 | { 8 | Value value; 9 | Error error; 10 | bool success; 11 | 12 | Expected(Value _value, Error _error, bool _success) : 13 | value(_value), error(_error), success(_success) { } 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /types/HeadBlendData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace alt 7 | { 8 | struct HeadBlendData 9 | { 10 | uint32_t shapeFirstID = 0; 11 | uint32_t shapeSecondID = 0; 12 | uint32_t shapeThirdID = 0; 13 | uint32_t skinFirstID = 0; 14 | uint32_t skinSecondID = 0; 15 | uint32_t skinThirdID = 0; 16 | float shapeMix = 0.f; 17 | float skinMix = 0.f; 18 | float thirdMix = 0.f; 19 | 20 | HeadBlendData() = default; 21 | 22 | HeadBlendData(uint32_t _shapeFirstID, uint32_t _shapeSecondID, uint32_t _shapeThirdID, 23 | uint32_t _skinFirstID, uint32_t _skinSecondID, uint32_t _skinThirdID, 24 | float _shapeMix, float _skinMix, float _thirdMix) : 25 | shapeFirstID(_shapeFirstID), shapeSecondID(_shapeSecondID), shapeThirdID(_shapeThirdID), 26 | skinFirstID(_skinFirstID), skinSecondID(_skinSecondID), skinThirdID(_skinThirdID), 27 | shapeMix(_shapeMix) , skinMix(_skinMix) , thirdMix(_thirdMix) { } 28 | 29 | friend std::ostream &operator<<(std::ostream &stream, const HeadBlendData &headBlendData) 30 | { 31 | stream << "HeadBlendData{ "<< headBlendData.shapeFirstID << headBlendData.shapeSecondID << ", " << headBlendData.shapeThirdID << ", " 32 | << headBlendData.skinFirstID << ", " << headBlendData.skinSecondID << ", " << headBlendData.skinThirdID 33 | << ", " << headBlendData.shapeMix << ", " << headBlendData.skinMix << ", " << headBlendData.thirdMix << " }"; 34 | return stream; 35 | } 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /types/HeadOverlay.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace alt 7 | { 8 | struct HeadOverlay 9 | { 10 | uint8_t index = 0; 11 | float opacity = 0; 12 | uint8_t colorType; 13 | uint8_t colorIndex = 0; 14 | uint8_t secondColorIndex = 0; 15 | 16 | HeadOverlay() = default; 17 | 18 | HeadOverlay(uint8_t _index, float _opacity, uint8_t _colorType, uint8_t _colorIndex, uint8_t _secondColorIndex) : 19 | index(_index), opacity(_opacity), colorType(_colorType), colorIndex(_colorIndex), secondColorIndex(_secondColorIndex){ } 20 | 21 | friend std::ostream &operator<<(std::ostream &stream, const HeadOverlay &headOverlay) 22 | { 23 | stream << "HeadOverlay{ "<< headOverlay.index << headOverlay.opacity << ", " << headOverlay.colorType << ", " 24 | << headOverlay.colorIndex << headOverlay.secondColorIndex << ", " << " }"; 25 | return stream; 26 | } 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /types/KeyState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace alt 4 | { 5 | struct KeyState 6 | { 7 | KeyState(bool down, bool toggled) 8 | : down(down), toggled(toggled) 9 | {} 10 | 11 | bool IsDown() { return down; } 12 | bool IsToggled() { return toggled; } 13 | 14 | private: 15 | bool down, toggled; 16 | }; 17 | } // namespace alt 18 | -------------------------------------------------------------------------------- /types/MValue.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "../types/Types.h" 8 | #include "../Ref.h" 9 | #include "../types/RGBA.h" 10 | #include "../deps/alt-math/alt-math.h" 11 | 12 | namespace alt 13 | { 14 | class IBaseObject; 15 | 16 | class IMValue; 17 | class IMValueNone; 18 | class IMValueNil; 19 | class IMValueBool; 20 | class IMValueInt; 21 | class IMValueUInt; 22 | class IMValueDouble; 23 | class IMValueString; 24 | class IMValueList; 25 | class IMValueDict; 26 | class IMValueBaseObject; 27 | class IMValueFunction; 28 | class IMValueVector2; 29 | class IMValueVector3; 30 | class IMValueRGBA; 31 | class IMValueByteArray; 32 | 33 | using MValue = std::shared_ptr; 34 | using MValueNone = std::shared_ptr; 35 | using MValueNil = std::shared_ptr; 36 | using MValueBool = std::shared_ptr; 37 | using MValueInt = std::shared_ptr; 38 | using MValueUInt = std::shared_ptr; 39 | using MValueDouble = std::shared_ptr; 40 | using MValueString = std::shared_ptr; 41 | using MValueList = std::shared_ptr; 42 | using MValueDict = std::shared_ptr; 43 | using MValueBaseObject = std::shared_ptr; 44 | using MValueFunction = std::shared_ptr; 45 | using MValueVector2 = std::shared_ptr; 46 | using MValueVector3 = std::shared_ptr; 47 | using MValueRGBA = std::shared_ptr; 48 | using MValueByteArray = std::shared_ptr; 49 | 50 | using MValueConst = std::shared_ptr; 51 | using MValueNoneConst = std::shared_ptr; 52 | using MValueNilConst = std::shared_ptr; 53 | using MValueBoolConst = std::shared_ptr; 54 | using MValueIntConst = std::shared_ptr; 55 | using MValueUIntConst = std::shared_ptr; 56 | using MValueDoubleConst = std::shared_ptr; 57 | using MValueStringConst = std::shared_ptr; 58 | using MValueListConst = std::shared_ptr; 59 | using MValueDictConst = std::shared_ptr; 60 | using MValueBaseObjectConst = std::shared_ptr; 61 | using MValueFunctionConst = std::shared_ptr; 62 | using MValueVector2Const = std::shared_ptr; 63 | using MValueVector3Const = std::shared_ptr; 64 | using MValueRGBAConst = std::shared_ptr; 65 | using MValueByteArrayConst = std::shared_ptr; 66 | 67 | using MValueArgs = std::vector; 68 | 69 | class IMValue : public std::enable_shared_from_this 70 | { 71 | public: 72 | enum class Type : uint8_t 73 | { 74 | NONE, 75 | NIL, 76 | BOOL, 77 | INT, 78 | UINT, 79 | DOUBLE, 80 | STRING, 81 | LIST, 82 | DICT, 83 | BASE_OBJECT, 84 | FUNCTION, 85 | VECTOR3, 86 | RGBA, 87 | BYTE_ARRAY, 88 | VECTOR2 89 | }; 90 | 91 | virtual ~IMValue() = default; 92 | 93 | virtual Type GetType() const = 0; 94 | virtual std::string ToString() const = 0; 95 | virtual double ToNumber() const = 0; 96 | virtual MValue Clone() const = 0; 97 | virtual bool Equals(MValueConst other, bool deep) const = 0; 98 | }; 99 | 100 | // Represents lack of value 101 | class IMValueNone : public IMValue 102 | { 103 | }; 104 | 105 | // Represents null value 106 | class IMValueNil : public IMValue 107 | { 108 | }; 109 | 110 | class IMValueBool : public IMValue 111 | { 112 | public: 113 | virtual bool Value() const = 0; 114 | }; 115 | 116 | class IMValueInt : public IMValue 117 | { 118 | public: 119 | virtual int64_t Value() const = 0; 120 | }; 121 | 122 | class IMValueUInt : public IMValue 123 | { 124 | public: 125 | virtual uint64_t Value() const = 0; 126 | }; 127 | 128 | class IMValueDouble : public IMValue 129 | { 130 | public: 131 | virtual double Value() const = 0; 132 | }; 133 | 134 | class IMValueString : public IMValue 135 | { 136 | public: 137 | virtual const std::string& Value() const = 0; 138 | }; 139 | 140 | class IMValueList : public IMValue 141 | { 142 | public: 143 | virtual Size GetSize() const = 0; 144 | virtual MValue Get(Size i) = 0; 145 | virtual MValueConst Get(Size i) const = 0; 146 | 147 | // Transfers ownership of MValue (You should not have any more refs to this copy) 148 | virtual void Set(Size i, MValue val) = 0; 149 | virtual void Push(MValue val) = 0; 150 | 151 | // Will clone an MValueConst 152 | virtual void SetConst(Size i, MValueConst val) = 0; 153 | virtual void PushConst(MValueConst val) = 0; 154 | }; 155 | 156 | class IMValueDict : public IMValue 157 | { 158 | public: 159 | virtual Size GetSize() const = 0; 160 | virtual MValue Get(const std::string& key) = 0; 161 | virtual MValue Get(const char* key) = 0; 162 | virtual MValueConst Get(const std::string& key) const = 0; 163 | virtual MValueConst Get(const char* key) const = 0; 164 | virtual bool Has(const std::string& key) const = 0; 165 | virtual bool Has(const char* key) const = 0; 166 | 167 | // Transfers ownership of MValue (You should not have any more refs to this copy) 168 | virtual void Set(const std::string& key, MValue val) = 0; 169 | virtual void Set(const char* key, MValue val) = 0; 170 | 171 | // Will clone an MValueConst 172 | virtual void SetConst(const std::string& key, MValueConst val) = 0; 173 | virtual void SetConst(const char* key, MValueConst val) = 0; 174 | 175 | virtual void Delete(const std::string& key) = 0; 176 | virtual void Delete(const char* key) = 0; 177 | 178 | virtual std::unordered_map::const_iterator Begin() const = 0; 179 | virtual std::unordered_map::const_iterator End() const = 0; 180 | }; 181 | 182 | class IMValueBaseObject : public IMValue 183 | { 184 | public: 185 | virtual IBaseObject* RawValue() const = 0; 186 | virtual std::shared_ptr Value() const = 0; 187 | }; 188 | 189 | class IMValueFunction : public IMValue 190 | { 191 | public: 192 | class Impl 193 | { 194 | public: 195 | virtual MValue Call(MValueArgs args) const = 0; 196 | 197 | virtual void AddRef() 198 | { 199 | ++refCount; 200 | } 201 | 202 | virtual void RemoveRef() 203 | { 204 | if(--refCount == 0) delete this; 205 | } 206 | 207 | protected: 208 | ~Impl() = default; 209 | 210 | private: 211 | Size refCount = 0; 212 | }; 213 | 214 | virtual MValue Call(MValueArgs args) const = 0; 215 | }; 216 | 217 | class IMValueVector2 : public IMValue 218 | { 219 | public: 220 | virtual Vector2f Value() const = 0; 221 | }; 222 | 223 | class IMValueVector3 : public IMValue 224 | { 225 | public: 226 | virtual Vector3f Value() const = 0; 227 | }; 228 | 229 | class IMValueRGBA : public IMValue 230 | { 231 | public: 232 | virtual RGBA Value() const = 0; 233 | }; 234 | 235 | class IMValueByteArray : public IMValue 236 | { 237 | public: 238 | virtual Size GetSize() const = 0; 239 | virtual const uint8_t* GetData() const = 0; 240 | virtual uint8_t* GetData() = 0; 241 | }; 242 | } // namespace alt 243 | -------------------------------------------------------------------------------- /types/Metric.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace alt 7 | { 8 | struct Metric 9 | { 10 | enum Type: uint8_t 11 | { 12 | METRIC_TYPE_GAUGE, 13 | METRIC_TYPE_COUNTER, 14 | METRIC_TYPE_SIZE 15 | }; 16 | 17 | std::string name {}; 18 | uint64_t value = 0; 19 | bool exists = false; 20 | 21 | void SetValue(uint64_t _value) 22 | { 23 | value = _value; 24 | } 25 | 26 | void Add(uint64_t _value) 27 | { 28 | value += _value; 29 | } 30 | 31 | void Inc() 32 | { 33 | ++value; 34 | } 35 | 36 | void Begin() 37 | { 38 | lastBegin = Time(); 39 | } 40 | 41 | // Deprecated old behavior, remove in future 42 | void End() 43 | { 44 | value = Time() - lastBegin; 45 | } 46 | 47 | void End2() 48 | { 49 | if (lastBegin == 0) 50 | return; // Warn? 51 | 52 | Add(Time() - lastBegin); 53 | lastBegin = 0; 54 | } 55 | 56 | void Destroy() 57 | { 58 | exists = false; 59 | } 60 | 61 | Metric() = default; 62 | explicit Metric(std::string_view _name): name(_name), value(0), exists(false) {} 63 | 64 | private: 65 | uint64_t lastBegin = 0; 66 | 67 | static inline uint64_t Time() 68 | { 69 | static uint64_t start = std::chrono::steady_clock::now().time_since_epoch().count(); 70 | return std::chrono::steady_clock::now().time_since_epoch().count() - start; 71 | } 72 | }; 73 | } 74 | -------------------------------------------------------------------------------- /types/PedModelInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "BoneInfo.h" 7 | 8 | namespace alt 9 | { 10 | struct PedModelInfo 11 | { 12 | bool invalid = false; 13 | 14 | uint32_t hash; 15 | std::string name; 16 | std::string type; 17 | std::string dlcName; // Is not yet parsed for custom peds 18 | std::string defaultUnarmedWeapon; 19 | std::string movementClipSet; 20 | std::vector bones; 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /types/Permissions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace alt 6 | { 7 | // DO NOT CHANGE ORDER, ADD IN DECSENDING FASHION (before All) 8 | enum class Permission : uint8_t 9 | { 10 | NONE, 11 | SCREEN_CAPTURE, 12 | WEBRTC, 13 | CLIPBOARD_ACCESS, 14 | EXTENDED_VOICE_API, 15 | All 16 | }; 17 | static Permission GetPermissionFromString(const std::string& val) 18 | { 19 | if(val == "Screen Capture") return Permission::SCREEN_CAPTURE; 20 | if(val == "WebRTC") return Permission::WEBRTC; 21 | if(val == "Clipboard Access") return Permission::CLIPBOARD_ACCESS; 22 | if(val == "Extended Voice API") return Permission::EXTENDED_VOICE_API; 23 | return Permission::NONE; 24 | } 25 | static std::string GetStringFromPermission(Permission val) 26 | { 27 | if(val == Permission::SCREEN_CAPTURE) return "Screen Capture"; 28 | if(val == Permission::WEBRTC) return "WebRTC"; 29 | if(val == Permission::CLIPBOARD_ACCESS) return "Clipboard Access"; 30 | if(val == Permission::EXTENDED_VOICE_API) return "Extended Voice API"; 31 | return "None"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /types/Prop.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace alt 7 | { 8 | struct Prop 9 | { 10 | uint16_t drawableId = 0; 11 | uint8_t textureId = 0; 12 | 13 | Prop() = default; 14 | 15 | Prop(uint16_t _drawableId, uint8_t _textureId) : 16 | drawableId(_drawableId), textureId(_textureId) { } 17 | 18 | friend std::ostream &operator<<(std::ostream &stream, const Prop &prop) 19 | { 20 | stream << "Prop{ " << (int)prop.drawableId << ", " << (int)prop.textureId << " }"; 21 | return stream; 22 | } 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /types/RGBA.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace alt 7 | { 8 | struct RGBA 9 | { 10 | uint8_t r = 0; 11 | uint8_t g = 0; 12 | uint8_t b = 0; 13 | uint8_t a = 0; 14 | 15 | RGBA() = default; 16 | 17 | RGBA(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) : 18 | r(_r), g(_g), b(_b), a(_a) { } 19 | 20 | friend std::ostream& operator<<(std::ostream& stream, const RGBA& rgba) 21 | { 22 | stream << "RGBA{ " << (int)rgba.r << ", " << (int)rgba.g << ", " << (int)rgba.b << ", " << (int)rgba.a << " }"; 23 | return stream; 24 | } 25 | 26 | //also works as fromBGRA 27 | RGBA toBGRA() const 28 | { 29 | return RGBA(b, g, r, a); 30 | } 31 | 32 | RGBA toARGB() const 33 | { 34 | return RGBA(a ,r, g, b); 35 | } 36 | 37 | uint32_t toInt() const 38 | { 39 | uint32_t RGB = (r << 24); 40 | RGB = RGB | (g << 16); 41 | RGB = RGB | (b << 8); 42 | RGB = RGB | (a); 43 | return RGB; 44 | } 45 | }; 46 | } 47 | -------------------------------------------------------------------------------- /types/SyncInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace alt 4 | { 5 | struct SyncInfo 6 | { 7 | uint8_t active; 8 | uint32_t receivedTick; 9 | uint32_t fullyReceivedTick; 10 | uint32_t sendTick; 11 | uint32_t ackedSendTick; 12 | uint16_t propertyCount; 13 | uint8_t componentCount; 14 | // array size of propertyCount 15 | uint32_t* propertiesUpdateTick; 16 | // array size of componentCount - 1, if (componentCount == 0) => nullptr 17 | uint32_t* componentPropertyIndex; 18 | }; 19 | } // namespace alt 20 | -------------------------------------------------------------------------------- /types/Types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace alt 6 | { 7 | using Size = uint64_t; 8 | } -------------------------------------------------------------------------------- /types/VehicleBadgePosition.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "../deps/alt-math/alt-math.h" 8 | 9 | namespace alt 10 | { 11 | struct VehicleBadgePosition 12 | { 13 | bool active { false }; 14 | uint8_t alpha { 255 }; 15 | float size { 1.f }; 16 | int16_t boneIndex { 0 }; 17 | Vector3f offset { 0, 0, 0 }; 18 | Vector3f direction { 0, 0, 0 }; 19 | Vector3f side { 0, 0, 0 }; 20 | 21 | VehicleBadgePosition() = default; 22 | 23 | VehicleBadgePosition(uint8_t alpha, float size, int16_t boneIndex, const Vector3f& offset, 24 | const Vector3f& direction, const Vector3f& side) 25 | : alpha(alpha), 26 | size(size), 27 | boneIndex(boneIndex), 28 | offset(offset), 29 | direction(direction), 30 | side(side) 31 | { 32 | } 33 | 34 | friend std::ostream& operator<<(std::ostream& os, const VehicleBadgePosition& obj) 35 | { 36 | return os 37 | << "alpha: " << obj.alpha 38 | << " size: " << obj.size 39 | << " boneIndex: " << obj.boneIndex 40 | << " offset: " << obj.offset 41 | << " direction: " << obj.direction 42 | << " side: " << obj.side; 43 | } 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /types/VehicleModelInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "BoneInfo.h" 6 | 7 | namespace alt 8 | { 9 | struct VehicleModelInfo 10 | { 11 | enum class Type : uint8_t 12 | { 13 | INVALID, 14 | PED, 15 | AUTOMOBILE, 16 | PLANE, 17 | TRAILER, 18 | QUAD_BIKE, 19 | SUBMARINE_CAR, 20 | AMPHIBIOUS_AUTOMOBILE, 21 | AMPHIBIOUS_QUAD_BIKE, 22 | HELI, 23 | BLIMP, 24 | AUTOGYRO, 25 | BIKE, 26 | BMX, 27 | BOAT, 28 | TRAIN, 29 | SUBMARINE, 30 | OBJECT 31 | }; 32 | 33 | bool invalid = false; 34 | 35 | uint32_t modelHash; 36 | std::string title; 37 | Type modelType; 38 | uint8_t wheelsCount; 39 | bool hasArmoredWindows; 40 | uint8_t primaryColor; 41 | uint8_t secondaryColor; 42 | uint8_t pearlColor; 43 | uint8_t wheelsColor; 44 | uint8_t interiorColor; 45 | uint8_t dashboardColor; 46 | 47 | uint16_t modkits[2]; 48 | uint16_t extras; 49 | uint16_t defaultExtras; 50 | bool hasAutoAttachTrailer; 51 | 52 | std::vector bones; 53 | 54 | bool canAttachCars; 55 | uint32_t handlingNameHash; 56 | 57 | bool DoesExtraExist(uint8_t extraId) const 58 | { 59 | return ((!!((extras) & (1ULL << (extraId))))); 60 | } 61 | 62 | bool DoesExtraDefault(uint8_t extraId) const 63 | { 64 | return ((!!((defaultExtras) & (1ULL << (extraId))))); 65 | } 66 | }; 67 | } 68 | -------------------------------------------------------------------------------- /types/VoiceChat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace alt 7 | { 8 | struct SoundDeviceInfo 9 | { 10 | std::optional uid; 11 | std::string name; 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /types/Weapon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace alt 8 | { 9 | struct Weapon 10 | { 11 | uint32_t hash = 0; 12 | uint8_t tintIndex = 0; 13 | std::unordered_set components {}; 14 | 15 | Weapon() = default; 16 | 17 | Weapon(uint32_t _hash, uint8_t _tintIndex, std::unordered_set _components) : 18 | hash(_hash), tintIndex(_tintIndex), components(_components) { } 19 | 20 | friend std::ostream &operator<<(std::ostream &stream, const Weapon& weapon) 21 | { 22 | stream << "Weapon{ " << weapon.hash<< ", " << weapon.tintIndex << ", " << weapon.components.size() << " }"; 23 | return stream; 24 | } 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /types/WeaponModelInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace alt 7 | { 8 | struct WeaponModelInfo 9 | { 10 | bool invalid = false; 11 | uint32_t hash; 12 | uint32_t modelHash; 13 | uint32_t ammoTypeHash; 14 | std::string name; 15 | std::string model; 16 | std::string ammoType; 17 | // Above should be stored in a separate WeaponAmmoInfo, not parsed for custom weapons 18 | std::string ammoModelName; 19 | uint32_t ammoModelHash; 20 | int32_t defaultMaxAmmoMp; 21 | int32_t skillAbove50MaxAmmoMp; 22 | int32_t maxSkillMaxAmmoMp; 23 | int32_t bonusMaxAmmoMp; 24 | std::string damageType; 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /types/WebView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace alt 7 | { 8 | struct WebViewCookie 9 | { 10 | std::string url; 11 | std::string name; 12 | std::string value; 13 | 14 | bool httpOnly; 15 | bool secure; 16 | std::optional expires; 17 | std::optional domain; 18 | std::optional path; 19 | std::optional sameSite; 20 | std::optional priority; 21 | }; 22 | 23 | using WebViewHeaders = std::unordered_map; 24 | } 25 | -------------------------------------------------------------------------------- /version/get-version.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | pushd .. 4 | FOR /F %%I IN ('git rev-parse --short HEAD') DO @SET "COMMIT_HASH=%%I" 5 | popd 6 | 7 | ( 8 | echo #pragma once 9 | echo. 10 | echo #define ALT_SDK_VERSION "%COMMIT_HASH%" 11 | ) > version.h.tmp 12 | 13 | if not exist version.h goto rename 14 | 15 | fc version.h version.h.tmp > nul 16 | if errorlevel 1 goto remove 17 | 18 | del version.h.tmp 19 | goto end 20 | 21 | :remove 22 | del version.h 23 | :rename 24 | move version.h.tmp version.h 25 | 26 | :end 27 | -------------------------------------------------------------------------------- /version/get-version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pushd .. > /dev/null 4 | COMMIT_HASH=$(git rev-parse --short HEAD) 5 | popd > /dev/null 6 | 7 | cat <> version.h.tmp 8 | #pragma once 9 | 10 | #define ALT_SDK_VERSION "$COMMIT_HASH" 11 | EOM 12 | 13 | if [ -f version.h ]; then 14 | if cmp -s version.h.tmp version.h; then 15 | rm version.h.tmp 16 | else 17 | rm version.h 18 | mv version.h.tmp version.h 19 | fi 20 | else 21 | mv version.h.tmp version.h 22 | fi 23 | 24 | --------------------------------------------------------------------------------