This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

[Request] In-Game Commands Script

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Locked
User avatar
Ol1vver
Superfighter
Superfighter
Posts: 69
Joined: Mon Nov 19, 2018 4:55 pm
SFD Account: olv
SFD Alias: olv
Started SFD: PreAlpha 1.6.4
Gender:

[Request] In-Game Commands Script

Post by Ol1vver » Tue Dec 11, 2018 6:12 pm

Hello,
Can anyone make a script with commands?
I want to include this in my map for debugging purposes.
Commands example:

/rfskip [Activates ScriptTrigger with ID "SkipTrigger"
/rfspawn [0/1] - If 0, activates ScriptTrigger with ID "SpawnOFF"; if 1, activates ScriptTrigger with ID "SpawnON".)

Optional:
/rfdebug [0/1] - Turns on debug mode, which enables commands (sets debugMode to false/true)
Off Topic
I didn't really know how to write this properly, so this is the result.
0 x

User avatar
ebomb09
Fighter
Fighter
Posts: 13
Joined: Mon Apr 30, 2018 5:04 am
SFD Account: ebomb09
Location: Canada/BC
Age: 24

Post by ebomb09 » Wed Dec 12, 2018 6:36 am

Code: Select all

static bool debugMode = false;

Events.UserMessageCallback m_userMessageCallback = null;

public void OnStartup(){
m_userMessageCallback = Events.UserMessageCallback.Start(OnUserMessage);

}

public void OnUserMessage(UserMessageCallbackArgs args){
	if(args.IsCommand){
		switch(args.Command){
			case "RFDEBUG":{
				if(args.CommandArguments == "0"){
					debugMode = false;
					Game.RunCommand("/msg DebugMode Off");
				}
				if (args.CommandArguments == "1"){
					debugMode = true;
					Game.RunCommand("/msg DebugMode On");
				}
					
			break;
			}
			case "RFSKIP":
				if(debugMode){
					(Game.GetSingleObjectByCustomID("SkipTrigger") as IObjectScriptTrigger).Trigger();
				}
			break;
			case "RFSPAWN":
				if(debugMode){
					if(args.CommandArguments == "0"){
						(Game.GetSingleObjectByCustomID("SpawnOFF") as IObjectScriptTrigger).Trigger();
					}
					if (args.CommandArguments == "1"){
						(Game.GetSingleObjectByCustomID("SpawnON") as IObjectScriptTrigger).Trigger();
					}
				}
			break;
		}
	}
}
2 x

Locked