/// <summary> /// Converts the specified position into one that is aware of <see cref="SetElementAlignment(GFXAlignment, GFXAlignment)"/>. /// </summary> /// <param name="x">The 1080p based X position.</param> /// <param name="y">The 1080p based Y position.</param> /// <returns>A new 1080p based position that is aware of the the Alignment.</returns> public static PointF GetRealPosition(float x, float y) { // Convert the resolution to relative ToRelative(x, y, out float relativeX, out float relativeY); // Request the real location of the position float realX = 0, realY = 0; #if FIVEM API.GetScriptGfxPosition(relativeX, relativeY, ref realX, ref realY); #elif RPH using (NativePointer argX = new NativePointer()) using (NativePointer argY = new NativePointer()) { NativeFunction.CallByHash <int>(0x6DD8F5AA635EB4B2, relativeX, relativeY, argX, argY); realX = argX.GetValue <float>(); realY = argY.GetValue <float>(); } #elif (SHVDN2 || SHVDN3) OutputArgument argX = new OutputArgument(); OutputArgument argY = new OutputArgument(); Function.Call((Hash)0x6DD8F5AA635EB4B2, relativeX, relativeY, argX, argY); // _GET_SCRIPT_GFX_POSITION realX = argX.GetResult <float>(); realY = argY.GetResult <float>(); #endif // And return it converted to absolute ToAbsolute(realX, realY, out float absoluteX, out float absoluteY); return(new PointF(absoluteX, absoluteY)); }
private static void DrawText(String text, float x, float y, float scale, bool centre, bool rightJust, float wrapEnd, bool shadow, Color fcolor) { NativeFunction.CallByName <uint>("SET_TEXT_FONT", 0); NativeFunction.CallByName <uint>("SET_TEXT_SCALE", scale, scale); NativeFunction.CallByName <uint>("SET_TEXT_COLOUR", (int)fcolor.R, (int)fcolor.G, (int)fcolor.B, (int)fcolor.A); NativeFunction.CallByHash <uint>(0x038C1F517D7FDCF8, false); NativeFunction.CallByHash <uint>(0xC02F4DBFB51D988B, centre); NativeFunction.CallByHash <uint>(0x6B3C4650BC8BEE47, rightJust); if (!rightJust) { NativeFunction.CallByName <uint>("SET_TEXT_WRAP", 0.0f, 1.0f); } else { NativeFunction.CallByName <uint>("SET_TEXT_WRAP", 0.0f, wrapEnd); } if (!shadow) { NativeFunction.CallByName <uint>("SET_TEXT_DROPSHADOW", 0, 0, 0, 0, 0); } else { NativeFunction.CallByName <uint>("SET_TEXT_DROPSHADOW", 100, 0, 0, 0, 0); } NativeFunction.CallByName <uint>("SET_TEXT_EDGE", 1, 0, 0, 0, 205); NativeFunction.CallByName <uint>("_SET_TEXT_ENTRY", "STRING"); NativeFunction.CallByName <uint>("_ADD_TEXT_COMPONENT_STRING", text); NativeFunction.CallByName <uint>("_DRAW_TEXT", x, y); }
private static IntPtr NativeCall() { if (returnedValue == IntPtr.Zero) { throw new Exception("RPHNativeInvoker is not initialized."); } NativeArgument[] args = argsBuffer[argumentsIndex]; for (int i = 0; i < argumentsIndex; i++) { args[i] = new NativeArgument(arguments[i]); } argumentsIndex = 0; try { *(NativeRetVal *)returnedValue = NativeFunction.CallByHash <NativeRetVal>(nativeHash, args); } catch (Exception) { if (Support.Instance.Config.IgnoreUnknownNatives) { *(NativeRetVal *)returnedValue = new NativeRetVal(); //== 0 } else { throw; } } return(returnedValue); }
/// <summary> /// Gets the returned string from a native. /// </summary> /// <param name="native_hash">Hash of the native</param> /// <param name="args">Arguments</param> /// <returns>A string of the native's return</returns> internal static string GetStringFromNative(ulong native_hash, params NativeArgument[] args) { IntPtr ptr = NativeFunction.CallByHash <IntPtr>(native_hash, args); String str = Marshal.PtrToStringAnsi(ptr); return(str); }
public new static void Draw(string caption, Point position, float scale, Color color, Common.EFont font, bool centered) { int screenw = Game.Resolution.Width; int screenh = Game.Resolution.Height; const float height = 1080f; float ratio = (float)screenw / screenh; var width = height * ratio; float x = (position.X) / width; float y = (position.Y) / height; NativeFunction.CallByName <uint>("SET_TEXT_FONT", (int)font); NativeFunction.CallByName <uint>("SET_TEXT_SCALE", 1.0f, scale); NativeFunction.CallByName <uint>("SET_TEXT_COLOUR", color.R, color.G, color.B, color.A); if (centered) { NativeFunction.CallByName <uint>("SET_TEXT_CENTRE", true); } NativeFunction.CallByHash <uint>(0x25fbb336df1804cb, "jamyfafi"); // _SET_TEXT_ENTRY AddLongString(caption); NativeFunction.CallByHash <uint>(0xcd015e5bb0d96a57, x, y); // _DRAW_TEXT }
/// <summary> /// Returns the position zone, Los Santos or Blaine County /// </summary> /// <param name="position">Position</param> /// <returns>the position zone </returns> public static EWorldArea GetArea(Vector3 position) { ulong GetMapZoneAtCoordsHash = 0x7ee64d51e8498728; EWorldArea zone = (EWorldArea)NativeFunction.CallByHash <int>(GetMapZoneAtCoordsHash, position.X, position.Y, position.Z); return(zone); }
public static void SetName(this Blip blip, string text) { const ulong AddTextComponentStringHash = 0x6c188be134e074aa; NativeFunction.CallByName <uint>("BEGIN_TEXT_COMMAND_SET_BLIP_NAME", "STRING"); NativeFunction.CallByHash <uint>(AddTextComponentStringHash, text); NativeFunction.CallByName <uint>("END_TEXT_COMMAND_SET_BLIP_NAME", blip); }
public void CallFunction(string function, params object[] arguments) { const ulong PushScaleformMovieFunctionHash = 0xf6e48914c7a8694e; const ulong PushScaleformMovieFunctionParameterIntHash = 0xc3d0841a0cc546a6; const ulong BeginTextComponentHash = 0x80338406f3475e55; const ulong AddTextComponentStringHash = 0x6c188be134e074aa; const ulong EndTextComponentHash = 0x362e2d3fe93a9959; const ulong PushScaleformMovieFunctionParameterFloatHash = 0xd69736aae04db51a; const ulong PushScaleformMovieFunctionParameterBoolHash = 0xc58424ba936eb458; const ulong PushScaleformMovieFunctionParameterStringHash = 0xba7148484bd90365; const ulong PopScaleformMovieFunctionVoidHash = 0xc6796a8ffa375e53; NativeFunction.CallByHash <uint>(PushScaleformMovieFunctionHash, this.handle, function); foreach (object obj in arguments) { if (obj.GetType() == typeof(int)) { NativeFunction.CallByHash <uint>(PushScaleformMovieFunctionParameterIntHash, (int)obj); } else if (obj.GetType() == typeof(string)) { NativeFunction.CallByHash <uint>(BeginTextComponentHash, "STRING"); NativeFunction.CallByHash <uint>(AddTextComponentStringHash, (string)obj); NativeFunction.CallByHash <uint>(EndTextComponentHash); } else if (obj.GetType() == typeof(char)) { NativeFunction.CallByHash <uint>(BeginTextComponentHash, "STRING"); NativeFunction.CallByHash <uint>(AddTextComponentStringHash, ((char)obj).ToString()); NativeFunction.CallByHash <uint>(EndTextComponentHash); } else if (obj.GetType() == typeof(float)) { NativeFunction.CallByHash <uint>(PushScaleformMovieFunctionParameterFloatHash, (float)obj); } else if (obj.GetType() == typeof(double)) { NativeFunction.CallByHash <uint>(PushScaleformMovieFunctionParameterFloatHash, (float)((double)obj)); } else if (obj.GetType() == typeof(bool)) { NativeFunction.CallByHash <uint>(PushScaleformMovieFunctionParameterBoolHash, (bool)obj); } else if (obj.GetType() == typeof(ScaleformArgumentTXD)) { NativeFunction.CallByHash <uint>(PushScaleformMovieFunctionParameterStringHash, ((ScaleformArgumentTXD)obj).TXD); } else { Game.LogTrivial(String.Format("Unknown argument type {0} passed to scaleform with handle {1}.", obj.GetType().Name, this.handle)); } } NativeFunction.CallByHash <uint>(PopScaleformMovieFunctionVoidHash); }
/// <summary> /// Enables a control during the next frame. /// </summary> /// <param name="control">The control to enable.</param> public static void EnableThisFrame(Control control) { #if FIVEM API.EnableControlAction(0, (int)control, true); #elif RPH NativeFunction.CallByHash <int>(0x351220255D64C155, 0, (int)control); #elif (SHVDN2 || SHVDN3) Function.Call(Hash.ENABLE_CONTROL_ACTION, 0, (int)control); #endif }
/// <summary> /// Disables all of the controls during the next frame. /// </summary> public static void DisableAll(int inputGroup = 0) { #if FIVEM API.DisableAllControlActions(inputGroup); #elif RPH NativeFunction.CallByHash <int>(0x5F4B6931816E599B, inputGroup); #elif (SHVDN2 || SHVDN3) Function.Call(Hash.DISABLE_ALL_CONTROL_ACTIONS, inputGroup); #endif }
/// <summary> /// Checks if a control is currently pressed. /// </summary> /// <param name="control">The control to check.</param> /// <returns>true if the control is pressed, false otherwise.</returns> public static bool IsPressed(Control control) { #if FIVEM return(API.IsDisabledControlPressed(0, (int)control)); #elif RPH return(NativeFunction.CallByHash <bool>(0xE2587F8CBBD87B1D, 0, (int)control)); #elif (SHVDN2 || SHVDN3) return(Function.Call <bool>(Hash.IS_DISABLED_CONTROL_PRESSED, 0, (int)control)); #endif }
/// <summary> /// Checks if a control was pressed during the last frame. /// </summary> /// <param name="control">The control to check.</param> /// <returns>true if the control was pressed, false otherwise.</returns> public static bool IsJustPressed(Control control) { #if FIVEM return(API.IsDisabledControlJustPressed(0, (int)control)); #elif RPH return(NativeFunction.CallByHash <bool>(0x91AEF906BCA88877, 0, (int)control)); #elif (SHVDN2 || SHVDN3) return(Function.Call <bool>(Hash.IS_DISABLED_CONTROL_JUST_PRESSED, 0, (int)control)); #endif }
/// <summary> /// Disables a control during the next frame. /// </summary> /// <param name="control">The control to disable.</param> public static void DisableThisFrame(Control control) { #if FIVEM API.DisableControlAction(0, (int)control, true); #elif RPH NativeFunction.CallByHash <int>(0xFE99B66D079CF6BC, 0, (int)control, true); #elif (SHVDN2 || SHVDN3) Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)control, true); #endif }
/// <summary> /// Push a long string into the stack. /// </summary> /// <param name="str"></param> public static void AddLongString(string str) { const int strLen = 99; for (int i = 0; i < str.Length; i += strLen) { string substr = str.Substring(i, Math.Min(strLen, str.Length - i)); NativeFunction.CallByHash <uint>(0x6c188be134e074aa, substr); // _ADD_TEXT_COMPONENT_STRING } }
/// <summary> /// Calls a Scaleform function with a return value. /// </summary> /// <param name="function">The name of the function to call.</param> /// <param name="parameters">The parameters to pass.</param> public int CallFunctionReturn(string function, params object[] parameters) { CallFunctionBase(function, parameters); #if FIVEM return(API.EndScaleformMovieMethodReturnValue()); #elif RPH return(NativeFunction.CallByHash <int>(0xC50AA39A577AF886)); #elif (SHVDN2 || SHVDN3) return(Function.Call <int>((Hash)0xC50AA39A577AF886)); #endif }
/// <summary> /// Calls a Scaleform function. /// </summary> /// <param name="function">The name of the function to call.</param> /// <param name="parameters">The parameters to pass.</param> public void CallFunction(string function, params object[] parameters) { CallFunctionBase(function, parameters); #if FIVEM API.EndScaleformMovieMethod(); #elif RPH NativeFunction.CallByHash <int>(0xC6796A8FFA375E53); #elif (SHVDN2 || SHVDN3) Function.Call((Hash)0xC6796A8FFA375E53); #endif }
public static void DrawShiftWorkStatus() { NativeFunction.CallByHash <uint>(0x66E0276CC5F6B9DA, 1); // font NativeFunction.CallByHash <uint>(0x07C837F9A01C34C9, 1.0f, 1.0f); // scale NativeFunction.CallByHash <uint>(0xBE6B23FFA53FB442, 255, 255, 255, 255); // colour NativeFunction.CallByHash <uint>(0xC02F4DBFB51D988B, 1); // centre NativeFunction.CallByHash <uint>(0x465C84BC39F1C351, 0, 0, 0, 0, 0); //dropshadow NativeFunction.CallByHash <uint>(0x441603240D202FA6, 0, 0, 0, 0, 0); //edge NativeFunction.CallByHash <uint>(0x25FBB336DF1804CB, "STRING"); // text_entry NativeFunction.CallByHash <uint>(0x6C188BE134E074AA, "You still have to work ~g~" + ConvertSecondsToMinutes(ShiftWork.timerCountDown) + "~s~ minutes "); // component_string NativeFunction.CallByHash <uint>(0xCD015E5BB0D96A57, 0.48f, 0.03f); // draw_text }
/// <summary> /// Marks the scaleform as no longer needed. /// </summary> public void Dispose() { int id = Handle; #if FIVEM API.SetScaleformMovieAsNoLongerNeeded(ref id); #elif RPH NativeFunction.CallByHash <int>(0x1D132D614DD86811, new NativeArgument(id)); #elif (SHVDN2 || SHVDN3) Function.Call(Hash.SET_SCALEFORM_MOVIE_AS_NO_LONGER_NEEDED, new OutputArgument(id)); #endif }
/// <summary> /// Checks if the specified Scaleform Return Value is ready to be fetched. /// </summary> /// <param name="id">The Identifier of the Value.</param> public bool IsValueReady(int id) { #if FIVEM return(API.IsScaleformMovieMethodReturnValueReady(id)); #elif RPH return(NativeFunction.CallByHash <bool>(0x768FF8961BA904D6, id)); #elif SHVDN2 return(Function.Call <bool>(Hash._0x768FF8961BA904D6, id)); #elif SHVDN3 return(Function.Call <bool>(Hash.IS_SCALEFORM_MOVIE_METHOD_RETURN_VALUE_READY, id)); #endif }
/// <summary> /// Resets the alignment of the game elements. /// </summary> public static void ResetElementAlignment() { #if FIVEM API.ResetScriptGfxAlign(); #elif RPH NativeFunction.CallByHash <int>(0xE3A3DB414A373DAB); #elif SHVDN2 Function.Call(Hash._0xE3A3DB414A373DAB); #elif SHVDN3 Function.Call(Hash.RESET_SCRIPT_GFX_ALIGN); #endif }
public static void DrawMoneyStatus() { NativeFunction.CallByHash <uint>(0x66E0276CC5F6B9DA, 1); // font NativeFunction.CallByHash <uint>(0x07C837F9A01C34C9, 1.0f, 1.0f); // scale NativeFunction.CallByHash <uint>(0xBE6B23FFA53FB442, 255, 255, 255, 255); // colour NativeFunction.CallByHash <uint>(0xC02F4DBFB51D988B, 1); // centre NativeFunction.CallByHash <uint>(0x465C84BC39F1C351, 0, 0, 0, 0, 0); //dropshadow NativeFunction.CallByHash <uint>(0x441603240D202FA6, 0, 0, 0, 0, 0); //edge NativeFunction.CallByHash <uint>(0x25FBB336DF1804CB, "STRING"); // text_entry NativeFunction.CallByHash <uint>(0x6C188BE134E074AA, "Money:~g~" + Main.myPlayer.playerMoney.ToString() + "$"); // component_string NativeFunction.CallByHash <uint>(0xCD015E5BB0D96A57, 0.8f, 0.03f); // draw_text }
/// <summary> /// Shows the cursor during the current game frame. /// </summary> public static void ShowCursorThisFrame() { #if FIVEM API.SetMouseCursorActiveThisFrame(); #elif RPH NativeFunction.CallByHash <int>(0xAAE7CE1D63167423); #elif SHVDN2 Function.Call(Hash._SHOW_CURSOR_THIS_FRAME); #elif SHVDN3 Function.Call(Hash._SET_MOUSE_CURSOR_ACTIVE_THIS_FRAME); #endif }
private static unsafe System.Drawing.Color UnsafeGetNeonLightsColor(Vehicle vehicle) { Color color; int red; int green; int blue; ulong GetVehicleNeonLightsColourHash = 0x7619eee8c886757f; NativeFunction.CallByHash <uint>(GetVehicleNeonLightsColourHash, vehicle, &red, &green, &blue); return(color = Color.FromArgb(red, green, blue)); }
public static void Draw(string caption, Point position, float scale, Color color, Common.EFont font, bool centered) { float x = position.X / 1280.0f; float y = position.Y / 720.0f; NativeFunction.CallByName <uint>("SET_TEXT_FONT", (int)font); NativeFunction.CallByName <uint>("SET_TEXT_SCALE", scale, scale); NativeFunction.CallByName <uint>("SET_TEXT_COLOUR", color.R, color.G, color.B, color.A); NativeFunction.CallByName <uint>("SET_TEXT_CENTRE", centered); NativeFunction.CallByHash <uint>(0x25fbb336df1804cb, "STRING"); // SetTextEntry native NativeFunction.CallByHash <uint>(0x6c188be134e074aa, caption); // AddTextComponentString native NativeFunction.CallByHash <uint>(0xcd015e5bb0d96a57, x, y); // DrawText native }
public static EPaint GetSecondaryColor(this Vehicle veh) { unsafe { int colorPrimaryInt; int colorSecondaryInt; ulong GetVehicleColorsHash = 0xa19435f193e081ac; NativeFunction.CallByHash <uint>(GetVehicleColorsHash, veh, &colorPrimaryInt, &colorSecondaryInt); return((EPaint)colorSecondaryInt); } }
/// <summary> /// Returns the neon light color /// </summary> /// <param name="vehicle"></param> /// <returns>the neon light color</returns> public static Color GetNeonLightsColor(this Vehicle vehicle) { unsafe { Color color; int red; int green; int blue; ulong GetVehicleNeonLightsColourHash = 0x7619eee8c886757f; NativeFunction.CallByHash <uint>(GetVehicleNeonLightsColourHash, vehicle, &red, &green, &blue); return(color = Color.FromArgb(red, green, blue)); } }
public static void UseFilter(bool enable) { if (enable) { DashHelper.filter = true; Game.Console.Print("[DASHCAM V] Black and white filter enabled."); } else { DashHelper.filter = false; NativeFunction.CallByHash <uint>(0x0F07E7745A236711); Game.Console.Print("[DASHCAM V] Black and white filter disabled."); } }
public static void GetColors(this Vehicle veh, out EPaint primaryColor, out EPaint secondaryColor) { unsafe { int colorPrimaryInt; int colorSecondaryInt; ulong GetVehicleColorsHash = 0xa19435f193e081ac; NativeFunction.CallByHash <uint>(GetVehicleColorsHash, veh, &colorPrimaryInt, &colorSecondaryInt); primaryColor = (EPaint)colorPrimaryInt; secondaryColor = (EPaint)colorSecondaryInt; } }
public static void Draw(string caption, Point position, float scale, Color color, Common.EFont font, Alignment textAlignment, bool dropShadow, bool outline, Size wordWrap) { int screenw = Game.Resolution.Width; int screenh = Game.Resolution.Height; const float height = 1080f; float ratio = (float)screenw / screenh; var width = height * ratio; float x = (position.X) / width; float y = (position.Y) / height; NativeFunction.CallByName <uint>("SET_TEXT_FONT", (int)font); NativeFunction.CallByName <uint>("SET_TEXT_SCALE", 1.0f, scale); NativeFunction.CallByName <uint>("SET_TEXT_COLOUR", color.R, color.G, color.B, color.A); if (dropShadow) { NativeFunction.CallByName <uint>("SET_TEXT_DROP_SHADOW"); } if (outline) { NativeFunction.CallByName <uint>("SET_TEXT_OUTLINE"); } switch (textAlignment) { case Alignment.Centered: NativeFunction.CallByName <uint>("SET_TEXT_CENTRE", true); break; case Alignment.Right: NativeFunction.CallByName <uint>("SET_TEXT_RIGHT_JUSTIFY", true); NativeFunction.CallByName <uint>("SET_TEXT_WRAP", 0, x); break; } if (wordWrap != new Size(0, 0)) { float xsize = (position.X + wordWrap.Width) / width; NativeFunction.CallByName <uint>("SET_TEXT_WRAP", x, xsize); } NativeFunction.CallByHash <uint>(0x25fbb336df1804cb, "jamyfafi"); // _SET_TEXT_ENTRY AddLongString(caption); NativeFunction.CallByHash <uint>(0xcd015e5bb0d96a57, x, y); // _DRAW_TEXT }
/// <summary> /// Draws the rectangle on the screen. /// </summary> public override void Draw() { if (Size == SizeF.Empty) { return; } #if FIVEM API.DrawRect(relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, Color.R, Color.G, Color.B, Color.A); #elif RPH NativeFunction.CallByHash <int>(0x3A618A217E5154F0, relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, Color.R, Color.G, Color.B, Color.A); #elif (SHVDN2 || SHVDN3) Function.Call(Hash.DRAW_RECT, relativePosition.X, relativePosition.Y, relativeSize.Width, relativeSize.Height, Color.R, Color.G, Color.B, Color.A); #endif }