關於V113 NPC傳送地圖的問題[已解決]
本帖最後由 a6170830 於 2019-10-26 19:30 編輯我現在用一個npc 2000做一個萬能NPC,第一個想要做傳送地圖功能,想法是較另一個npc 2001來當地圖傳送員如下:
importPackage(Packages.client);
var status = -1;
var options = ["傳送地圖"];
var name = "113私服";
function start() {
action(1,0,0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0 && status == 0) {
cm.dispose();
return;
}
if (mode == 1) {
status++;
} else {
status--;
}
if (status == 0) {
var msg = "親愛的 [" + cm.getPlayer().getName() + "] 你好,我是 #d" + name + "萬能NPC\r\n#b";
for (var i = 0; i < options.length; i++) {
msg += "\r\n#L" + i + "#" + options;
}
cm.sendOk(msg);
} else if (status == 1) {
switch(selection){
case 0://(地圖傳送)
cm.dispose();
cm.openNpc(2001);
break;
}
cm.dispose();
}
}
}
接著是npc 2001的JS:
importPackage(Packages.client);
var status = -1;
var mapname = ["回到自由"];
var name = "113私服";
function start() {
action1(1,0,0);
}
function action1(mode, type, selection) {
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0 && status == 0) {
cm.dispose();
return;
}
if (mode == 1) {
status++;
} else {
status--;
}
if (status == 0) {
var msg = "親愛的 [" + cm.getPlayer().getName() + "] 你好,我是 #d" + name + "地圖傳送員\r\n#b";
for (var i = 0; i < mapname.length; i++) {
msg += "\r\n#L" + i + "#" + mapname;
}
cm.sendOk(msg);
} else if (status == 1) {
switch(selection){
case 0:
cm.dispose();
cm.warp(910000000);
break;
}
cm.dispose();
}
}
}
有試過如果點傳送地圖直接寫cm.warp(910000000)是可以傳到自由的,但是分成兩個npc就無法傳送,請問這個要怎麼解決?
---
解決方法:2000.js openNpc後面break改成return
https://discord.gg/nvr3GVE
我dc 本帖最後由 a6170830 於 2019-10-26 17:07 編輯
洋洋技術 發表於 2019-10-26 16:40 static/image/common/back.gif
https://discord.gg/nvr3GVE
我dc
您好~我有私你了哦 importPackage(Packages.client);
var status = -1;
var options = ["傳送地圖"];
var name = "113私服";
function start() {
action(1,0,0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0 && status == 0) {
cm.dispose();
return;
}
if (mode == 1) {
status++;
} else {
status--;
}
if (status == 0) {
var msg = "親愛的 [" + cm.getPlayer().getName() + "] 你好,我是 #d" + name + "萬能NPC\r\n#b";
for (var i = 0; i < options.length; i++) {
msg += "\r\n#L" + i + "#" + options;
}
cm.sendOk(msg);
} else if (status == 1) {
switch(selection){
case 0://(地圖傳送)
cm.dispose();
cm.openNpc(2001);
break;
}
cm.dispose();
}
}
}
最後一個cm.dispose(); 刪除就OK 財神爺 發表於 2019-10-26 18:46 static/image/common/back.gif
importPackage(Packages.client);
var status = -1;
var options = ["傳送地圖"];
謝謝你
我是把break改成return就解決了~
頁:
[1]