猫史档案馆


qzhu[

用户:a_b_c_a_b_c_查看:2 回复:3 评论:2 创建时间:2021-02-22T15:49:01


当玩家‘az’说,“某某&禁言”就让那人禁言的代码怎么写


回复

上一页1 页 / 共 1下一页
月下樱花雨_中考退月下樱花雨_中考退

排一下语序谢谢

点赞0


评论


迷失冷光迷失冷光

你禁言的范围是多少,比如在地图内禁/离开地图也禁,或改名了也禁/不改名也禁,或禁多久之类的……

点赞0


评论


迷失冷光迷失冷光

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


评论