用户:
a_b_c_查看:2 回复:3 评论:2 创建时间:2021-02-22T15:49:01
当玩家‘az’说,“某某&禁言”就让那人禁言的代码怎么写
迷失冷光db.sql`CREATE TABLE IF NOT EXISTS dark(
id VARCHAR(16) NOT NULL,
black INTEGER NOT NULL
)`
world.onPlayerJoin(async({entity})=>{
const rows = await db.sql`SELECT * FROM dark WHERE id = ${entity.player.userKey}`;
if(rows && !rows.length){
if(entity.player.userKey)
db.sql`INSERT INTO dark VALUES(${entity.player.userKey},0)`;
}else if(rows[0].black){
black(entity);
}
})
async function black(entity){
while(true){
await entity.player.dialog({
type: Box3DialogType.TEXT,
title: '系统',
content: '禁言中',
})
}
}
world.onChat(({entity,message})=>{
if(entity.player.name == '你的名字' && message.substring(0,2) == '禁言'){
world.querySelectorAll('player').forEach((e)=>{
if(message.substring(2,message.length) == e.player.name){
if(e.player.userKey)
db.sql`UPDATE dark SET black = 1 WHERE id = ${e.player.userKey}`;
black(e);
}
})
}
})
至于取消懒得写
点赞0
评论