Lv.1
电磁炮与米库私斋
在 pvp的代码是什么啊,急求 中回复
是点击会伤害吗?
// 利用点击事件对点中的实体造成伤害
world.onClick(({ entity, clicker }) => { //entity是被点击的实体, clicker是点击了这个实体的玩家
if (entity.isPlayer) { //如果被点击的是个玩家实体
world.say(`${clicker.player.name} 击中 ${entity.player.name}`) //显示玩家的名字
} else {
world.say(`${clicker.player.name} 击中 ${entity.id}`) //显示实体的id
}
entity.hurt(20)
})2023-02-09T18:34:08 点赞:0
在 【求助】有大佬会做私聊吗 中回复
私聊类型:
async function chats(entity, other, text) {
other.player.directMessage('收到一条私信')
const has = await other.player.dialog({
type: Box3DialogType.SELECT,
title: "私聊",
titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
content: `${entity.player.name}:\n${text}`,
options: ['回复', '取消'],
});
if (!has || has === null) {
entity.player.directMessage('你被TA无视了');
return;
}
if (has.value === '回复') {
entity.player.directMessage('对方收到了你的私信')
const returns = await other.player.dialog({
type: Box3DialogType.INPUT,
title: "私聊-回复",
titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
content: `${other.player.name},请输入回复内容`,
confirmText: '发送',
placeholder: '输入回复内容',
});
if (!returns || returns === null) {
return;
}
chats(other, entity, returns)
}
else if (has.value === '取消') {
entity.player.directMessage('对方收到了你的私信')
}
}
world.onPlayerJoin(({ entity }) => {
entity.player.interactTimes = 0;
entity.enableInteract = true;
entity.interactRadius = 1.5;
entity.interactHint = '互动';
entity.onInteract(async ({ entity, targetEntity }) => {
targetEntity.player.directMessage('你被 ' + entity.player.name + ' 访问了')
while (!entity.destroyed) {
const others = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: targetEntity.player.name + ' 的信息',
titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
content: `可以自行更改此段文字`,
options: ['和TA私聊'],
})
if (!others || others === null) {
return;
}
if (others.value == '和TA私聊') {
const chating = await entity.player.dialog({
type: Box3DialogType.INPUT,
title: "私聊",
titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
content: `${entity.player.name},请输入私聊内容`,
confirmText: '发送',
placeholder: '输入私聊内容',
});
if (!chating || chating === null) {
return;
}
chats(entity, targetEntity, chating)
}
}
})
})
信箱类型:(需要将模型加一个标签)
db.sql`CREATE TABLE IF NOT EXISTS advice(
title TEXT NOT NULL
)`//创建一个数据库表格,并填入title字段
world.querySelectorAll('.信箱').forEach((e)=>{//加入一个模型,并加上一个名为“信箱”的标签
e.enableInteract = true;
e.interactRadius = 3;
e.interactHint = '信箱';//互动选项
e.onInteract(async({entity})=>{
const rows = await db.sql`SELECT * FROM advice`;
let title = '';
for(let i in rows){
title += rows[i].title + '\n';
}//遍历表格并取出字段排好
const result = await entity.player.dialog({
type: Box3DialogType.INPUT,
title: '信箱',
content: title,
placeholder: '输入你想说的话',
})
if(result != null){
db.sql`INSERT INTO advice VALUES(${entity.player.name + ':' + result})`;//插入新字段
entity.player.dialog({
type: Box3DialogType.TEXT,
title: '信箱',
content: '发布成功',
})
}
})
重启地图:
我觉得可能会用到,不代表一定要
world.onChat(({entity,message})=>{
if (message=='重启地图'&&admin.includes(entity.player.name)) {
while(1){world.say("正在重启,可能会卡顿......")}
}
if (message=='重启服务器'&&admin.includes(entity.player.name)) {
db.sql([""],"")
}
})
还可以加入:
这个可以不让玩家重启的代码
var admin = ['你的名字','管喵'] //把自己的名字和合作者的名字放入2023-02-10T14:14:36 点赞:0
在 【神器代码岛求助】新的那个建模器怎么打开 中回复
这需要看你用的是手机还是电脑:
如是手机,打开可以关闭广告的浏览器(如Microsoft edge)
如为电脑,可以检查此网页,点击检查页面左上角的鼠标,拖动鼠标到浏览页面黑色部分,会看见一条蓝色的代码,点击此代码,按下delet键,最后按下Enter,就能进入了
(里面足足有10个bug,你要尝试就是吧)()()()()()()()()()()()
![]()
2023-05-18T10:58:11 点赞:0