Added many things I can't recall but it has to do with inventory system and some minor fixes .. it's cool
This commit is contained in:
@@ -184,22 +184,22 @@ function addToInvenotry(addItem) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cloneItem.currentWeight * cloneItem.amount + weightInv >= 25) {
|
||||
if (cloneItem.currentWeight * cloneItem.amount + weightInv >= 45) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Adds item to inventory
|
||||
for (var i = 0; i < playerInventory.length; i++) {
|
||||
if (unfininshedStack != undefined) {
|
||||
if (playerInventory[unfininshedStack].amount + cloneItem.amount <= 99) {
|
||||
if (playerInventory[unfininshedStack].amount + cloneItem.amount <= 10) {
|
||||
playerInventory[unfininshedStack].amount += cloneItem.amount;
|
||||
unfininshedStack = undefined;
|
||||
drawToPage();
|
||||
moveItemsInv();
|
||||
break;
|
||||
}
|
||||
else if (playerInventory[unfininshedStack].amount + cloneItem.amount > 99) {
|
||||
var stackRemainder = 99 - playerInventory[unfininshedStack].amount;
|
||||
else if (playerInventory[unfininshedStack].amount + cloneItem.amount > 10) {
|
||||
var stackRemainder = 10 - playerInventory[unfininshedStack].amount;
|
||||
playerInventory[unfininshedStack].amount += stackRemainder;
|
||||
cloneItem.amount -= stackRemainder;
|
||||
var recycleCloned = cloneItem;
|
||||
@@ -210,11 +210,11 @@ function addToInvenotry(addItem) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (cloneItem.amount > 99 && playerInventory[i].object === 'false') {
|
||||
else if (cloneItem.amount > 10 && playerInventory[i].object === 'false') {
|
||||
var reduceCloneAmount = Object.assign({}, cloneItem);
|
||||
reduceCloneAmount.amount = 99;
|
||||
reduceCloneAmount.amount = 10;
|
||||
playerInventory[i] = reduceCloneAmount;
|
||||
cloneItem.amount -= 99;
|
||||
cloneItem.amount -= 10;
|
||||
addToInvenotry(cloneItem);
|
||||
drawToPage();
|
||||
moveItemsInv();
|
||||
@@ -254,11 +254,12 @@ function moveItemsInv() {
|
||||
if (playerInventory[currentSelected].stackable === 'false' || playerInventory[currentSelected].itemId != playerInventory[this.getAttribute('data-value')].itemId) {
|
||||
|
||||
if (playerInventory[this.getAttribute('data-value')] == EmptySlot && this.getAttribute('data-value') > 23) {
|
||||
$(".Betrag").show();
|
||||
|
||||
var hItem = this.getAttribute('data-value');
|
||||
var iItem = currentSelected;
|
||||
var Copy = Object.assign({}, playerInventory[iItem]);
|
||||
playerInventory.splice(hItem, 0, Copy);
|
||||
playerInventory.splice(hItem, 0, Copy);
|
||||
$(".Betrag").show();
|
||||
$("#tf_submitZahl").click(function () {
|
||||
|
||||
if ($('#tf_zahl').val() < playerInventory[iItem].amount && playerInventory[currentSelected].stackable) {
|
||||
@@ -270,8 +271,8 @@ function moveItemsInv() {
|
||||
playerInventory[hItem].amount = y;
|
||||
console.log(playerInventory[hItem].amount + " " + playerInventory[iItem].amount + " " + parseInt($('#tf_zahl').val(), 10) + " " + hItem);
|
||||
} else {
|
||||
playerInventory[hItem].amount = playerInventory[currentSelected].amount;
|
||||
playerInventory[currentSelected] = EmptySlot;
|
||||
playerInventory[hItem].amount = playerInventory[iItem].amount;
|
||||
playerInventory[iItem] = EmptySlot;
|
||||
}
|
||||
|
||||
drawToPage();
|
||||
@@ -331,6 +332,7 @@ var weightInv = 0;
|
||||
function drawToPage() {
|
||||
refreshAllCurrentItems();
|
||||
weightInv = 0;
|
||||
document.getElementById('gewicht').innerText = "0/45 kg";
|
||||
for (var i = 0; i < playerInventory.length; i++) {
|
||||
if (playerInventory[i].selected == 'true') {
|
||||
var className = ' selected';
|
||||
@@ -383,7 +385,7 @@ function drawToPage() {
|
||||
itemDescTitle.appendChild(getItemTitle);
|
||||
|
||||
weightInv += playerInventory[i].currentWeight * playerInventory[i].amount;
|
||||
document.getElementById('gewicht').innerText = Math.round(weightInv * 100) / 100 + "/25 kg";
|
||||
document.getElementById('gewicht').innerText = Math.round(weightInv * 100) / 100 + "/45 kg";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -519,13 +521,39 @@ $("#buttonbenutzen").click(function () {
|
||||
|
||||
|
||||
$("#buttonwegwerfen").click(function () {
|
||||
if (currentSelected) {
|
||||
drawToPage();
|
||||
drawToHandel();
|
||||
moveItemsInv();
|
||||
mp.trigger('CEF:invThrowItem', playerInventory[currentSelected].itemId);
|
||||
playerInventory[currentSelected] = EmptySlot;
|
||||
currentSelected = undefined;
|
||||
if (currentSelected) {
|
||||
|
||||
if (playerInventory[currentSelected].stackable == 'false') {
|
||||
mp.trigger('CEF:invThrowItem', playerInventory[currentSelected].itemId, playerInventory[currentSelected].amount);
|
||||
weightInv -= playerInventory[currentSelected].weight;
|
||||
playerInventory[currentSelected] = EmptySlot;
|
||||
currentSelected = undefined;
|
||||
drawToPage();
|
||||
drawToHandel();
|
||||
moveItemsInv();
|
||||
return;
|
||||
}
|
||||
|
||||
$(".Betrag").show();
|
||||
var iItem = currentSelected;
|
||||
$("#tf_submitZahl").click(function () {
|
||||
|
||||
if ($('#tf_zahl').val() < playerInventory[iItem].amount && playerInventory[currentSelected].stackable) {
|
||||
var y = parseInt($('#tf_zahl').val(), 10);
|
||||
|
||||
playerInventory[iItem].amount -= y;
|
||||
mp.trigger('CEF:invThrowItem', playerInventory[currentSelected].itemId, y);
|
||||
} else {
|
||||
mp.trigger('CEF:invThrowItem', playerInventory[currentSelected].itemId, playerInventory[currentSelected].amount);
|
||||
playerInventory[iItem] = EmptySlot;
|
||||
}
|
||||
$(".Betrag").hide();
|
||||
currentSelected = undefined;
|
||||
drawToPage();
|
||||
drawToHandel();
|
||||
moveItemsInv();
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user