在参数列表之后,这次我把它放在哪里?

时间:2016-03-19 14:17:13

标签: javascript

if (typeof scriptLoadedMeowPuff === "undefined") {
var scriptLoadedMeowPuff = true;
var MTYPEWON = 0;

// when a message is recieved in chat...
MPP.client.on("a", (msg) => {
        if (msg.a.indexOf(MPP.client.getOwnParticipant().name + "First person ") !== -1 && msg.p._id === ("903bcaadc5c62dbf197798a0")) {
        MPP.chat.send("msg.p.a".split("First person to type this wins: "))
        }
    }
};
    console.log("%c You already pasted the script, " + MPP.client.getOwnParticipant().name + "!\n\n Refresh and paste the code again to see any changes.", "background: #000; color: #ff3333");
};

2 个答案:

答案 0 :(得分:0)

问题在于MPP.client.on(,您从(开始,但以}结束,并且不需要在if条件之后使用该语句,如果条件,则在父级中执行此操作

if (typeof scriptLoadedMeowPuff === "undefined") {
  var scriptLoadedMeowPuff = true;
  var MTYPEWON = 0;

  // when a message is recieved in chat...
  MPP.client.on("a", (msg) => {
    if (msg.a.indexOf(MPP.client.getOwnParticipant().name + "First person ") !== -1 && msg.p._id === ("903bcaadc5c62dbf197798a0")) {
      MPP.chat.send("msg.p.a".split("First person to type this wins: "));
    }
  });
  console.log("%c You already pasted the script, " + MPP.client.getOwnParticipant().name + "!\n\n Refresh and paste the code again to see any changes.", "background: #000; color: #ff3333");
}

答案 1 :(得分:0)

这应该对你更好:

if (typeof scriptLoadedMeowPuff === "undefined") {
var scriptLoadedMeowPuff = true;
var MTYPEWON = 0;

// when a message is recieved in chat...
MPP.client.on("a", (msg) => {
        if (msg.a.indexOf(MPP.client.getOwnParticipant().name + "First person ") !== -1 && msg.p._id === ("903bcaadc5c62dbf197798a0")) {
        MPP.chat.send("msg.p.a".split("First person to type this wins: "));
        }
    }
);
    console.log("%c You already pasted the script, " + MPP.client.getOwnParticipant().name + "!\n\n Refresh and paste the code again to see any changes.", "background: #000; color: #ff3333");
}

编辑哦,Frayne先到了那儿,好吧。