【求助】在版本更新之后,subdata数据丢失了

[复制链接]
503 |12
温柔的败退 发表于 2024-11-21 15:01:04 | 显示全部楼层 |阅读模式
在没有进行更新,subdata数据是正常的,请问是需要使用version的相关方法吗?该怎么使用呢
回复

使用道具 举报

丸子 发表于 2024-11-21 15:03:20 | 显示全部楼层
是什么更新之后导致subdata数据丢失呢
回复

使用道具 举报

温柔的败退楼主 发表于 2024-11-21 15:05:54 | 显示全部楼层
丸子 发表于 2024-11-21 15:03
是什么更新之后导致subdata数据丢失呢

就是即使不修改脚本,提交游戏更新后,正式发布,就会导致数据丢失
回复

使用道具 举报

温柔的败退楼主 发表于 2024-11-21 15:07:42 | 显示全部楼层


export default class PlayerData extends Subdata {
    @Decorator.persistence()
    skinList: number[] = new Array(20).fill(0);

    @Decorator.persistence()
    skinItemList: number[] = new Array(20).fill(0);

    @Decorator.persistence()
    loginDays: number = 0;

    @Decorator.persistence()
    lastLoginTime: number = 0;

    @Decorator.persistence()
    lastSevenDayCheckInTime: number = 0;

    @Decorator.persistence()
    lastHalloweenCheckInTime: number = 0;

    @Decorator.persistence()
    sevenDayCheckInDays: number = 0;

    @Decorator.persistence()
    halloweenCheckInDays: number = 0;

    @Decorator.persistence()
    diamonds: number = 500;

    @Decorator.persistence()
    isDressingId: string = "";

    // 新增礼物列表变量
    @Decorator.persistence()
    giftList: number[] = new Array(20).fill(0);

    public setIsDressingId(dressId: string): void {
        this.isDressingId = dressId;
        this.save(true);
    }

    public getIsDressingId(): string {
        return this.isDressingId;
    }

    // 增加钻石数量
    public addDiamonds(amount: number): void {
        this.diamonds += amount;
        this.save(true);
    }

    // 减少钻石数量
    public subtractDiamonds(amount: number): void {
        if (this.diamonds >= amount) {
            this.diamonds -= amount;
            this.save(true);
        } else {
            console.error("Not enough diamonds to subtract");
        }
    }

    // 获取当前钻石数量
    public getDiamonds(): number {
        return this.diamonds;
    }

    public addOwnSkin(skinId: number): void {
        console.log(this.skinList);
        this.skinList[skinId - 1] = 1;
        this.save(true);
        console.log(this.skinList);
    }

    public addOwnSkinItem(skinItemId: number): void {
        this.skinItemList[skinItemId - 1] = 1;
        this.save(true);
    }

    // 增加礼物
    public addGift(giftId: number): void {
        this.giftList[giftId] += 1;
        this.save(true);
    }

    public useGift(giftId: number): void {
        this.giftList[giftId] -= 1;
        this.save(true);
    }

    // 获取礼物列表
    public getGiftList(): number[] {
        return this.giftList;
    }
}


回复

使用道具 举报

丸子 发表于 2024-11-21 15:08:18 | 显示全部楼层
温柔的败退 发表于 2024-11-21 15:05
就是即使不修改脚本,提交游戏更新后,正式发布,就会导致数据丢失 ...

看看游戏后台的报错摘要有没有相关的报错
image.png
回复

使用道具 举报

温柔的败退楼主 发表于 2024-11-21 15:12:15 | 显示全部楼层
丸子 发表于 2024-11-21 15:08
看看游戏后台的报错摘要有没有相关的报错

有一些报错,但是好像不是相关的
微信截图_20241121151114.png
回复

使用道具 举报

丸子 发表于 2024-11-21 15:15:12 | 显示全部楼层
你更新版本之后再原有的基础上新加了一些数据是不
回复

使用道具 举报

丸子 发表于 2024-11-21 15:18:31 | 显示全部楼层
回复

使用道具 举报

温柔的败退楼主 发表于 2024-11-21 16:01:00 | 显示全部楼层
丸子 发表于 2024-11-21 15:18
可以看看数据升级的这两篇帖子,参考一下
https://forum.ark.online/forum.php?mod=viewthread&tid=2243&hi ...

谢谢,我研究看一下
回复

使用道具 举报

温柔的败退楼主 发表于 2024-11-27 09:29:28 | 显示全部楼层
丸子 发表于 2024-11-21 15:18
可以看看数据升级的这两篇帖子,参考一下
https://forum.ark.online/forum.php?mod=viewthread&tid=2243&hi ...

大佬,好像还是有些问题。我再多试了试,具体情况是这样的,在退出游戏短时间内再进存档是正常的,但是过段时间再进的话存档是会没有的。不知道是不是房间服务器关闭了会导致这种情况
回复

使用道具 举报

72小时热榜
热门版块
快速回复 返回顶部 返回列表