Code ->
const business = require('./sBusiness');
const misc = require('../sMisc');
const i18n = require('../sI18n');
let weaponShops = {};
function createWeaponShopEntities(id, position) {
let colShape = mp.colshapes.newSphere(position.x, position.y, position.z, 1.0);
colShape.weaponShopID = id;
weaponShops[id] = {
colShape: colShape,
marker: mp.markers.new(1, new mp.Vector3(position.x, position.y, position.z - 2.25), 2.0, {
color: [224, 50, 50, 200]
}),
label: mp.labels.new(`Waffen Shop (${id})`, position,
{
los: true,
font: 4,
drawDistance: 20.0,
color: [255, 255, 255, 255]
}),
blip: mp.blips.new(110, position, {
name: "Waffen Shop",
scale: 1.0,
color: 0,
shortRange: true
})
};
}
function deleteWeaponShopEntities(id) {
if (weaponShops[id]) {
if (weaponShops[id].colShape) weaponShops[id].colShape.destroy();
if (weaponShops[id].marker) weaponShops[id].marker.destroy();
if (weaponShops[id].label) weaponShops[id].label.destroy();
if (weaponShops[id].blip) weaponShops[id].blip.destroy();
}
}
async function loadWeaponShops() {
const d = await misc.query("SELECT * FROM weapon_shops", (e, rows) => {
if (e) {
console.log(`Weapon shop loading failed: ${e.message}`);
} else {
rows.forEach((row) => createWeaponShopEntities(row.ID, new mp.Vector3(row.ShopX, row.ShopY, row.ShopZ)));
console.log(`Loaded ${rows.length} weapon shop(s).`);
}
});
};
loadWeaponShops();
async function createWeaponShop(position) {
return new Promise((resolve, reject) => {
const d = misc.query("INSERT INTO weapon_shops SET ShopX=?, ShopY=?, ShopZ=?", [position.x, position.y, position.z], (e, result) => {
if(e) {
console.log(`Weapon Shop adding failed: ${e.message}`);
reject(e);
} else {
createWeaponShopEntities(result.insertId, position);
resolve(result.insertId);
}
});
});
};
createWeaponShop();
async function deleteWeaponShop(id) {
return new Promise((resolve, reject) => {
const d = misc.query("DELETE FROM weapon_shops WHERE ID=?", [id], (error, result) => {
if(e) {
console.log(`Weapon Shop removing failed: ${e.message}`);
reject(error);
} else {
if(result.affectedRows > 0) {
deleteWeaponShopEntities(id);
delete weaponShops[id];
}
resolve(result.affectedRows);
}
});
});
};
deleteWeaponShop();
Alles anzeigen
Der Fehler ->
ZitatAlles anzeigen
[2018-12-16T21:05:40.254] [ERROR] default - DELETE FROM weapon_shops WHERE ID=?
(node:6184) UnhandledPromiseRejectionWarning: Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1
at Query.Sequence._packetToError (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\protocol\sequences\Sequence.js:47:14)
at Query.ErrorPacket (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\protocol\sequences\Query.js:77:18)
at Protocol._parsePacket (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\protocol\Protocol.js:278:23)
at Parser.write (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\protocol\Parser.js:76:12)
at Protocol.write (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\protocol\Protocol.js:38:16)
at Socket.<anonymous> (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\Connection.js:91:28)
at Socket.<anonymous> (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\Connection.js:502:10)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
--------------------
at Pool.query (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\Pool.js:199:23)
at Promise (C:\Users\Administrator\Desktop\server-files\packages\RP\index.js:1:1304)
at new Promise (<anonymous>)
at Object.dbquery (C:\Users\Administrator\Desktop\server-files\packages\RP\index.js:1:1283)
at Object.query (C:\Users\Administrator\Desktop\server-files\packages\RP\index.js:1:1425)
at Promise (C:\Users\Administrator\Desktop\server-files\packages\RP\index.js:1:100357)
at new Promise (<anonymous>)
at C:\Users\Administrator\Desktop\server-files\packages\RP\index.js:1:100335
at Object.<anonymous> (C:\Users\Administrator\Desktop\server-files\packages\RP\index.js:1:100697)
at n (C:\Users\Administrator\Desktop\server-files\packages\RP\index.js:1:172)
(node:6184) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
[2018-12-16T21:05:40.264] [WARN] default - 'SELECT * FROM weapon_shops' ends with: 1.046s
EMAIL SERVER READY!
Die Lösung?
Kann mir dabei eventuell Jemand helfen? Danke!