猫史档案馆


商店代码来力()()()

用户:这个屑水烨不会写代码这个屑水烨不会写代码查看:6 回复:8 评论:6 创建时间:2023-10-17T20:36:23


如下:

global.sc = world.querySelector('#喵商人');
sc.enableInteract = true; // 允许进行互动
sc.interactRadius = 5;   // 实体的互动范围
sc.interactHint = '喵商人'; // 互动提示框显示实体的名称
sc.interactColor = new GameRGBColor(1,0,1);  // 互动提示的文字颜色

sc.onInteract(async({entity}) => {
    c喵t arms = ['M4A1突击步枪', 'AKM突击步枪', 'H416突击步枪', 'M24狙击枪', 'AX50狙击枪',
                'AR30狙击枪'];
            c喵t money = [ 17600, 57800, 225000, 587000, 630000, 11000]
    c喵t s = await entity.player.dialog({
        
        type: GameDialogType.SELECT,
            title: "喵商人",
            content: `
        
            瞧一瞧看看喽,新鲜出炉的满改M4和G18C,商场价2万1,在我这只需1万块!!!
            哥们你要买什么???市场卖的东西我全都有!!!
        
            `,
            opti喵: ['喵', '装备','子弹和药品','每日礼包','退出互动'],
    }) 
    if (s.index === 0) {
                    c喵t s = await entity.player.dialog({
                        type: GameDialogType.SELECT,
                        content: `你有 ${entity.卢布} 卢布,${entity.道具数} 个道具`,
                        
                        opti喵: arms,
                    })
                    if (s) {
                        c喵t arm = arms[s.index]
                        c喵t ext = money[s.index]
                        if (entity.卢布 >= ext && entity.daoju.length < 25) {
                            entity.卢布 -= ext
                            entity.daoju.push(arm)
                            entity.道具数++
                            entity.player.directMessage(`你已成功购买 ${arm}`)
                        } else if (entity.卢布 < ext) {
                            entity.player.directMessage(`你的卢布不够!想要 ${s.value},共需 ${ext} 卢布,你只有 ${entity.卢布} 卢布`)
                        } else {
                            entity.player.directMessage(`背包空间已满,无法进行购买!`)
                        }
                    } 
    } else if (s.index === 2) {
                    c喵t bull = ['7.62×51 UN子弹', '7.62×51 BPZ子弹', '7.62×51 M80子弹', '7.62×51 M65子弹', '7.62×51 M61子弹',
                        '5.56×56 UN子弹', '5.56×51 FMJ子弹', '5.56×51 M855子弹', '5.56×51 M855A1子弹',
                        '5.56×51 M995子弹', '.300FMJ子弹', '.300PP子弹', '.300AP子弹'
                        , '12.7×99 M2子弹']
                    c喵t bullmoney = [ 24, 48, 156, 250, 24, 48, 156, 250, 500, 1000, 2000, 3000, 1200, 2300]
                    c喵t hosptil = ['标准手术包', '止痛药', '标准军用医疗包', '耐力针']
                    c喵t hosptilmoney = [5000, 8000, 36000, 26000, ];
                    c喵t s = await entity.player.dialog({
                        type: GameDialogType.SELECT,
                        content: `请选择消耗品类型`,
                        opti喵: ['子弹', '药品'],
                    })
                    if (s) {
                        if (s.value == '子弹') {
                            c喵t sa = await entity.player.dialog({
                                type: GameDialogType.SELECT,
                                opti喵: bull,
                            })
                            if (sa) {
                                c喵t bulls = bull[sa.index]
                                c喵t bullmoneys = bullmoney[sa.index]
                                if (entity.卢布 >= bullmoneys && entity.daoju.length < 25) {
                                    entity.卢布 -= bullmoneys
                                    entity.daoju.push(bulls)
                                    entity.道具数++
                                    entity.player.directMessage(`你已成功购买 ${bulls}`)
                                } else if (entity.卢布 < bullmoneys) {
                                    entity.player.directMessage(`你的点券不够!想要 ${sa.value},共需 ${bullmoneys} 卢布,你只有 ${entity.卢布} 卢布`)
                                } else {
                                    entity.player.directMessage(`背包空间已满`)
                                }
                            }
                        } else {
                            c喵t sa = await entity.player.dialog({
                                type: Box3DialogType.SELECT,
                                opti喵: hosptil,
                            })
                            if (sa) {
                                c喵t hosptils = hosptil[sa.index]
                                c喵t hosptilmoneys = hosptilmoney[sa.index]
                                if (entity.卢布 >= hosptilmoneys && entity.daoju.length < 25) {
                                    entity.卢布 -= hosptilmoneys
                                    entity.daoju.push(hosptils)
                                    entity.道具数++
                                    entity.player.directMessage(`你已成功购买 ${hosptils}`)
                                } else if (entity.卢布 < hosptilmoneys) {
                                    entity.player.directMessage(`你的点券不够!想要 ${sa.value},共需 ${hosptilmoneys} 卢布,你只有 ${entity.卢布} 卢布`)
                                } else {
                                    entity.player.directMessage(`背包空间已满`)
                                }
                            }
                        }
                    }
                    else if (s.index == 1) {
                    c喵t head = ['坦克兵防护帽', '老式钢盔', '6B4型头盔', 'IND战术头盔', 'FA突击战术头盔', '03重型头盔', 'SH50军用头盔', 'IND50重型军用头盔', 'IND70战术头盔', 'AS200战术军用头盔']
                    c喵t h_p = [6300, 22600, 67800, 2580000, 5000000, 5500000, 6500000, 7500000, 8500000, 1000000]
                    c喵t heart = ['老式防弹马甲', '220防弹衣', 'KN制式防弹衣', '6B23防弹衣', '926复型防弹衣', 'KN复合防弹衣']
                    c喵t he_p = [6300, 22600, 67800, 2240000, 500000, 7500000]
                    c喵t s = await entity.player.dialog({
                        type: GameDialogType.SELECT,
                        content: '选择头甲类型',
                        title: `头甲`,
                        opti喵: ['头盔', '护甲'],
                    })
                    if (s) {
                        if (s.value == '头盔') {
                            c喵t d = await entity.player.dialog({
                                type: GameDialogType.SELECT,
                                opti喵: head,
                            })
                            if (d) {
                                c喵t hs = head[d.index]
                                c喵t h_pp = h_p[d.index]
                                if (entity.卢布 >= h_pp && entity.daoju.length < 25) {
                                    entity.卢布 -= h_pp
                                    entity.daoju.push(hs)
                                    entity.道具数++
                                    entity.player.directMessage(`你已成功购买 ${hs}`)
                                } else if (entity.卢布 < h_pp) {
                                    entity.player.directMessage(`你的卢布不够!想要 ${d.value},共需 ${h_pp} 卢布,你只有 ${entity.卢布} 卢布`)
                                } else {
                                    entity.player.directMessage(`背包空间已满`)
                                }
                            }
                        } else {
                            c喵t ab = await entity.player.dialog({
                                type: GameDialogType.SELECT,
                                opti喵: heart,
                            })
                            if (ab) {
                                c喵t hes = heart[ab.index]
                                c喵t hos = he_p[ab.index]
                                if (entity.卢布 >= hos && entity.daoju.length < 25) {
                                    entity.卢布 -= hos
                                    entity.daoju.push(hes)
                                    entity.道具数++
                                    entity.player.directMessage(`你已成功购买 ${hes}`)
                                } else if (entity.卢布 < hos) {
                                    entity.player.directMessage(`你的卢布不够!想要 ${ab.value},共需 ${hos} 点券,你只有 ${entity.卢布} 卢布`)
                                } else {
                                    entity.player.directMessage(`背包空间已满`)
                                }
                            }
                        }
                    }
                    }
                    else if (s.index == 3) {
                    c喵t s = await entity.player.dialog({
                        type: "select",
                        title: "礼包",
                        opti喵: ['每日尝鲜礼包(免费)'],
                    })
                    if (s) {
                        if (s.index == 0) {
                            c喵t s = await entity.player.dialog({
                                type: "select",
                                content: "购买后会获得 100000 卢布,确定购买?",

                                opti喵: ['确定', '算了'],
                            })
                            if (s) {
                                if (s.index == 0) {

                                    if (PULLUP.includes(entity.player.userKey)) {
                                        entity.player.directMessage("你今天已经来过了,明天再来吧~")
                                        return
                                    } else {
                                        entity.卢布 += 100000
                                        PULLUP.push(entity.player.userKey)
                                        entity.player.directMessage("恭喜获得 100000 卢布")
                                    }

                                }
                            }
                        }
                    }
                    }
    
    }
    
})

可以修改,不要照抄()()()


回复

上一页1 页 / 共 1下一页
这个屑水烨不会写代码这个屑水烨不会写代码

如果有bug可以指出,我会进行修改()()()

点赞0


评论


NomenNomen

看起来真的很棒!很适合像我这样的萌新

点赞0


评论


fjskdfjslkdfjskdfjslkd

收藏了

点赞0


评论


这个屑水烨不会写代码这个屑水烨不会写代码

这里提示下,文本框那个Game是新编辑器,如果是在旧编辑器的把Game改成Box3

点赞0


评论


yee剑走天下yee剑走天下

说实话太冗余了,对象判断可能更快?emotion_doge

点赞0


评论


KeluoKeluo

谢谢,不修改,直————接抄()()(bushi)

点赞0


评论


𝙲ℴ𝗌𝔦𝒹ₑ𝑟𝙲ℴ𝗌𝔦𝒹ₑ𝑟

中文令名可还行()

卢布用rouble罢

点赞1


评论


𝙲ℴ𝗌𝔦𝒹ₑ𝑟𝙲ℴ𝗌𝔦𝒹ₑ𝑟

语法很熟练

你可以把商品数据以

Record<string,number>

(jsdoc翻译是 Object<string,number>)

键值对形式更好

 

最好储存在全局或者一个作用类里

点赞1


评论