Add drop to Inventory

This commit is contained in:
VegaZ
2018-12-19 20:22:00 +01:00
parent a542409855
commit a04cd81ede
11 changed files with 76 additions and 26 deletions

View File

@@ -25,6 +25,7 @@ var upRColor = 222;
var downRColor = 222;
var leftRColor = 222;
var rightRColor = 222;
var radialDescription;
var inventoryWeight;
var items = [[]];
@@ -210,24 +211,34 @@ mp.events.add("render", () => {
mp.game.graphics.drawSprite("itemimages", "radialdrop", grid[hoverGrid][0], grid[hoverGrid][1], rWidth / aspectRatioFactor, rWidth, 0, 255, 255, 255, 255);
mp.game.graphics.drawSprite("itemimages", "radialuse", grid[hoverGrid][0], grid[hoverGrid][1], rWidth / aspectRatioFactor, rWidth, 0, 255, 255, 255, 255);
}
//--------------------------------------------------------------DEBUG
mp.game.graphics.set2dLayer(7);
mp.game.graphics.drawText(itemRadial.toString() + " ~y~" + radialSelect, [0.5, 0.05], {
font: 7,
color: [255, 0, 0, 255],
scale: [0.7, 0.7],
outline: true,
});
//KOORDINATEN
if (ifMouseSelectRadial(pos[0], pos[1])) {
mp.game.graphics.drawText((pos[0] / screenX).toFixed(3) + " / " + (pos[1] / screenY).toFixed(3), [pos[0] / screenX, pos[1] / screenY - 0.02], {
//mp.game.graphics.drawRect(pos[0] / screenX, pos[1] / screenY - 0.02, 0.08, 0.03, 0, 0, 0, 255);
mp.game.graphics.drawText("~g~" + radialDescription, [pos[0] / screenX, pos[1] / screenY - 0.033], {
font: 4,
color: [255, 255, 255, 255],
scale: [0.4, 0.4],
outline: true,
});
}
//----------------------------------------------------------DEBUG END
////--------------------------------------------------------------DEBUG
//mp.game.graphics.drawText(itemRadial.toString() + " ~y~" + radialSelect, [0.5, 0.05], {
// font: 7,
// color: [255, 0, 0, 255],
// scale: [0.7, 0.7],
// outline: true,
//});
////KOORDINATEN
//if (ifMouseSelectRadial(pos[0], pos[1])) {
// mp.game.graphics.drawText((pos[0] / screenX).toFixed(3) + " / " + (pos[1] / screenY).toFixed(3), [pos[0] / screenX, pos[1] / screenY - 0.02], {
// font: 4,
// color: [255, 255, 255, 255],
// scale: [0.4, 0.4],
// outline: true,
// });
//}
////----------------------------------------------------------DEBUG END
}
if (showAdmin === true) {
var pos = mp.gui.cursor.position;
@@ -453,12 +464,14 @@ function ifMouseSelectRadial(cX2, cY2) {
//OBEN
if (x > grid[hoverGrid][0] - 0.0255 / aspectRatioFactor && x < grid[hoverGrid][0] + 0.0255 / aspectRatioFactor && y < grid[hoverGrid][1] - 0.065 && y > grid[hoverGrid][1] - 0.2) {
radialSelect = "up";
radialDescription = "Wegwerfen";
upRColor = 255;
return true;
}
//UNTEN
else if (x > grid[hoverGrid][0] - 0.0255 / aspectRatioFactor && x < grid[hoverGrid][0] + 0.0255 / aspectRatioFactor && y > grid[hoverGrid][1] + 0.065 && y < grid[hoverGrid][1] + 0.2) {
radialSelect = "down";
radialDescription = "Benutzen / Essen";
downRColor = 255;
return true;
}
@@ -508,8 +521,11 @@ mp.events.add('click', (x, y, upOrDown, leftOrRight, relativeX, relativeY, world
if (isNaN(amount) || amount < 1) {
mp.game.graphics.notify('~r~Du musst eine Zahl größer als 0 eingeben!');
return;
} else if (parseInt(amount) > parseInt(items[clickedItem][3])) {
mp.game.graphics.notify('~r~So viele Items hast du nicht!');
return;
}
mp.events.callRemote('itemInteract', "drop", items[clickedItem][5], amount);
mp.events.callRemote('itemInteract', "drop", items[clickedItem][5], parseInt(amount));
});
itemRadial = false;