用户:yee剑走天下查看:312 回复:7 评论:12 创建时间:2023-07-14T22:47:11

求助大佬()为什么SQL报错)(
用的是新版SQL()原本用的var storage.getDataStorage('player'),完全没有问题
但是转念一想这样可能会读取到其他玩家的数据,所以改了一些代码()
console.clear();
const admin = ['AlhambraMemories']
const INIT = {
money: 100,
lv: 0,
exp: 0
};
function initPlayer(entity) {
for (let i in INIT) {
entity[i] = INIT[i];
}
};
function getPlayerData(entity) {
var data = { "name": entity.player.name };
for (let i in INIT) {
data[i] = entity[i]
};
return data;
}
async function savePlayer(entity) {
await entity.dataBase.set(entity.player.userKey, getPlayerData(entity));
};
async function loadPlayer(entity) {
var datas = await entity.dataBase.get(entity.player.userKey);
if (datas) {
for (let i in datas.value) {
entity[i] = datas.value[i]
}
} else {
initPlayer(entity);
entity.player.directMessage('已为您创建数据!');
await entity.dataBase.set(entity.player.userKey, getPlayerData(entity))
}
};
world.onPlayerJoin(async ({ entity }) => {
entity.dataBase = await storage.getDataStorage(entity.player.userKey);
await loadPlayer(entity);
})
world.onPlayerLeave(async ({ entity }) => {
await savePlayer(entity)
})
world.onPress(async ({ entity, button }) => {
if (button == GameButtonType.ACTION1) {
const ask = await entity.player.dialog({
type: 'select',
title: '测试',
content: `你目前[${entity.lv}]级\n[${entity.exp}]点经验\n[${entity.money}]枚金币`,
options: ['点我加等级', '点我加经验', '点我加金币']
});
if (!ask) return;
if (ask) {
entity[['lv', 'exp', 'money'][ask.index]]++;
}
}
});
world.onChat(({ entity, message }) => {
if (message[0] == '$' && admin.includes(entity.player.name)) {
try {
world.say(`<~ ${eval(message.slice(1))}`)
} catch (error) {
world.say(`<~ ${error}`)
}
}
})
求教大佬问题()
西里斯_隆巴顿别装了好不好()你是不是知道新编辑器没有SQL()()
点赞0
评论
?什么意思
你不知道但实际存在的多了去了 包括pro的sql
有的()是你不知道()()官方没出api而已()
感谢大佬()()随便捉()
FML饭米粒这个不晓得)你是咋触发的?用eval或者console貌似不能调用哎
点赞0
评论
啥也没弄()一运行就这样(
貌似玩家userKey是带符号和数字的,然后表名不允许符号
可以试试用userId?
https://shequ.codemao.cn/wiki/forum/551064()那个我修好了()模板也出了()()