猫史档案馆


【box3】玩家查询系统代码分享!

用户:YDS尹子YDS尹子查看:31 回复:44 评论:31 创建时间:2020-08-09T17:13:39


 

center_image

//nc=n c

world.querySelectorAll(".findAdmin").forEach((finder) => {


    finder.enableInteract = true; 
    finder.interactRadius = 8;  
    finder.interactHint = "玩家查找器";
    finder.interactColor = new Box3RGBColor(1, 1, 1); 
    finder.onInteract(async ({ entity }) => {
        const result = await entity.player.dialog({
            title: '系统',
            type: Box3DialogType.INPUT, 
            content: `全局玩家查询系统开启,你要查询哪个玩家?`,
            titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
            placeholder: '请输入玩家名', 
            confirmText: '确认',
        })
        const findee = world.querySelector("." + result);

        const resu=await entity.player.dialog({
            title: '系统',
            type: Box3DialogType.SELECT,
            content: `找到玩家${findee.player.name}`,
            titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
            lookEye: entity,
            lookEyeOffset: new Box3Vector3(0, 30, 0),
            lookTarget: findee,
            options:["到他那里去","知道了"],
        })
        
        if(resu.index==0){
            entity.position.set(findee.position.x,findee.position.y+2,findee.position.z)
        }
        findee.player.dialog({
            title: '系统',
            type: Box3DialogType.TEXT,
            content: `你被${entity.player.name}查询了`,
            titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
        })
    })
})


回复

上一页1 页 / 共 2下一页
亿只懒Ink亿只懒Ink

沙发(?)

点赞0


评论


空空空空空空空空空空空空

怎么用啊?

点赞0


评论


IDF哲宇MIKEIDF哲宇MIKE

咋用?

点赞0


评论


YDS尹子YDS尹子

先添加一个模型并加上标签findAdmin

点赞1


评论


小小瓢虫小小瓢虫

666666666

点赞0


评论


Architect_皮卡awaArchitect_皮卡awa

emotion_编程猫_点赞

点赞0


评论


月yueyue月yueyue

https://box3create.cod喵/games/bcb6f73733372b724865

点赞0


评论


凌_墨水凌_墨水

emotion_编程猫_紧张emotion_编程猫_加油

点赞0


评论


指令者指令者

emotion_编程猫_加油

点赞0


评论


BCM月见草BCM月见草

emotion_编程猫_点赞

点赞0


评论


Vicent轩Vicent轩

伊子nnnnnnnnb!

点赞0


评论


阳光的流熔怪Uyt5阳光的流熔怪Uyt5

az

点赞0


评论


代号曦机代号曦机

emotion_编程猫_点赞

点赞0


评论


BZS编程球球BZS编程球球

尹子NB!

点赞1


评论


YDS尹子YDS尹子

还有一段代码要添上

world.onPlayerJoin(({entity})=>{entity.a喵Tag(entity.player.name)})

点赞0


评论


老葵老葵

emotion_编程猫_点赞emotion_编程猫_加油

点赞0


评论


未命名用户015734未命名用户015734

dd

点赞0


评论


陆奕博Max陆奕博Max

前几天不是纪念他吗?(滑稽)

点赞1


评论


QBZ_QBZ_

emotion_编程猫_点赞

点赞0


评论


两个小八路小号两个小八路小号

emotion_编程猫_加油

点赞0


评论


幻想一笑而过幻想一笑而过

dd

点赞0


评论


GZ006GZ006

查询不到玩家时会报错!

点赞0


评论


AbnormalLOGAbnormalLOG

   

点赞0


评论


AbnormalLOGAbnormalLOG

world.onPlayerJoin(({entity})=>{entity.addTag(entity.player.name)})
world.querySelectorAll(".玩家查找器").forEach((finder) => {
    finder.enableInteract = true; 
    finder.interactRadius = 8;  
    finder.interactHint = "玩家查找器";
    finder.interactColor = new Box3RGBColor(1, 1, 1); 
    finder.onInteract(async ({ entity }) => {
        const result = await entity.player.dialog({
            title: '系统',
            type: Box3DialogType.INPUT, 
            content: `全局玩家查询系统开启,你要查询哪个玩家?`,
            titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
            placeholder: '请输入玩家名', 
            confirmText: '确认',
        })
        const findee = world.querySelector("." + result);
        try {
            if (findee.isPlayer) {
                const resu=await entity.player.dialog({
                    title: '系统',
                    type: Box3DialogType.SELECT,
                    content: `找到玩家${findee.player.name}`,
                    titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
                    lookEye: entity,
                    lookEyeOffset: new Box3Vector3(0, 30, 0),
                    lookTarget: findee,
                    options:["到他那里去","知道了"],
                })
                
                if(resu.index==0){
                    entity.position.set(findee.position.x,findee.position.y+2,findee.position.z)
                }
                findee.player.dialog({
                    title: '系统',
                    type: Box3DialogType.TEXT,
                    content: `你被${entity.player.name}查询了`,
                    titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
                })
            }
        } catch(err) {
            await entity.player.dialog({
                type:Box3DialogType.TEXT,
                title:'找不到这个玩家!',
                content:'无法查找此玩家'
            })
        }
    })
})

改版代码,不会出错

点赞0


评论


害羞的独角蛛907害羞的独角蛛907

能不能改一下,所有在线玩家都可以通过选择来查询,不用输入用户名?

点赞0


评论


IaeaIaea

666

点赞1


评论


小小瓢虫小小瓢虫

挖出这个非常nb的帖子emotion_doge

点赞1


评论


Summer橘子喵Summer橘子喵

emotion_编程猫_点赞

点赞0


评论


薹灣解放再改名薹灣解放再改名

这挖坟多是一件美逝啊

点赞0


评论


坦率的血翼蝠5801坦率的血翼蝠5801

dddddddddddddddddddddd

点赞0


评论