@colcefer

Могу ли я связать два автономных скрипта?

Код номер 1 цепляется при запуске игры GTA 5 и работает.

Код №1

using GTA;
using GTA.Native;
using GTA.Math;
using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.IO;
using System.Drawing;
using System.Media;

public class SuperStreamMod : Script
{
	// Where you initialize all your variables for use.
	private string modName = "SuperStreamMod";
	private string modCreatorName = "Colcefer®";

	private Ped playerPed = Game.Player.Character;
	private Player player = Game.Player;

	// Where you initialize the events or do anything when the mod starts.
	public SuperStreamMod()
	{
		UI.Notify(modName + " сделан: " + modCreatorName);

		Tick += OnTick;
		KeyDown += OnKeyDown;
		KeyUp += OnKeyUp;
	}

	// This is where loops/things are run every frame.
	private void OnTick(object sender, EventArgs e)
	{

	}
	
	// When you press a key down or hold it.
	private void OnKeyDown(object sender, KeyEventArgs e)
	{
        if (e.KeyCode == Keys.NumPad1)
		{
            Game.Player.SetRunSpeedMultThisFrame(1.00f);
        }
		//2
        else if (e.KeyCode == Keys.NumPad2)
		{
            // Game.Player.WantedLevel += 2;
            Game.Player.WantedLevel = +2;
            UI.Notify("Заказали! +2 звезды");
		}
		//3
        else if (e.KeyCode == Keys.NumPad3)
		{
            Game.Player.WantedLevel = 0;
            UI.Notify("За вас порешали! Ходи спокойно");

		}
		//4
        else if (e.KeyCode == Keys.NumPad4/* && e.Modifiers == Keys.Alt*/)
		{
            /*playerPed.Health = +400;*/
            Game.Player.Character.Health = +400;
            UI.Notify("+400 к здоровью");
		}
		//5
        else if (e.KeyCode == Keys.NumPad5)
		{
            playerPed.Armor = +400;
            UI.Notify("+400 к армору");
		}
		//6
        else if (e.KeyCode == Keys.NumPad6)
		{
            World.Weather = Weather.Blizzard;
            UI.Notify("Ну и метель");
		}
        else if (e.KeyCode == Keys.NumPad7 && e.Modifiers == Keys.Alt)
		{
            World.Weather = Weather.Christmas;
            UI.Notify("Ну и Christmas");
		}
        else if (e.KeyCode == Keys.NumPad8 && e.Modifiers == Keys.Alt)
		{
            World.Weather = Weather.Snowlight;
            UI.Notify("Ну и Snowlight");
		}
        else if (e.KeyCode == Keys.NumPad9 && e.Modifiers == Keys.Alt)
		{
            World.Weather = Weather.Snowing;
            UI.Notify("Ну и Snowing");
		}
		//7
        else if (e.KeyCode == Keys.NumPad7)
		{
            	Ped GUARDS = World.CreatePed("S_M_Y_MIME", new Vector3(playerPed.Position.X+2, playerPed.Position.Y+5, playerPed.Position.Z));
            	GUARDS.Health = 100;
            	GUARDS.Task.FightAgainst(playerPed);
            	UI.Notify("Мим придет за тобой!");
		}
		//8
        else if (e.KeyCode == Keys.NumPad8)
		{
            Ped MIME1 = World.CreatePed("S_M_Y_MIME", new Vector3(playerPed.Position.X+2, playerPed.Position.Y+5, playerPed.Position.Z));
            Ped MIME2 = World.CreatePed("S_M_Y_MIME", new Vector3(playerPed.Position.X+4, playerPed.Position.Y+5, playerPed.Position.Z));
            Ped MIME3 = World.CreatePed("S_M_Y_MIME", new Vector3(playerPed.Position.X+6, playerPed.Position.Y+5, playerPed.Position.Z));
            MIME1.Weapons.Give((WeaponHash)Function.Call<int>(Hash.GET_HASH_KEY, "WEAPON_SMG"), 150,  true, false);
            MIME2.Weapons.Give((WeaponHash)Function.Call<int>(Hash.GET_HASH_KEY, "WEAPON_SMG"), 150,  true, false);
            MIME3.Weapons.Give((WeaponHash)Function.Call<int>(Hash.GET_HASH_KEY, "WEAPON_SMG"), 150,  true, false);
            MIME1.Health = 300;
            MIME2.Health = 300;
            MIME3.Health = 300;
            MIME1.Task.FightAgainst(playerPed);
            MIME2.Task.FightAgainst(playerPed);
            MIME3.Task.FightAgainst(playerPed);
            UI.Notify("Мим придет за тобой!");
		}
	}

	// When you press a key up or release it.
	private void OnKeyUp(object sender, KeyEventArgs e)
	{

	}
}



Хочу связать с кодом №2, чтобы при выполнении условий из второго кода выполнялось действие из первого кода. Это вообще реально? Как объединить эти два кода чтобы он загружался в GTA и работал.

Код №2

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace TestScripts {
    public static class RemoteControl {
        public static bool isActive = false;

        public enum TypeAlert { Follower, Subscriber, Donate, Text, HotKey, Host };
        public enum TypeCondMessage { chance, qty };

        [Flags]
        public enum ModifierKeys : uint {
            None = 0,
            Alt = 1,
            Control = 2,
            Shift = 4,
            Win = 8
        }

        public class RemotePreset {
            // ==== conditions ====
            public int IndPreset = 0;
            public bool Active = false;
            public string Name = "";

            // alert
            public bool isAlertCond = false; // флаг, алерт, в том числе донат
            public TypeAlert Type = TypeAlert.Follower;
            public int ViewerQty = 0;

            public bool isDonate = false;
            public float MinValue = 0;
            public float MaxValue = 0;

            // text
            public bool ConditionText = false;  // флаг, текст
            public bool OnlySubscriber = false;
            public string ChatText = "";
            public TypeCondMessage CondMessage = TypeCondMessage.chance;
            public int Chance = 100;
            public int TextQty = 5;

            // hotkey
            public bool isHotkey = false; // флаг, нажата клавиша
            public ModifierKeys alt1 = ModifierKeys.None;
            public ModifierKeys alt2 = ModifierKeys.None;
            public System.Windows.Forms.Keys KeyHotKey = System.Windows.Forms.Keys.None;

            // ==== result ====
            // key
            public bool ConditionKey = false;
            public string WindowName = "";
            public bool StayPressed = false;
            public ModifierKeys alt = ModifierKeys.None;
            public System.Windows.Forms.Keys Key = System.Windows.Forms.Keys.F1;
            // script
            public bool isScript = false;
            public string Script = "";
            public string ScriptArguments = "";
            // sound
            public bool isSoundFile = false;
            public string SoundFile = "";
            public int SoundVolume = 100;
            // alert
            public bool isAlert = false;
            public string AlertID = "";
            public string AlertName = "";
            // counter
            public bool isCounter = false;
            public int CounterAction = 0;
            public int CounterNumber = 0;
            // run script
            public bool isRunScript = false;
            public string RunScriptName = "";
            public string RunScriptParams = "";
            // run bot command
            public bool isRunBotCommand = false;
            public int IndRunBotCommand = -1;
            // timers
            public bool isTimer = false;
            public int TimerOper = 0;
            public int TimerIndex = 0;
            public DateTime TimerEstimate = new DateTime();
            public bool TimerRunRCPreset = false;
            public int TimerRCPreset = -1;

            // ==== param =======
            public int saveQty = 0;
        }

        public static List<RemotePreset> ListPresets;
    }
}

  • Вопрос задан
  • 98 просмотров
Пригласить эксперта
Ответы на вопрос 1
2chevskii
@2chevskii
Если бы каждый мог в поиск, тостер бы вымер.
Опа, моддеры подьехали.
Я не в курсе, что именно вы используете, но, как правило, во всяких апишках под гта есть функции для эмита событий. Скиньте ссылку на доки, я посмотрю и точно смогу сказать.

UPD. Понял, что это scripthookvdotnet. Смотрите на SHVDN.ScriptDomain. Там можно загрузить другие скрипты. В инстансе CurrentDomain есть лист runningScripts, я предполагаю, что вам нужен он. Дальше там, наверное, придется рефлексию использовать, т.к. я не вижу методов для вызова чего-либо из самих скриптов, но я смотрел код напрямую через гитхаб, мб упустил чего.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы