用户:小蛇749查看:11 回复:3 评论:11 创建时间:2022-08-25T13:31:55
直接上代码:(entity.S1是变量)let sq=[];let a=[];async function savePlayer(entity) { if(entity.player.userKey){ for(let q=0;q<=a.length;q++){ if(a[q]==entity.player.userKey){ sq[q]=entity.S1; } } }}async function loadPlayer(entity) { if(entity.player.userKey){ if(a.includes(entity.player.userKey)){ for(let p=0;p<=a.length;p++){ if(a[p]==entity.player.userKey){ entity.S1=sq[p]; } } } else { a.push(entity.player.userKey) sq.push(0) } }}world.onPlayerJoin(async ({ entity }) => { entity.S1 = 0; loadPlayer(entity)})world.onPlayerLeave(async ({ entity }) => { savePlayer(entity)})world.onPress(async ({ button, entity }) => { if (button == Box3ButtonType.ACTION1) { const mais = await entity.player.dialog({ type: 'select', content: `你有${entity.S1}积分,你想干什么`, options: ['存档', '点错了'] }) if (mais) { if (mais.value === '存档') { savePlayer(entity) entity.player.directMessage(`存档成功!`); } } }}) 再也不用考虑数据库啦 imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%97%A8%E8%B5%B7%E6%9D%A5.gif"alt="emotion_编程猫_嗨起来"注:创作端重新运行数据会清零如果有问题就告诉我~