Finish interaction on items

This commit is contained in:
VegaZ
2018-12-18 23:22:27 +01:00
parent 0fa58ca680
commit f9e488b329
2 changed files with 62 additions and 21 deletions

View File

@@ -107,16 +107,10 @@ mp.events.add("removeItem", (userItemId, amount) => {
arrIndex = i;
}
}
if (amount === "stack") {
items[arrIndex][4] = "-1";
inventoryWeight -= parseInt(items[arrIndex][2]) * parseInt(items[arrIndex][3]);
inventoryWeight -= parseInt(items[arrIndex][2]) * parseInt(items[arrIndex][3]);
items[arrIndex][3] -= amount;
if (items[arrIndex][3] === 0) {
items.splice(arrIndex, 1);
} else if (amount === "one") {
items[arrIndex][3]--;
inventoryWeight -= items[arrIndex][2];
if (items[arrIndex][3] === 0) {
items.splice(arrIndex, 1);
}
}
}
});
@@ -479,7 +473,7 @@ function ifMouseSelectRadial(cX2, cY2) {
// radialSelect = "right";
// rightRColor = 255;
// return true;
//} else {
else {
upRColor = 222;
downRColor = 222;
leftRColor = 222;
@@ -496,7 +490,7 @@ mp.events.add('click', (x, y, upOrDown, leftOrRight, relativeX, relativeY, world
if (show) {
//LINKE MAUSTASTE
//RUNTER
if (upOrDown === "down" && leftOrRight === "left" && mouseLDown === false && mouseRDown === false && itemRadial === false) {
if (upOrDown === "down" && leftOrRight === "left" && mouseLDown === false && mouseRDown === false) {
mouseLDown = true;
@@ -504,26 +498,24 @@ mp.events.add('click', (x, y, upOrDown, leftOrRight, relativeX, relativeY, world
dragItem = hoverItem;
oldDragSlot = items[dragItem][4];
items[dragItem][4] = "-1";
} else if (ifMouseSelectRadial(x, y) && dragItem === null) {
} else if (ifMouseSelectRadial(x, y)) {
switch (radialSelect) {
case "up":
var dropInput = new InputHelper("Wie viel Items möchtest du wegwerfen?");
dropInput.show();
dropInput.getValue((data) => {
var amount = parseInt(data);
if (isNaN(amount)) {
mp.game.graphics.notify('~r~Du musst eine Nummer eingeben!');
if (isNaN(amount) || amount < 1) {
mp.game.graphics.notify('~r~Du musst eine Zahl größer als 0 eingeben!');
return;
}
mp.events.callRemote('itemInteract', "drop", items[clickedItem][5], amount);
items[clickedItem][3] -= amount;
});
itemRadial = false;
break;
case "down":
mp.events.callRemote('itemInteract', "use", items[clickedItem][5], 1);
items[clickedItem][3]--;
itemRadial = false;
break;
case "left":