Page 1 of 1

How to when to use a specific command to activate a trigger automatically

Posted: Sun Jun 14, 2020 1:56 am
by Kevi
:( I couldn't do that, if a player used a specific command to activate a specific trigger, can you help me?

Re: How to when to use a specific command to activate a trigger automatically

Posted: Sun Jun 14, 2020 12:01 pm
by Odex64

Code: Select all

public void OnStartup()
{
    Events.UserMessageCallback.Start(Commands);
}

public void Commands(UserMessageCallbackArgs cmds)
{
    if (cmds.IsCommand && cmds.User.IsModerator)
    {
        switch (cmds.Command)
        {
            case "EXPLOSION": //NAME OF THE COMMAND
                ((IObjectTrigger) Game.GetSingleObjectByCustomId("exp")).Trigger(); //USE THIS TO ACTIVATE 1 TRIGGER
                break;

            case "SPAWN":
                foreach(IObjectTrigger spwn in Game.GetObjectsByCustomId("spawn")) //USE THIS TO ACTIVATE MULTIPLE TRIGGERS
                	spwn.Trigger();
                break;
        }
    }
}
Here's the script. Just change the command name and the CustomId inside the marks. (also remember to assign the same id to the trigger you want to activate).