Add Inv. sync
This commit is contained in:
@@ -39,6 +39,9 @@ export default function inventory(globalData: GlobalData) {
|
||||
var dragTradeItem = null; //Ob aktuell ein Item aus dem Handelfenster gezogen wird
|
||||
var spriteScaleX = rWidth / 8;
|
||||
var spriteScaleY = rWidth / 8 * aspectRatioFactor;
|
||||
var syncStatus = false; //Synchronisation mit der Datenbank
|
||||
var syncCount = 0; //Wieviele Slots noch gesynced werden müssen
|
||||
var syncDeg = 0;
|
||||
|
||||
var inventoryWeight; //Das aktuelle Inventargewicht, berechnet aus allen Metainfos des items[[]] Array
|
||||
var items = [[]]; //Items aus der Datenbank
|
||||
@@ -181,6 +184,10 @@ export default function inventory(globalData: GlobalData) {
|
||||
items.splice(arrIndex, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("SERVER:INVENTORY_SYNC", () => {
|
||||
syncCount--;
|
||||
});
|
||||
|
||||
mp.events.add("render", () => {
|
||||
@@ -202,6 +209,28 @@ export default function inventory(globalData: GlobalData) {
|
||||
centre: false
|
||||
});
|
||||
|
||||
if (syncCount != 0) {
|
||||
syncDeg += 3;
|
||||
if (syncDeg === 360) syncDeg = 0;
|
||||
|
||||
mp.game.graphics.drawText("~s~synchronisiere ~g~ " + syncCount, [rxC + 0.165, ryC - (rWidth / 1.20) + 0.035], {
|
||||
font: 7,
|
||||
color: [112, 128, 144, 254],
|
||||
scale: [0.4, 0.4],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
mp.game.graphics.drawSprite("itemimages", "refresh", rxC + 0.165, ryC - (rWidth / 1.20) + 0.01, spriteScaleX * 0.4, spriteScaleY * 0.4, syncDeg, 255, 255, 255, 255);
|
||||
} else {
|
||||
mp.game.graphics.drawText("~s~synchronisiert", [rxC + 0.165, ryC - (rWidth / 1.20) + 0.035], {
|
||||
font: 7,
|
||||
color: [112, 128, 144, 254],
|
||||
scale: [0.4, 0.4],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
}
|
||||
|
||||
//SLOTS [RECHTECKE] [SLOTZAHLEN]
|
||||
|
||||
var slots;
|
||||
@@ -882,6 +911,7 @@ export default function inventory(globalData: GlobalData) {
|
||||
items.push([tradeItems[dragItem][0], tradeItems[dragItem][1], tradeItems[dragItem][2], tradeItems[dragItem][3], actFreeSlot.toString(), tradeItems[dragItem][5]]);
|
||||
tradeItems.splice(dragItem, 1);
|
||||
}
|
||||
syncCount++;
|
||||
mp.events.callRemote('saveInventory', JSON.stringify(items));
|
||||
oldDragSlot = null;
|
||||
dragItem = null;
|
||||
@@ -896,6 +926,7 @@ export default function inventory(globalData: GlobalData) {
|
||||
items[stackToItem][3] = newAmount.toString();
|
||||
tradeItems.splice(dragItem, 1);
|
||||
}
|
||||
syncCount++;
|
||||
mp.events.callRemote('saveInventory', JSON.stringify(items));
|
||||
oldDragSlot = null;
|
||||
dragItem = null;
|
||||
@@ -910,6 +941,7 @@ export default function inventory(globalData: GlobalData) {
|
||||
tradeItems[stackToTradeItem][3] = newAmount.toString();
|
||||
tradeItems[dragItem][4] = "-1";
|
||||
}
|
||||
syncCount++;
|
||||
mp.events.callRemote('saveInventory', JSON.stringify(items));
|
||||
oldDragSlot = null;
|
||||
dragItem = null;
|
||||
@@ -921,6 +953,7 @@ export default function inventory(globalData: GlobalData) {
|
||||
} else {
|
||||
tradeItems[dragItem][4] = actFreeTradeSlot;
|
||||
}
|
||||
syncCount++;
|
||||
mp.events.callRemote('saveInventory', JSON.stringify(items));
|
||||
oldDragSlot = null;
|
||||
dragItem = null;
|
||||
@@ -983,6 +1016,7 @@ export default function inventory(globalData: GlobalData) {
|
||||
tradeItems.splice(hoverItem, 1);
|
||||
}
|
||||
}
|
||||
syncCount++;
|
||||
mp.events.callRemote('saveInventory', JSON.stringify(items));
|
||||
oldDragSlot = null;
|
||||
dragItem = null;
|
||||
@@ -998,6 +1032,7 @@ export default function inventory(globalData: GlobalData) {
|
||||
tradeItems.splice(hoverItem, 1);
|
||||
}
|
||||
}
|
||||
syncCount++;
|
||||
mp.events.callRemote('saveInventory', JSON.stringify(items));
|
||||
bufferItem = null;
|
||||
dragItem = null;
|
||||
@@ -1014,6 +1049,7 @@ export default function inventory(globalData: GlobalData) {
|
||||
tradeItems[hoverItem][4] = "-1";
|
||||
}
|
||||
}
|
||||
syncCount++;
|
||||
mp.events.callRemote('saveInventory', JSON.stringify(items));
|
||||
oldDragSlot = null;
|
||||
bufferItem = null;
|
||||
@@ -1031,6 +1067,7 @@ export default function inventory(globalData: GlobalData) {
|
||||
tradeItems[hoverItem][4] = "-1";
|
||||
}
|
||||
}
|
||||
syncCount++;
|
||||
mp.events.callRemote('saveInventory', JSON.stringify(items));
|
||||
oldDragSlot = null;
|
||||
dragItem = null;
|
||||
|
||||
Reference in New Issue
Block a user