/// <summary> /// Returns true if this vehicle is damaged. /// </summary> public static bool IsDamaged(this Vehicle vehicle) => NativeWrappers.IsVehicleDamaged(vehicle);
/// <summary> /// Causes this ped to face the specified <paramref name="entity"/> for some <paramref name="duration"/> (in ms). /// </summary> /// <param name="duration">In miliseconds (-1 is infinite)</param> public static void FaceEntity(this Ped ped, Entity entity, int duration) => NativeWrappers.TaskTurnPedToFaceEntity(ped, entity, duration);
/// <summary> /// Sets this <see cref="Vehicle"/> forward speed /// </summary> /// <param name="forwardSpeed">The forward speed in m/s.</param> /// <remarks> /// <para>Setting the speed to 30 would result in a speed of roughly 60mph, according to speedometer.</para> /// <para>To convert m/s to mph use <see cref="MathHelper.ConvertMetersPerSecondToMilesPerHour(float)"/></para> /// </remarks> public static void SetForwardSpeed(this Vehicle vehicle, float forwardSpeed) => NativeWrappers.SetVehicleForwardSpeed(vehicle, forwardSpeed);
/// <summary> /// Applies an amount of <paramref name="damage"/> across a specified <paramref name="radius"/> to a <paramref name="position"/> relative to the vehicle's model. /// </summary> /// <remarks> /// When <paramref name="focusOnModel"/> is set to `true`, the damage sphere will travel towards the vehicle from the given <paramref name="position"/>, thus guaranteeing an impact. /// </remarks> public static void SetVehicleDamage(this Vehicle vehicle, Vector3 position, float damage, float radius, bool focusOnModel) => NativeWrappers.SetVehicleDamage(vehicle, position, damage, radius, focusOnModel);
/// <summary> /// Determine whether this <paramref name="position"/> is on screen, or visible by a rendering <see cref="Camera"/> /// </summary> /// <param name="position"></param> /// <returns><c>true</c> if this <paramref name="position"/> is on screen, or visible by a rendering <see cref="Camera"/></returns> public static bool IsOnScreen(this Vector3 position) { return(NativeWrappers.GetHudScreenPositionFromWorldPosition(position, out float _, out float _)); }
/// <summary> /// Checks whether this <see cref="Vehicle"/> is stuck on it's roof /// </summary> /// <param name="vehicle">The <see cref="Vehicle"/> to check</param> /// <returns><c>true</c> if this <see cref="Vehicle"/> is stuck on roof</returns> public static bool IsStuckOnRoof(this Vehicle vehicle) { return(NativeWrappers.IsVehicleStuckOnRoof(vehicle)); }
/// <summary> /// Gets a list of scenarios that currently active in this ped /// </summary> /// <param name="ped"></param> /// <returns></returns> public static List <Scenario> GetActiveScenarios(this Ped ped) { var scenarios = Enum.GetValues(typeof(Scenario)).Cast <Scenario>(); return(scenarios.Where(x => NativeWrappers.IsPedUsingScenario(ped, x.ToString())).ToList()); }
internal void TriggerChatAction(string name) { NativeWrappers.SendNuiMessage($@"{{""meta"": ""{name}""}}"); }
/// <summary> /// Returns true if the specified task is active for this ped. /// </summary> public static bool IsTaskActive(this Ped ped, PedTask task) => NativeWrappers.GetIsTaskActive(ped, (int)task);
/// <summary> /// Checks whether this ped is playing the specified scenario /// </summary> /// <param name="ped">The target <see cref="Ped"/></param> /// <param name="scenario">The scenario that want to be check</param> /// <returns><c>true</c> if this ped is playing the given <paramref name="scenario"/>, otherwise <c>false</c></returns> public static bool IsUsingScenario(this Ped ped, Scenario scenario) => NativeWrappers.IsPedUsingScenario(ped, scenario.ToString());
/// <summary> /// Causes this ped to start playing the specified scenario at the given <paramref name="position"/> /// </summary> /// <param name="ped">The target <see cref="Ped"/></param> /// <param name="scenario">The scenario to be played</param> /// <param name="position">The position that the scenario will be playing at</param> /// <param name="heading">The heading</param> /// <param name="duration">in miliseconds, if <c>-1</c> the task will never timeout</param> /// <param name="sittingScenario"><c>true</c> if the given <paramref name="scenario"/> is a sitting scenario, otherwise <c>false</c></param> /// <param name="teleport">if set to <c>true</c> the <paramref name="ped"/> will be teleported at the given <paramref name="position"/></param> public static void StartScenarioAtPosition(this Ped ped, Scenario scenario, Vector3 position, float heading, int duration, bool sittingScenario, bool teleport) { NativeWrappers.TaskStartScenarioAtPosition(ped, scenario.ToString(), position, heading, duration, sittingScenario, teleport); }
/// <summary> /// Causes this ped to start playing the specified scenario in place. /// </summary> public static void StartScenarioInPlace(this Ped ped, Scenario scenario, int unkDelay = 0, bool playEnterAnimation = true) { NativeWrappers.TaskStartScenarioInPlace(ped, scenario, unkDelay, playEnterAnimation); }
/// <summary> /// Causes this ped to shoot from a vehicle at the specified <paramref name="target"/> ped. (e.g. drive-bys) /// </summary> /// <param name="unknown">Unknown parameter, default 0</param> public static void ShootFromVehicle(this Ped ped, Ped target, float unknown = 0) => NativeWrappers.TaskVehicleShootAtPed(ped, target, unknown);
/// <summary> /// Checks whether this <see cref="Entity"/> is an <see cref="Rage.Object"/> /// </summary> /// <param name="entity">The <see cref="Entity"/> to check</param> /// <returns><c>true</c> if this <see cref="Entity"/> is an <see cref="Rage.Object"/>, otherwise <c>false</c></returns> public static bool IsObject(this Entity entity) { return(NativeWrappers.IsEntityAnObject(entity)); }
public void Draw() { NativeWrappers.DrawMarker(MarkerType, Position, Direction, Rotation, Scale, MarkerColor, BobUpAndDown, FaceCamera, Rotate, DrawOnEntities); }
public async Task Update() { try { // Currently it seems this assembly loads way earlier than the Lua ever did // So SetTextChatEnabled has to be called at a later point than before // Not sure what would be a suitable solution, so temporarily // it's done on each tick... Overkill. NativeWrappers.SetTextChatEnabled(false); if (isChatScrollEnabled) { if (Game.IsControlJustPressed(0, Control.ReplayCameraUp)) // PgUp { TriggerChatAction("scrollUp"); } else if (Game.IsControlJustPressed(0, Control.ReplayCameraDown)) // PgDn { TriggerChatAction("scrollDown"); } } if (isChatInputActive && Game.IsDisabledControlPressed(0, Control.CursorScrollUp)) // Scrollwheel Up { TriggerChatAction("scrollUp"); } else if (isChatInputActive && Game.IsDisabledControlPressed(0, Control.CursorScrollDown)) // Scrollwheel Down { TriggerChatAction("scrollDown"); } if (Game.IsControlJustPressed(0, Control.FrontendCancel)) // Escape { isChatInputActive = false; isChatInputActivating = false; NativeWrappers.EnableControlAction(0, Control.CursorScrollUp, true); // Scrollwheel Up NativeWrappers.EnableControlAction(0, Control.CursorScrollDown, true); // Scrollwheel Down NativeWrappers.SetPedCanSwitchWeapon(Game.PlayerPed, true); // Disable weapon select NativeWrappers.SetNuiFocus(false); TriggerChatAction("forceCloseChatBox"); } if (!isChatInputActive && Game.IsControlPressed(0, Control.MpTextChatAll)) { isChatInputActive = true; isChatInputActivating = true; TriggerChatAction("openChatBox"); } if (isChatInputActivating && !Game.IsControlPressed(0, Control.MpTextChatAll)) { NativeWrappers.SetNuiFocus(true); isChatInputActivating = false; } if (isChatInputActive) { TriggerChatAction("focusChatBox"); NativeWrappers.DisableControlAction(0, Control.CursorScrollUp, true); NativeWrappers.DisableControlAction(0, Control.CursorScrollDown, true); NativeWrappers.SetPedCanSwitchWeapon(Game.PlayerPed, false); } } catch (Exception ex) { Log.Error($"Chat Update ERROR: ${ex.Message}"); } await Task.FromResult(0); }
public static void Delete(int id) { NativeWrappers.DeleteCheckpoint(id); }
/// <summary> /// Determine whether the given <paramref name="position"/> is occupied /// </summary> /// <param name="position">The position to checks</param> /// <param name="range">The range</param> /// <param name="checkVehicles">Check for any <see cref="Vehicle"/> in that area.</param> /// <param name="checkPeds">Check for any <see cref="Ped"/> in that area.</param> /// <param name="ignoredEntity">This <see cref="Entity"/> will be ignored if it's in the area. Set to <c>null</c> if you don't want to exclude any <see cref="Entity"/>.</param> /// <returns><c>true</c> if there is anything in that location matching the provided parameters.</returns> public static bool IsOccupied(this Vector3 position, float range, bool checkVehicles, bool checkPeds, Entity ignoredEntity) { return(NativeWrappers.IsPositionOccupied(position, range, false, checkVehicles, checkPeds, false, false, ignoredEntity, false)); }
internal unsafe void Initialize(Process process, ILogger logger) { this.logger = logger; if (process == null) { return; // Do not continue if this is null. } if (!SelectPointerAddresses(GameHashes.DetectVersion(process.MainModule.FileName))) { return; // Unknown version. } int pid = GetProcessId(process).Value; memoryAccess = new ProcessMemoryHandler(pid); if (ProcessRunning) { BaseAddress = NativeWrappers.GetProcessBaseAddress(pid, PInvoke.ListModules.LIST_MODULES_64BIT); // Bypass .NET's managed solution for getting this and attempt to get this info ourselves via PInvoke since some users are getting 299 PARTIAL COPY when they seemingly shouldn't. // Setup the pointers. //PointerPlayerHP = new MultilevelPointer(memoryAccess, IntPtr.Add(BaseAddress, pointerAddressHP), 0x58L, 0x18L, 0x18L, 0x78L, 0x68L, 0x48L); //PointerCurrentView = new MultilevelPointer(memoryAccess, IntPtr.Add(BaseAddress, pointerCurrentView), 0x58L); PointerEventActionType = new MultilevelPointer( memoryAccess, IntPtr.Add(BaseAddress, pointerPropsManager), 0x58L, 0x68L, 0x68L, 0xD0L, 0x38L, 0x50L ); PointerIsMotionPlay = new MultilevelPointer( memoryAccess, IntPtr.Add(BaseAddress, pointerPropsManager), 0x58L, 0x68L, 0x68L, 0xD0L, 0x38L ); PointerEventActionTask = new MultilevelPointer( memoryAccess, IntPtr.Add(BaseAddress, pointerEventActionTask), 0x58L, 0x60L, 0x40L, 0x80L, 0x10L, 0x10L, 0x20L, 0x28L ); PointerPlayerStatus = new MultilevelPointer( memoryAccess, IntPtr.Add(BaseAddress, pointerPropsManager), 0x58L, 0x68L, 0x68L ); PointerPlayerHP = new MultilevelPointer( memoryAccess, IntPtr.Add(BaseAddress, pointerPropsManager), 0x58L, 0x68L, 0x68L, 0xD0L, 0x68L, 0x48L ); PointerPlayerPosition = new MultilevelPointer( memoryAccess, IntPtr.Add(BaseAddress, pointerPropsManager), 0x58L, 0x68L, 0x68L, 0xD0L, 0x78L, 0x50L ); PointerRankManager = new MultilevelPointer( memoryAccess, IntPtr.Add(BaseAddress, pointerRankManager) ); try { PointerInventory = new MultilevelPointer( memoryAccess, IntPtr.Add(BaseAddress, pointerInventory), 0x60L, 0x18L, 0x10L ); //Enemies PointerEnemyEntryList = new MultilevelPointer( memoryAccess, IntPtr.Add(BaseAddress, pointerAddressEnemies), 0x58L, 0x10L ); PointerEnemyCount = new MultilevelPointer( memoryAccess, IntPtr.Add(BaseAddress, pointerAddressEnemies), 0x58L, 0x10L ); GenerateEnemyEntries(); //Items PointerInventoryCount = new MultilevelPointer( memoryAccess, IntPtr.Add(BaseAddress, pointerInventory), 0x60L, 0x18L, 0x10L ); PointerInventoryEntryList = new MultilevelPointer( memoryAccess, IntPtr.Add(BaseAddress, pointerAddressItems), 0x78L, 0x70L ); GenerateItemEntries(); } catch { // May fail in main menu } } }
/// <summary> /// Makes this <see cref="Vehicle"/> honk it's horn for the given <paramref name="duration"/> (in ms). /// </summary> public static void HonkHorn(this Vehicle vehicle, int duration, bool heldDown = false, bool forever = false) => NativeWrappers.StartVehicleHorn(vehicle, duration, heldDown, forever);
public static bool WasLastInputFromController() { return(!NativeWrappers.IsInputDisabled(controllerControlGroup)); }
/// <summary> /// Sets the state of this vehicle's lights /// </summary> public static void SetLights(this Vehicle vehicle, VehicleLightsState vehicleLightsState) => NativeWrappers.SetVehicleLights(vehicle, vehicleLightsState);
/// <summary> /// Sets the max <paramref name="speed"/> of this entity. /// </summary> /// <remarks> /// Animations may become out of sync if speed is adjusted too much (e.g., running) /// </remarks> public static void SetMaxSpeed(this Entity entity, float speed) { NativeWrappers.SetEntityMaxSpeed(entity, speed); }
/// <summary> /// Toggle's this vehicle's brake lights on or off /// </summary> public static void SetBrakeLights(this Vehicle vehicle, bool enabled) => NativeWrappers.SetVehicleBrakeLights(vehicle, enabled);
/// <summary> /// Checks whether this <see cref="Entity"/> is a <see cref="Ped"/> /// </summary> /// <param name="entity">The <see cref="Entity"/> to check</param> /// <returns><c>true</c> if this <see cref="Entity"/> is a <see cref="Ped"/>, otherwise <c>false</c></returns> public static bool IsPed(this Entity entity) { return(NativeWrappers.IsEntityAPed(entity)); }
/// <summary> /// Fixes the specified window of this vehicle. /// </summary> public static void FixWindow(Vehicle vehicle, Vehicles.VehicleWindow vehicleWindow) => NativeWrappers.FixVehicleWindow(vehicle, vehicleWindow);
/// <summary> /// Checks whether this <see cref="Entity"/> is a <see cref="Vehicle"/> /// </summary> /// <param name="entity">The <see cref="Entity"/> to check</param> /// <returns><c>true</c> if this <see cref="Entity"/> is a <see cref="Vehicle"/>, otherwise <c>false</c></returns> public static bool IsVehicle(this Entity entity) { return(NativeWrappers.IsEntityAVehicle(entity)); }
/// <summary> /// Copies the damage from this vehicle to <paramref name="targetVehicle"/> /// </summary> /// <remarks> /// Unlike SetVehicleDamage, there is no audio when the damage is applied. /// </remarks> public static void CopyVehicleDamages(this Vehicle vehicle, Vehicle targetVehicle) => NativeWrappers.CopyVehicleDamages(vehicle, targetVehicle);
/// <summary> /// indicates whether this <paramref name="ped"/> can see the <paramref name="target"/> <see cref="Ped"/> /// </summary> public static bool CanSeePed(this Ped ped, Ped target) { return(NativeWrappers.CanPedSeeHatedPed(ped, target)); }