猫史档案馆


【神奇代码岛】管理系统

用户:屑JOJO屑JOJO查看:0 回复:1 评论:0 创建时间:2022-11-30T13:02:56


是一个一个屑系统啦(

world.onPlayerJoin(({ entity }) => {
    entity.addTag(entity.player.name);
});
world.onPlayerLeave(({ entity }) => {
    entity.removeTag;
});
function find(tag) {//find功能
    return world.querySelector('.' + tag);
}
const admin = []//填自己boxId
world.onPress(async ({ entity, button }) => {
    const admin_protect = [];//填自己boxId
    for (let i = 0; i < 3; i++) {
        if (admin[i] != admin_protect[i]) admin[i] = admin_protect[i];
    }
    if (entity.player.walkState == Box喵layerWalkState.CROUCH && button == Box3ButtonType.JUMP && admin.includes(entity.player.boxId)) {
        //上面的是下蹲加跳跃开启方便型管理终端
        var ctrl = ['管理玩家', '控制台'];
        const result = await entity.player.dialog({
            type: Box3DialogType.SELECT,
            title: "管喵终端",
            titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
            titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
            contentTextColor: new Box3RGBAColor(0, 0, 0, 1),
            contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1),
            content: `你好管喵${entity.player.name}!`,
            options: ctrl,
        });
        if (!result || result === null) {
            return;
        }
        if (ctrl[result.index] == '管理玩家') {
            let namelist = [], cz = ['禁言', '踢', '跟踪', '解除禁言'];
            if (!admin.includes(entity.player.boxId)) {
                entity.player.dialog({
                    type: 'text',
                    content: `玩家${entity.player.name},你没有权限`
                })
                return;
            }
            world.querySelectorAll('player').forEach((e) => {
                if (e.isPlayer) namelist.push(e.player.name);
            });
            //for(let i in namelist) world.say(namelist[i])
            const result = await entity.player.dialog({
                type: Box3DialogType.SELECT,
                title: "管理玩家",
                titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
                titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
                contentTextColor: new Box3RGBAColor(0, 0, 0, 1),
                contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1),
                content: `你好管喵${entity.player.name}!`,
                options: namelist,
            });
            //如果玩家点击了屏幕其他区域,取消了对话框。
            if (!result || result === null) {
                return;
            }
            try {
                const r = await entity.player.dialog({
                    type: Box3DialogType.SELECT,
                    title: "管理玩家",
                    titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
                    titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
                    contentTextColor: new Box3RGBAColor(0, 0, 0, 1),
                    contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1),
                    content: `你好管喵${entity.player.name}!`,
                    options: cz,
                });
                if (!r || r === null) {
                    return;
                }
                world.querySelectorAll('player').forEach(async (p) => {
                    if (p.player.name == namelist[result.index]) {
                        if (cz[r.index] == '跟踪') entity.player.cameraEntity = p;
                        else if (cz[r.index] == '踢' && !admin.includes(p.player.boxId)) p.player.kick();
                        else if (cz[r.index] == '禁言' && !admin.includes(p.player.boxId)) p.player.muted = true;
                        else if (cz[r.index] == '解除禁言') p.player.muted = false;
                        else { world.say('不能操作管喵qwq~'); return; }
                        world.say(`管喵${entity.player.name}对玩家${p.player.name}进行了操作:` + cz[r.index]);
                    }
                });
            }
            catch (err) { world.say('<~ ' + err); }

        }
        else if (ctrl[result.index] == '控制台') {
            const result = await entity.player.dialog({
                title: '控制台',
                type: Box3DialogType.INPUT,
                content: ``,
                titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
                placeholder: '请输入指令',
                confirmText: '确认',
            })
            try {
                world.say('<~' + eval(result));
            } catch (err) {
                world.say('<~ ' + err);
            }

        }

        

    }
});
//下面是直接说代码内个
world.onChat(async ({ entity, message }) => {
    if (message.indexOf('$') == 0 && admin.includes(entity.player.boxId)) {
        try {
            world.say('<~ ' + eval(message.slice(1)));
        } catch (err) {
            world.say('<~ ' + err);
        }
    }
});


回复

上一页1 页 / 共 1下一页
整活的网友整活的网友

好厉害

点赞0


评论