猫史档案馆


[教程]如何做管喵兑换码?

用户:./'./'查看:4 回复:4 评论:4 创建时间:2021-07-20T11:06:49


你是不是因太多人要加入管喵而烦恼?

是不是很想做出管喵的兑换码?

首届贴——管喵兑换码,来啦!

tips:本帖教程适合拥有编辑器的岛民

1.存档管喵列表

这两段都要复制哟

async function insertLeaderboard(userKey,item) {//插入数据
    try {
        await db.sql`INSERT INTO player VALUES (${userKey}, ${item})`;
    } catch (e) {
        console.log(`insert sql error: ${e}`) ;
    }
}
world.onPlayerJoin(async({entity})=>{
    const rows = await db.sql`SELECT * FROM player WHERE userKey=${entity.player.userKey} ORDER BY die ASC LIMIT 1`; 
    if (rows && !rows.length) {retrun}
    if (!rows[0]){
        insertLeaderboard(entity.player.userKey, JSON.stringify(item))
    }else{
        item = JSON.parse(rows[0].item)
    }
})

2.管喵其他方法

world.onPress(async({ button,entity }) => {
    if(button === Box3ButtonType.ACTION1){
        const text = await entity.player.dialog({
            type: Box3DialogType.INPUT,
            title: "管喵系统",
            content: "请输入管喵兑换码",
            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), // 对话框背景颜色。
        })
        if(text){
            if(text === "QSTING88喵22"){
                TEXT(entity,"恭喜成功成为管喵!")
                entity.item.push(entity.player.userKey)
            }
            else{
                TEXT(entity,`您输入的${text}不是兑换码`)
            }
        }
    }
})

3.读取数据

这步发回帖,不露面emotion_doge

 

 


回复

上一页1 页 / 共 1下一页
稚兔丸稚兔丸

我我我

 

点赞0


评论


Architect_皮卡awaArchitect_皮卡awa

emotion_doge

点赞0


评论


./'./'

声明一下:

TEXT()是个函数,是一个对话框函数,这个不要加

点赞0


评论


某人某某人某

!牛

点赞0


评论