Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the 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.
Post Reply
User avatar
Ol1vver
Fighter
Fighter
Posts: 30
Joined: Mon Nov 19, 2018 4:55 pm
SFD Alias: Ol1vver
Started SFD: PreAlpha 1.6
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
Why are you reading my signature?

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

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

Post Reply