/// <summary> /// Sets the label. /// </summary> /// <param name="label">The label.</param> public void SetLabel(string label) { if (this.lblProgress.InvokeRequired) { SetString setTextDel = delegate(string text) { lblProgress.Text = text; }; lblProgress.Invoke(setTextDel, new object[] { label }); } else { lblProgress.Text = label; } }
void UpdateStatus(string status) { ISynchronizeInvoke synchronizer = m_StatusLabel; if (synchronizer.InvokeRequired == false) { SetStatus(status); return; } SetString del = new SetString(SetStatus); try { synchronizer.Invoke(del, new object[] { status }); } catch {} }
void ReportTable(string val) { ISynchronizeInvoke synchronizer = lblRows; if (synchronizer.InvokeRequired == false) { SetTable(val); return; } SetString delTab = new SetString(SetTable); try { synchronizer.Invoke(delTab, new object[] { val }); } catch { } }
private void RagePresence_Tick(object sender, EventArgs e) { // Wait until the game has loaded while (Function.Call <bool>(Hash.GET_IS_LOADING_SCREEN_ACTIVE)) { Yield(); } // Get the address of the main RagePresence ASI File IntPtr module = GetModuleHandle("RagePresence.asi"); // If is not there, return if (module == IntPtr.Zero) { Notification.Show("~r~Error~s~: Unable to find RagePresence.asi in memory. Please make sure that it was loaded by checking ScriptHookV.log and then restart your game."); Tick -= RagePresence_Tick; return; } // Try to get the addresses of the functions IntPtr set = GetProcAddress(module, "SetCustomMission"); IntPtr get = GetProcAddress(module, "GetCustomMission"); IntPtr check = GetProcAddress(module, "IsCustomMissionSet"); IntPtr clear = GetProcAddress(module, "ClearCustomMission"); // If the functions are not present, return if (set == IntPtr.Zero) { Notification.Show("~r~Error~s~: Unable to find SetCustomMission in memory. Please make sure that you have an up to date version of RagePresence and restart your game."); Tick -= RagePresence_Tick; return; } if (get == IntPtr.Zero) { Notification.Show("~r~Error~s~: Unable to find GetCustomMission in memory. Please make sure that you have an up to date version of RagePresence and restart your game."); Tick -= RagePresence_Tick; return; } else if (check == IntPtr.Zero) { Notification.Show("~r~Error~s~: Unable to find IsCustomMissionSet in memory. Please make sure that you have an up to date version of RagePresence and restart your game."); Tick -= RagePresence_Tick; return; } else if (clear == IntPtr.Zero) { Notification.Show("~r~Error~s~: Unable to find ClearCustomMission in memory. Please make sure that you have an up to date version of RagePresence and restart your game."); Tick -= RagePresence_Tick; return; } // If we got here, is safe to set the delegates for the pointers of the functions setCustomMission = Marshal.GetDelegateForFunctionPointer <SetString>(set); getCustomMission = Marshal.GetDelegateForFunctionPointer <GetString>(get); isCustomMissionSet = Marshal.GetDelegateForFunctionPointer <GetBool>(check); clearCustomMission = Marshal.GetDelegateForFunctionPointer <Void>(clear); // Then do the last steps Tick -= RagePresence_Tick; IsReady = true; }
private void RagePresence_Tick(object sender, EventArgs e) { // Wait until the game has loaded while (Function.Call <bool>(Hash.GET_IS_LOADING_SCREEN_ACTIVE)) { Yield(); } // Get the address of the main RagePresence ASI File IntPtr module = GetModuleHandle("RagePresence.asi"); // If is not there, return if (module == IntPtr.Zero) { Error("Unable to find RagePresence.asi in memory. Please make sure that it was loaded by checking ScriptHookV.log and then restart your game."); return; } // Try to get the addresses of the functions IntPtr missionSet = GetProcAddress(module, "SetCustomMission"); IntPtr missionGet = GetProcAddress(module, "GetCustomMission"); IntPtr missionCheck = GetProcAddress(module, "IsCustomMissionSet"); IntPtr missionClear = GetProcAddress(module, "ClearCustomMission"); IntPtr detailsSet = GetProcAddress(module, "SetCustomDetails"); IntPtr detailsGet = GetProcAddress(module, "GetCustomDetails"); IntPtr detailsCheck = GetProcAddress(module, "AreCustomDetailsSet"); IntPtr detailsClear = GetProcAddress(module, "ClearCustomDetails"); IntPtr stateSet = GetProcAddress(module, "SetCustomState"); IntPtr stateGet = GetProcAddress(module, "GetCustomState"); IntPtr stateCheck = GetProcAddress(module, "IsCustomStateSet"); IntPtr stateClear = GetProcAddress(module, "ClearCustomState"); // If the functions are not present, return if (missionSet == IntPtr.Zero) { PointerError("SetCustomMission"); return; } if (missionGet == IntPtr.Zero) { PointerError("GetCustomMission"); return; } else if (missionCheck == IntPtr.Zero) { PointerError("IsCustomMissionSet"); return; } else if (missionClear == IntPtr.Zero) { PointerError("ClearCustomMission"); return; } else if (detailsSet == IntPtr.Zero) { PointerError("SetCustomDetails"); return; } else if (detailsGet == IntPtr.Zero) { PointerError("GetCustomDetails"); return; } else if (detailsCheck == IntPtr.Zero) { PointerError("AreCustomDetailsSet"); return; } else if (detailsClear == IntPtr.Zero) { PointerError("ClearCustomDetails"); return; } else if (stateSet == IntPtr.Zero) { PointerError("SetCustomState"); return; } else if (stateGet == IntPtr.Zero) { PointerError("GetCustomState"); return; } else if (stateCheck == IntPtr.Zero) { PointerError("IsCustomStateSet"); return; } else if (stateClear == IntPtr.Zero) { PointerError("ClearCustomState"); return; } // If we got here, is safe to set the delegates for the pointers of the functions setCustomMission = Marshal.GetDelegateForFunctionPointer <SetString>(missionSet); getCustomMission = Marshal.GetDelegateForFunctionPointer <GetString>(missionGet); isCustomMissionSet = Marshal.GetDelegateForFunctionPointer <GetBool>(missionCheck); clearCustomMission = Marshal.GetDelegateForFunctionPointer <Void>(missionClear); setCustomDetails = Marshal.GetDelegateForFunctionPointer <SetString>(detailsSet); getCustomDetails = Marshal.GetDelegateForFunctionPointer <GetString>(detailsGet); areCustomDetailsSet = Marshal.GetDelegateForFunctionPointer <GetBool>(detailsCheck); clearCustomDetails = Marshal.GetDelegateForFunctionPointer <Void>(detailsClear); setCustomState = Marshal.GetDelegateForFunctionPointer <SetString>(stateSet); getCustomState = Marshal.GetDelegateForFunctionPointer <GetString>(stateGet); isCustomStateSet = Marshal.GetDelegateForFunctionPointer <GetBool>(stateCheck); clearCustomState = Marshal.GetDelegateForFunctionPointer <Void>(stateClear); // Then do the last steps Tick -= RagePresence_Tick; IsReady = true; }