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

Share questions, scripts and tutorials related to the ScriptAPI in SFD.
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
Kevi
Meatbag
Posts: 3
Joined: Thu Jun 11, 2020 3:36 am
Title: Kevi
SFD Account: KeviBR
Gender:
Age: 16

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

Post by Kevi » Sun Jun 14, 2020 1:56 am

:( I couldn't do that, if a player used a specific command to activate a specific trigger, can you help me?
0 x
Hi, I can't speak much English, I live in Brazil and ... yes, that's it, and I like the letter "comic sans" , and map maker :geek:

User avatar
Odex64
Superfighter
Superfighter
Posts: 172
Joined: Sat Jul 29, 2017 12:39 pm
Title: Content Creator
SFD Account: Odex64
Started SFD: PreAlpha
Location: Italy
Gender:
Age: 22

Post by Odex64 » Sun Jun 14, 2020 12:01 pm

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).
2 x
Image

Post Reply