diff --git a/ReallifeGamemode.Client/assets/css/inventory/style.css b/ReallifeGamemode.Client/assets/css/inventory/style.css deleted file mode 100644 index 9ccfa3e0..00000000 --- a/ReallifeGamemode.Client/assets/css/inventory/style.css +++ /dev/null @@ -1,327 +0,0 @@ -/* *** FOR TESTING ONLY *** */ -.greyFont { - color: gray; - font-size: 14px; - width: 250px; -} - -#commandOpts { - width: 250px; - height: 50px; - overflow: hidden; - overflow-y: scroll; -} - -#commandOpts li{ - cursor: pointer; -} - -/* *** FOR TESTING ONLY *** */ - -body { - overflow: hidden; - font-family: 'Roboto', sans-serif; - font-weight: 500; - color: #222; - margin: 0; - padding: 0; -} -#buttonbenutzen { - background-color: #4CAF50; /* gruen */ - border: none; - color: white; - padding: 12px 24px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; - position: relative; - left: 1.5%; -} -#buttonwegwerfen { - background-color: #f44336; /* rot */ - border: none; - color: white; - padding: 12px 24px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; - position: relative; - left: 1.5%; -} -#buttonhandeln { - background-color: #008CBA; /* blau */ - border: none; - color: white; - padding: 12px 24px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; - position: relative; - left: 1.5%; -} - -button { - width: 125px; - background-color: lightGrey; - padding: 5px; - margin: 2px 0px; - border: none; - cursor: pointer; -} - -button:hover { - background-color: grey; -} - - -h2 { - font-family: 'Roboto', sans-serif; - font-weight: 700; - font-size: 18px; - color: white; - margin:5px; - padding: 5px; - border: 1px solid #808080; - width: 20.75em; -} -.box1 { - float: left; - width: 50%; -} -.box2 { - - padding: 2px; - - } - .left { text-align: left; } - .right { text-align: right; } -h4 { - font-family: 'Roboto', sans-serif; - font-weight: 700; - font-size: 18px; - color: white; - margin:5px; - padding: 5px; - text-align:right; - border: none; -} - -h3 { - font-family: 'Roboto', sans-serif; - font-weight: 700; - font-size: 16px; - padding: 0px 0px; -} -h5 { - font-family: 'Roboto', sans-serif; - font-weight: 700; - font-size: 18px; - color: white; - margin:5px; - padding: 5px; - border: 1px solid #808080; - width: 20.75em; -} - -.pInvWrapper { - background: rgba(0,0,0,0.4); - height: 395px; - width: 394px; - display: block; - padding: 5px; - position: absolute; - left: 38%; - top: 0; -} - -.pInvWrapper { - background: rgba(0,0,0,0.4); - height: 395px; - width: 394px; - display: block; - padding: 5px; - position: absolute; - left: 38%; - top: 0; -} - -.phanWrapper { - background: rgba(0,0,0,0.4); - height: 170px; - width: 394px; - display: block; - padding: 5px; - position: absolute; - left: 38%; - top: 50%; -} - -#invContainer{ - width: 110%; - height: auto; -} -#handelContainer{ - width: 110%; - height: auto; -} - -#invContainer h3 { - padding: 0px 10px; -} - -.itemSlot { - width: 54px; - height: 54px; - margin: 5px; - float: left; - border: 1px solid #808080; - border-radius: 5px; - position: relative; - cursor: pointer; -} - -.itemSlot:hover { - border: 1px solid #999999; -} - -.itemAmount p { - color: white; - font-family: 'Roboto', sans-serif; - font-weight: 700; - text-shadow: 0px 0px 2px black; - position: absolute; - top: 16px; - left: 4px; -} - - -.selected { - box-shadow: 0px 0px 6px white; - border: 1px solid yellow; -} - -.common { - box-shadow: 0 0 2px 1px white inset; -} - -.common h3 { - color: white; - text-shadow: 0 0 0 1px black; -} - -.uncommon { - box-shadow: 0 0 2px 1px #3333ff inset; -} - -.uncommon h3 { - color: #3333ff; - text-shadow: 0 0 0 1px black; -} - -.rare { - box-shadow: 0 0 2px 1px #66ff33 inset; -} - -.rare h3 { - color: #66ff33; - text-shadow: 0 0 0 1px black; -} - -.superior { - box-shadow: 0 0 3px 1px #990099 inset; -} - -.superior h3 { - color: #990099; - text-shadow: 0px 0px 1px black; -} - -.mythic { - box-shadow: 0 0 3px 1px #ffa333 inset; -} - -.mythic h3 { - color: #ffa333; - text-shadow: 0px 0px 1px black; -} - -.pForgeWrapper { - background: #222; - height: 176px; - width: 330px; - display: block; - padding: 5px; - position: absolute; - left: 0; - top: 0; -} - -/*item description */ -.itemSlot:hover > .itemDesc { - display: block; -} - -.itemDesc { - width: 250px; - height: auto; - top: 60px; - border: 1px solid #808080; - border-radius: 5px; - background: #1a1a1a; - position: absolute; - display: none; - z-index: 9999; -} - -.itemDesc p{ - color: white; -} -/*Handelfenster */ -#tf_betrag { - background-color: #313131; /* blau */ - border: none; - height: 30px; - width: 124px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 12px; - position: relative; - left: 1.5%; - color:#ffffff; -} -#tf_name { - background-color: #313131; /* blau */ - border: none; - height: 30px; - width: 124px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 12px; - position: relative; - left: 1.5%; - color: #ffffff; -} -::placeholder { - color: #696969; - opacity: 1; -} -#tf_submit { - background-color: #008CBA; /* blau */ - border: none; - height: 32px; - width: 124px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; - font-color: white; - position: relative; - left: 1.5%; - color: #ffffff; -} - /* tasks */ \ No newline at end of file diff --git a/ReallifeGamemode.Client/assets/html/inventory/handel/handelakzeptieren.html b/ReallifeGamemode.Client/assets/html/inventory/handel/handelakzeptieren.html deleted file mode 100644 index cf260543..00000000 --- a/ReallifeGamemode.Client/assets/html/inventory/handel/handelakzeptieren.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - Inventory - - - - - - - - - -
-
-

Handel Akzeptieren

-

Preis: 0$

-
-
- -
- - -
- - - - - \ No newline at end of file diff --git a/ReallifeGamemode.Client/assets/html/inventory/handel/script.js b/ReallifeGamemode.Client/assets/html/inventory/handel/script.js deleted file mode 100644 index e3515e0c..00000000 --- a/ReallifeGamemode.Client/assets/html/inventory/handel/script.js +++ /dev/null @@ -1,312 +0,0 @@ - -$(document).ready(function () { - //fire functions before page load - drawToPage(); - moveItemsInv(); - console.log("loading finished"); - mp.trigger("CEF:BrowserLoadedTrade"); -}); - -function setItems(itemIdArr1, itemAmountArr1, money1) { - var itemIdArr = JSON.parse(itemIdArr1); - var money = JSON.parse(money1); - var itemAmountArr = JSON.parse(itemAmountArr1); - document.getElementById('gewicht').innerText = 'Preis: '+money+'$'; - var itemAmountArr = JSON.parse(itemAmountArr1); - for (var i = 0; i < itemIdArr.length; i++) { - for (x = 0; x < itemAmountArr[i]; x++) { - commands.addToPlayerInv(itemIdArr[i]); - console.log(i); - } - } -} - - - -var fish = { - name: "Fisch", - weight: 1, - currentWeight: 1, - dropweight: function () { - var randomweight = Math.floor((Math.random() * 10) + 1); - this.weight = randomweight; - this.currentWeight = randomweight; - }, - def: 15, - rarity: 'common', - statSlots: [], - runes: [], - amount: 1, - usable: 'false', - selected: 'false', - stackable: 'false', - object: 'true', - itemId: 1, - img: 'package://assets/img/items/fish.svg' -} - -var hamburger = { - name: "Hamburger", - rarity: 'common', - selected: 'false', - usable: 'true', - amount: 1, - currentWeight: 0.3, - stackable: 'true', - object: 'true', - itemId: 2, - img: "package://assets/img/items/burger.svg" -} - -var cocaine = { - name: "Koks", - rarity: 'common', - selected: 'false', - usable: 'true', - amount: 1, - currentWeight: 0.05, - stackable: 'true', - object: 'true', - itemId: 3, - img: "package://assets/img/items/cocaine.svg" -} - -var cannabis = { - name: "Cannabis", - rarity: 'common', - selected: 'false', - usable: 'true', - amount: 1, - currentWeight: 0.05, - stackable: 'true', - object: 'true', - itemId: 4, - img: "package://assets/img/items/cannabis.svg" -} - -var allItems = [fish, hamburger, cocaine, cannabis]; - - - -//////////////////////// -// Player Invenotry // -//////////////////////// - -var playerInventory = []; -var EmptySlot = { name: 'blankSpace', rarity: '', object: 'false' }; - - -function addToInvenotry(addItem) { - var cloneItem = Object.assign({}, addItem); - var getExsistingId = cloneItem.itemId; - var unfininshedStack; - - - //Checks to see if any items can be stacked, the location, and stack amount - for (var i = 0; i < playerInventory.length; i++) { - if (playerInventory[i].itemId === getExsistingId && cloneItem.stackable === 'true' && playerInventory[i].amount < 10) { - unfininshedStack = i - break; - } - } - if (cloneItem.currentWeight * cloneItem.amount + weightInv >= 25) { - return; - } - - //Adds item to inventory - for (var i = 0; i < playerInventory.length; i++) { - if (unfininshedStack != undefined) { - if (playerInventory[unfininshedStack].amount + cloneItem.amount <= 10) { - playerInventory[unfininshedStack].amount += cloneItem.amount; - unfininshedStack = undefined; - drawToPage(); - moveItemsInv(); - break; - } - else if (playerInventory[unfininshedStack].amount + cloneItem.amount > 10) { - var stackRemainder = 10 - playerInventory[unfininshedStack].amount; - playerInventory[unfininshedStack].amount += stackRemainder; - cloneItem.amount -= stackRemainder; - var recycleCloned = cloneItem; - addToInvenotry(recycleCloned); - unfininshedStack = undefined; - drawToPage(); - moveItemsInv(); - break; - } - } - else if (cloneItem.amount > 10 && playerInventory[i].object === 'false') { - var reduceCloneAmount = Object.assign({}, cloneItem); - reduceCloneAmount.amount = 10; - playerInventory[i] = reduceCloneAmount; - cloneItem.amount -= 10; - addToInvenotry(cloneItem); - drawToPage(); - moveItemsInv(); - break; - } - else if (unfininshedStack == undefined && playerInventory[i].object === 'false') { - playerInventory[i] = cloneItem; - drawToPage(); - moveItemsInv(); - break; - } - } -} - -var getItemSlotData; -function getAllItemSlotData() { - getItemSlotData = document.getElementsByClassName('itemSlot'); -} - - -var currentSelected; -function moveItemsInv() { - getAllItemSlotData(); - for (var i = 0; i < getItemSlotData.length; i++) { - getItemSlotData[i].addEventListener("click", function () { - if (this.classList.contains('selected')) { - this.classList.remove('selected'); - currentSelected = undefined; - } - else if (this.getAttribute('object') === 'false' && isNaN(currentSelected)) { - return; - } - else if (currentSelected) { - if (playerInventory[currentSelected].stackable === 'false' || playerInventory[currentSelected].itemId != playerInventory[this.getAttribute('data-value')].itemId) { - var swap = playerInventory[this.getAttribute('data-value')]; - playerInventory[this.getAttribute('data-value')] = playerInventory[currentSelected]; - playerInventory[currentSelected] = swap; - drawToPage(); - currentSelected = undefined; - getItemSlotData = document.getElementsByClassName('itemSlot'); - moveItemsInv(); - } - else if (playerInventory[currentSelected].itemId == playerInventory[this.getAttribute('data-value')].itemId && playerInventory[currentSelected].stackable) { - playerInventory[this.getAttribute('data-value')].amount += playerInventory[currentSelected].amount - playerInventory[currentSelected] = EmptySlot; - drawToPage(); - currentSelected = undefined; - getItemSlotData = document.getElementsByClassName('itemSlot'); - moveItemsInv(); - } - } - else { - this.className += ' selected' - currentSelected = this.getAttribute('data-value') - } - }); - } -} - -function refreshAllCurrentItems() { - var remove = document.getElementById('invContainer'); - while (remove.firstChild) remove.removeChild(remove.firstChild); -} - - -function fillOutEmptyInv() { - for (var i = 0; i < 6; i++) { - if (!playerInventory[i]) { - playerInventory.push(EmptySlot); - drawToPage(); - } - } -} -var weightInv = 0; -function drawToPage() { - refreshAllCurrentItems(); - weightInv = 0; - for (var i = 0; i < playerInventory.length; i++) { - if (playerInventory[i].selected == 'true') { - var className = ' selected'; - } - else { - var className = ''; - } - - if (i >= 6) { - //Keeps inventory set to 10 items max - console.log('Inventory is full!') - return; - } - else { - //creates item element - var item = document.createElement("div"); - item.className = "itemSlot " + playerInventory[i].rarity + className; - item.setAttribute("data-value", i); - item.setAttribute("inv-type", 'p'); - item.setAttribute("object", playerInventory[i].object); - item.setAttribute('style', 'background: url(' + playerInventory[i].img + '); background-size: contain;'); - - //show element amounts - var itemAmount = document.createElement("div"); - itemAmount.className = "itemAmount"; - var itemAmountDisplay = document.createElement("p"); - if (playerInventory[i].amount) { - var itemDisplayStatsName = document.createTextNode(playerInventory[i].amount); - } - else { - var itemDisplayStatsName = document.createTextNode(''); - } - item.appendChild(itemAmount); - itemAmount.appendChild(itemAmountDisplay); - itemAmountDisplay.appendChild(itemDisplayStatsName); - - - //adds item element or elements - document.getElementById("invContainer").appendChild(item); - - //creates item display information - if (playerInventory[i].object === 'true') { - var itemDesc = document.createElement("div"); - var itemDescTitle = document.createElement("h3"); - - var getItemTitle = document.createTextNode(playerInventory[i].name + " (" + Math.round(playerInventory[i].currentWeight * playerInventory[i].amount * 100) / 100 + " kg)"); - itemDesc.className = "itemDesc"; - item.appendChild(itemDesc); - itemDesc.appendChild(itemDescTitle); - itemDescTitle.appendChild(getItemTitle); - } - } - } - fillOutEmptyInv(); -} - - -/////////////////// -// Dev Commands // -/////////////////// - -var commands = { - addToPlayerInv: function (itemGiveId) { - for (var i = 0; i < allItems.length; i++) { - if (allItems[i].itemId === itemGiveId) { - addToInvenotry(allItems[i]); - } - } - }, - clearPlayerInv: function () { - playerInventory = []; - drawToPage(); - }, -} - - -// Button funktionen -var elemakzeptieren = document.getElementById("buttonakzeptieren"); -elemakzeptieren.addEventListener('click', akzeptieren); - -var elemablehnen = document.getElementById("buttonablehnen"); -elemablehnen.addEventListener('click', ablehnen); - - -//Handel Akzeptierenfenster - -function akzeptieren() { - mp.trigger('CEF:acceptTrade'); -} - -function ablehnen() { - mp.trigger('CEF:declineTrade'); -} diff --git a/ReallifeGamemode.Client/assets/html/inventory/handel/style.css b/ReallifeGamemode.Client/assets/html/inventory/handel/style.css deleted file mode 100644 index 3beb72fe..00000000 --- a/ReallifeGamemode.Client/assets/html/inventory/handel/style.css +++ /dev/null @@ -1,284 +0,0 @@ -/* *** FOR TESTING ONLY *** */ -.greyFont { - color: gray; - font-size: 14px; - width: 250px; -} - -body { - overflow: hidden; - font-family: 'Roboto', sans-serif; - font-weight: 500; - color: #222; - margin: 0; - padding: 0; -} -#buttonbenutzen { - background-color: #4CAF50; /* gruen */ - border: none; - color: white; - padding: 12px 24px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; - position: relative; - left: 1.5%; -} -#buttonwegwerfen { - background-color: #f44336; /* rot */ - border: none; - color: white; - padding: 12px 24px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; - position: relative; - left: 1.5%; -} -#buttonhandeln { - background-color: #008CBA; /* blau */ - border: none; - color: white; - padding: 12px 24px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; - position: relative; - left: 1.5%; -} -#buttonablehnen { - background-color: #f44336; /* rot */ - border: none; - color: white; - padding: 12px 24px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; - position: relative; - left: 18%; -} -#buttonakzeptieren { - background-color: #008CBA; /* blau */ - border: none; - color: white; - padding: 12px 24px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; - position: relative; - left: 18%; -} - -button { - width: 125px; - background-color: lightGrey; - padding: 5px; - margin: 2px 0px; - border: none; - cursor: pointer; -} - -button:hover { - background-color: grey; -} - -h2 { - font-family: 'Roboto', sans-serif; - font-weight: 700; - font-size: 18px; - color: white; - margin:5px; - padding: 5px; - border: 1px solid #808080; - width: 20.75em; -} -.box1 { - float: left; - width: 50%; -} -.box2 { - - padding: 2px; - - } - -h4 { - font-family: 'Roboto', sans-serif; - font-weight: 700; - font-size: 18px; - color: white; - margin:5px; - padding: 5px; - text-align:right; - border: none; -} - -.pakWrapper { - background: rgba(0,0,0,0.4); - height: 170px; - width: 394px; - display: block; - padding: 5px; - position: absolute; - left: 38%; - top: 35%; -} - -#invContainer{ - width: 110%; - height: auto; -} - -#invContainer h3 { - padding: 0px 10px; -} - -.itemSlot { - width: 54px; - height: 54px; - margin: 5px; - float: left; - border: 1px solid #808080; - border-radius: 5px; - position: relative; - cursor: pointer; -} - -.itemSlot:hover { - border: 1px solid #999999; -} - -.itemAmount p { - color: white; - font-family: 'Roboto', sans-serif; - font-weight: 700; - text-shadow: 0px 0px 2px black; - position: absolute; - top: 16px; - left: 4px; -} - - -.selected { - box-shadow: 0px 0px 6px white; - border: 1px solid yellow; -} - -.common { - box-shadow: 0 0 2px 1px white inset; -} - -.common h3 { - color: white; - text-shadow: 0 0 0 1px black; -} - -.uncommon { - box-shadow: 0 0 2px 1px #3333ff inset; -} - -.uncommon h3 { - color: #3333ff; - text-shadow: 0 0 0 1px black; -} - -.rare { - box-shadow: 0 0 2px 1px #66ff33 inset; -} - -.rare h3 { - color: #66ff33; - text-shadow: 0 0 0 1px black; -} - -.superior { - box-shadow: 0 0 3px 1px #990099 inset; -} - -.superior h3 { - color: #990099; - text-shadow: 0px 0px 1px black; -} - -.mythic { - box-shadow: 0 0 3px 1px #ffa333 inset; -} - -.mythic h3 { - color: #ffa333; - text-shadow: 0px 0px 1px black; -} - -.pForgeWrapper { - background: #222; - height: 176px; - width: 330px; - display: block; - padding: 5px; - position: absolute; - left: 0; - top: 0; -} - -/*item description */ -.itemSlot:hover > .itemDesc { - display: block; -} - -.itemDesc { - width: 250px; - height: auto; - top: 60px; - border: 1px solid #808080; - border-radius: 5px; - background: #1a1a1a; - position: absolute; - display: none; - z-index: 9999; -} - -.itemDesc p{ - color: white; -} -/*Handelfenster */ -#tf_betrag { - background-color: #008CBA; /* blau */ - border: none; - height: 30px; - width: 124px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; - font-color: white; - position: relative; - left: 1.5%; - color:#ffffff; -} -::placeholder { - color: white; - opacity: 1; -} -#tf_submit { - background-color: #008CBA; /* blau */ - border: none; - height: 32px; - width: 124px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; - font-color: white; - position: relative; - left: 1.5%; - color:#ffffff; -} - - - -/* tasks */ \ No newline at end of file diff --git a/ReallifeGamemode.Client/assets/html/inventory/index.html b/ReallifeGamemode.Client/assets/html/inventory/index.html deleted file mode 100644 index ec2ba455..00000000 --- a/ReallifeGamemode.Client/assets/html/inventory/index.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - Inventory - - - - -
-
-

Inventar

-

0/25 kg

-
-
-

-

- -
- - - -
- - -
-

Handel

-
- -
- - - - - -
- -
-
-
- -
-
-

- - - - - - - - - - - diff --git a/ReallifeGamemode.Client/assets/img/items/burger.svg b/ReallifeGamemode.Client/assets/img/items/burger.svg deleted file mode 100644 index f890542f..00000000 --- a/ReallifeGamemode.Client/assets/img/items/burger.svg +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ReallifeGamemode.Client/assets/img/items/cannabis.svg b/ReallifeGamemode.Client/assets/img/items/cannabis.svg deleted file mode 100644 index 92a41b9c..00000000 --- a/ReallifeGamemode.Client/assets/img/items/cannabis.svg +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ReallifeGamemode.Client/assets/img/items/cocaine.svg b/ReallifeGamemode.Client/assets/img/items/cocaine.svg deleted file mode 100644 index b8e9aea0..00000000 --- a/ReallifeGamemode.Client/assets/img/items/cocaine.svg +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ReallifeGamemode.Client/assets/img/items/fish.svg b/ReallifeGamemode.Client/assets/img/items/fish.svg deleted file mode 100644 index ded220af..00000000 --- a/ReallifeGamemode.Client/assets/img/items/fish.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/ReallifeGamemode.Client/assets/js/inventory/script.js b/ReallifeGamemode.Client/assets/js/inventory/script.js deleted file mode 100644 index 77316876..00000000 --- a/ReallifeGamemode.Client/assets/js/inventory/script.js +++ /dev/null @@ -1,486 +0,0 @@ - - -$(document).ready(function () { - //fire functions before page load - drawToPage(); - moveItemsInv(); - console.log("loading finished"); - mp.trigger("CEF:BrowserLoaded"); -}); - -function setItems(itemIdArr1, itemAmountArr1) { - var itemIdArr = JSON.parse(itemIdArr1); - var itemAmountArr = JSON.parse(itemAmountArr1); - for (var i = 0; i < itemIdArr.length; i++) { - for (x = 0; x < itemAmountArr[i]; x++) { - commands.addToPlayerInv(itemIdArr[i]); - console.log(i); - } - } -} - - - -var fish = { - name: "Fisch", - weight: 1, - currentWeight: 1, - dropweight: function () { - var randomweight = Math.floor((Math.random() * 10) + 1); - this.weight = randomweight; - this.currentWeight = randomweight; - }, - def: 15, - rarity: 'common', - statSlots: [], - runes: [], - amount: 1, - usable: 'false', - selected: 'false', - stackable: 'false', - object: 'true', - itemId: 1, - img: 'package://assets/img/items/fish.svg' -} - -var hamburger = { - name: "Hamburger", - rarity: 'common', - selected: 'false', - usable: 'true', - amount: 1, - currentWeight: 0.3, - stackable: 'true', - object: 'true', - itemId: 2, - img: "package://assets/img/items/burger.svg" -} - -var cocaine = { - name: "Koks", - rarity: 'common', - selected: 'false', - usable: 'true', - amount: 1, - currentWeight: 0.05, - stackable: 'true', - object: 'true', - itemId: 3, - img: "package://assets/img/items/cocaine.svg" -} - -var cannabis = { - name: "Cannabis", - rarity: 'common', - selected: 'false', - usable: 'true', - amount: 1, - currentWeight: 0.05, - stackable: 'true', - object: 'true', - itemId: 4, - img: "package://assets/img/items/cannabis.svg" -} - -var allItems = [fish, hamburger, cocaine, cannabis]; - - - -//////////////////////// -// Player Invenotry // -//////////////////////// - -var playerInventory = []; -var EmptySlot = { name: 'blankSpace', rarity: '', object: 'false' }; - - -function addToInvenotry(addItem) { - var cloneItem = Object.assign({}, addItem); - var getExsistingId = cloneItem.itemId; - var unfininshedStack; - - - //Checks to see if any items can be stacked, the location, and stack amount - for (var i = 0; i < playerInventory.length; i++) { - if (playerInventory[i].itemId === getExsistingId && cloneItem.stackable === 'true' && playerInventory[i].amount < 10) { - unfininshedStack = i - break; - } - } - if (cloneItem.currentWeight * cloneItem.amount + weightInv >= 25) { - return; - } - - //Adds item to inventory - for (var i = 0; i < playerInventory.length; i++) { - if (unfininshedStack != undefined) { - if (playerInventory[unfininshedStack].amount + cloneItem.amount <= 10) { - playerInventory[unfininshedStack].amount += cloneItem.amount; - unfininshedStack = undefined; - drawToPage(); - moveItemsInv(); - break; - } - else if (playerInventory[unfininshedStack].amount + cloneItem.amount > 10) { - var stackRemainder = 10 - playerInventory[unfininshedStack].amount; - playerInventory[unfininshedStack].amount += stackRemainder; - cloneItem.amount -= stackRemainder; - var recycleCloned = cloneItem; - addToInvenotry(recycleCloned); - unfininshedStack = undefined; - drawToPage(); - moveItemsInv(); - break; - } - } - else if (cloneItem.amount > 10 && playerInventory[i].object === 'false') { - var reduceCloneAmount = Object.assign({}, cloneItem); - reduceCloneAmount.amount = 10; - playerInventory[i] = reduceCloneAmount; - cloneItem.amount -= 10; - addToInvenotry(cloneItem); - drawToPage(); - moveItemsInv(); - break; - } - else if (unfininshedStack == undefined && playerInventory[i].object === 'false') { - playerInventory[i] = cloneItem; - drawToPage(); - moveItemsInv(); - break; - } - } -} - -var getItemSlotData; -function getAllItemSlotData() { - getItemSlotData = document.getElementsByClassName('itemSlot'); -} - - -var currentSelected; -function moveItemsInv() { - getAllItemSlotData(); - for (var i = 0; i < getItemSlotData.length; i++) { - getItemSlotData[i].addEventListener("click", function () { - if (this.classList.contains('selected')) { - this.classList.remove('selected'); - currentSelected = undefined; - } - else if (this.getAttribute('object') === 'false' && isNaN(currentSelected)) { - return; - } - else if (currentSelected) { - if (playerInventory[currentSelected].stackable === 'false' || playerInventory[currentSelected].itemId != playerInventory[this.getAttribute('data-value')].itemId) { - var swap = playerInventory[this.getAttribute('data-value')]; - playerInventory[this.getAttribute('data-value')] = playerInventory[currentSelected]; - playerInventory[currentSelected] = swap; - drawToPage(); - drawToHandel(); - currentSelected = undefined; - getItemSlotData = document.getElementsByClassName('itemSlot'); - moveItemsInv(); - } - else if (playerInventory[currentSelected].itemId == playerInventory[this.getAttribute('data-value')].itemId && playerInventory[currentSelected].stackable) { - playerInventory[this.getAttribute('data-value')].amount += playerInventory[currentSelected].amount - playerInventory[currentSelected] = EmptySlot; - drawToPage(); - drawToHandel(); - currentSelected = undefined; - getItemSlotData = document.getElementsByClassName('itemSlot'); - moveItemsInv(); - } - } - else { - this.className += ' selected' - currentSelected = this.getAttribute('data-value') - } - }); - } -} - -function refreshAllCurrentItems() { - var remove = document.getElementById('invContainer'); - while (remove.firstChild) remove.removeChild(remove.firstChild); -} - - -function fillOutEmptyInv() { - for (var i = 0; i < 24; i++) { - if (!playerInventory[i]) { - playerInventory.push(EmptySlot); - drawToPage(); - } - } -} -var weightInv = 0; -function drawToPage() { - refreshAllCurrentItems(); - weightInv = 0; - for (var i = 0; i < playerInventory.length; i++) { - if (playerInventory[i].selected == 'true') { - var className = ' selected'; - } - else { - var className = ''; - } - - if (i >= 24) { - //Keeps inventory set to 10 items max - console.log('Inventory is full!') - return; - } - else { - //creates item element - var item = document.createElement("div"); - item.className = "itemSlot " + playerInventory[i].rarity + className; - item.setAttribute("data-value", i); - item.setAttribute("inv-type", 'p'); - item.setAttribute("object", playerInventory[i].object); - item.setAttribute('style', 'background: url(' + playerInventory[i].img + '); background-size: contain;'); - - //show element amounts - var itemAmount = document.createElement("div"); - itemAmount.className = "itemAmount"; - var itemAmountDisplay = document.createElement("p"); - if (playerInventory[i].amount) { - var itemDisplayStatsName = document.createTextNode(playerInventory[i].amount); - } - else { - var itemDisplayStatsName = document.createTextNode(''); - } - item.appendChild(itemAmount); - itemAmount.appendChild(itemAmountDisplay); - itemAmountDisplay.appendChild(itemDisplayStatsName); - - - //adds item element or elements - document.getElementById("invContainer").appendChild(item); - - //creates item display information - if (playerInventory[i].object === 'true') { - var itemDesc = document.createElement("div"); - var itemDescTitle = document.createElement("h3"); - - var getItemTitle = document.createTextNode(playerInventory[i].name + " (" + Math.round(playerInventory[i].currentWeight * playerInventory[i].amount * 100) / 100 + " kg)"); - itemDesc.className = "itemDesc"; - item.appendChild(itemDesc); - itemDesc.appendChild(itemDescTitle); - itemDescTitle.appendChild(getItemTitle); - - weightInv += playerInventory[i].currentWeight * playerInventory[i].amount; - document.getElementById('gewicht').innerText = Math.round(weightInv * 100) / 100 + "/25 kg"; - } - } - } - fillOutEmptyInv(); -} - -function refreshAllCurrentHandelItems() { - var remove = document.getElementById('handelContainer'); - while (remove.firstChild) remove.removeChild(remove.firstChild); -} - - -function fillOutEmptyInvHandel() { - for (var i = 24; i < 30; i++) { - if (!playerInventory[i]) { - playerInventory.push(EmptySlot); - drawToHandel(); - } - } -} - -function drawToHandel() { - refreshAllCurrentHandelItems(); - for (var i = 24; i < playerInventory.length; i++) { - if (playerInventory[i].selected == 'true') { - var className = ' selected'; - } - else { - var className = ''; - } - - if (i >= 30) { - //Keeps inventory set to 10 items max - console.log('Inventory is full!') - return; - } - else { - //creates item element - var item = document.createElement("div"); - item.className = "itemSlot " + playerInventory[i].rarity + className; - item.setAttribute("data-value", i); - item.setAttribute("inv-type", 'p'); - item.setAttribute("object", playerInventory[i].object); - item.setAttribute('style', 'background: url(' + playerInventory[i].img + '); background-size: contain;'); - - //show element amounts - var itemAmount = document.createElement("div"); - itemAmount.className = "itemAmount"; - var itemAmountDisplay = document.createElement("p"); - if (playerInventory[i].amount) { - var itemDisplayStatsName = document.createTextNode(playerInventory[i].amount); - } - else { - var itemDisplayStatsName = document.createTextNode(''); - } - item.appendChild(itemAmount); - itemAmount.appendChild(itemAmountDisplay); - itemAmountDisplay.appendChild(itemDisplayStatsName); - - - //adds item element or elements - document.getElementById("handelContainer").appendChild(item); - - if (playerInventory[i].object === 'true') { - var itemDesc = document.createElement("div"); - var itemDescTitle = document.createElement("h3"); - - var getItemTitle = document.createTextNode(playerInventory[i].name + " (" + Math.round(playerInventory[i].currentWeight * playerInventory[i].amount * 100) / 100 + " kg)"); - itemDesc.className = "itemDesc"; - item.appendChild(itemDesc); - itemDesc.appendChild(itemDescTitle); - itemDescTitle.appendChild(getItemTitle); - } - - } - - } - fillOutEmptyInvHandel(); -} - - - -/////////////////// -// Dev Commands // -/////////////////// - -var commands = { - addToPlayerInv: function (itemGiveId) { - for (var i = 0; i < allItems.length; i++) { - if (allItems[i].itemId === itemGiveId) { - addToInvenotry(allItems[i]); - } - } - }, - clearPlayerInv: function () { - playerInventory = []; - drawToPage(); - drawToHandel(); - }, -} - - -// Button funktionen -var elembenutzen = document.getElementById("buttonbenutzen"); -elembenutzen.addEventListener('click', benutzen); - -var elemwegwerfen = document.getElementById("buttonwegwerfen"); -elemwegwerfen.addEventListener('click', wegwerfen); - -var elemsubmit = document.getElementById("tf_submit"); -elemsubmit.addEventListener('click', handeln); - - -function benutzen() { - if (currentSelected) { - if (playerInventory[currentSelected].usable == 'true') { - if (playerInventory[currentSelected].stackable == 'true') { - playerInventory[currentSelected].amount -= 1; - if (playerInventory[currentSelected].amount <= 0) { - playerInventory[currentSelected] = EmptySlot; - } else { - if (getItemSlotData[currentSelected].classList.contains('selected')) { - getItemSlotData[currentSelected].classList.remove('selected'); - playerInventory[currentSelected].selected = 'false'; - currentSelected = undefined; - } - } - drawToPage(); - drawToHandel(); - moveItemsInv(); - getCommands(); - } else { - playerInventory[currentSelected] = EmptySlot; - currentSelected = undefined; - drawToPage(); - drawToHandel(); - moveItemsInv(); - - } - mp.trigger("CEF:UseItemInv", playerInventory[currentSelected].itemId); - } - } -} - - -function wegwerfen() { - if (currentSelected) { - playerInventory[currentSelected] = EmptySlot; - currentSelected = undefined; - drawToPage(); - drawToHandel(); - moveItemsInv(); - mp.events.callRemote('invThrowItem', playerInventory[currentSelected].itemId); - } - -} -$(".phanWrapper").hide(); -var trade = 1; -$("#buttonhandeln").click(function () { - if (trade == 1) { - $(".phanWrapper").show(); - drawToHandel(); - drawToPage(); - moveItemsInv(); - trade = 0; - } else { - $(".phanWrapper").hide(); - trade = 1; - } -}); - -function handeln() { - var Money = document.getElementById("tf_betrag").value; - var User = document.getElementById("tf_name").value; - if (User == '') { - return; - } - if (Money == '') { - getTradeSlotItems(); - playerInventory[currentSelected] = EmptySlot; - currentSelected = undefined; - drawToPage(); - drawToHandel(); - moveItemsInv(); - - mp.trigger("CEF:tradeItem", 0, User, JSON.stringify(tradeItems), JSON.stringify(tradeItemAmount)); - return; - } - getTradeSlotItems(); - playerInventory[currentSelected] = EmptySlot; - currentSelected = undefined; - drawToPage(); - drawToHandel(); - moveItemsInv(); - mp.trigger("CEF:tradeItem", $('#tf_betrag').val(), User, JSON.stringify(tradeItems), JSON.stringify(tradeItemAmount)); - return; -} -var tradeItems = []; -var tradeItemAmount = []; -function getTradeSlotItems() { - tradeItems = []; - tradeItemAmount = []; - for (var i = 24; i < playerInventory.length; i++) { - if (playerInventory[i].object == 'true') { - for (var x = 0; x < allItems.length; x++) { - if (playerInventory[i].itemId == allItems[x].itemId) { - tradeItems.push(playerInventory[i].itemId); - tradeItemAmount.push(playerInventory[i].amount); - } - } - } - } -} - diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index e5b8af06..385517eb 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -82,7 +82,8 @@ Infobox(globalData); import playerList from './Gui/playerlist'; playerList(); - +import inventory from './Gui/Inventory/inventory'; +inventory(globalData); import vehicleMenu from './Gui/vehiclemenu/main'; vehicleMenu(globalData); @@ -105,9 +106,6 @@ playerInteraction(globalData); import interactionMenu from './Interaction/interactionmenu'; interactionMenu(globalData); -import inventory from './inventory/inventory'; -inventory(globalData); - import Login from './Login/main'; Login(globalData); diff --git a/ReallifeGamemode.Client/inventory/inventory.ts b/ReallifeGamemode.Client/inventory/inventory.ts deleted file mode 100644 index 4aa691ba..00000000 --- a/ReallifeGamemode.Client/inventory/inventory.ts +++ /dev/null @@ -1,78 +0,0 @@ - - -export default function inventory(globalData: GlobalData): void { - - var invBrowser: BrowserMp = null; - - var itemIdArr; - var itemAmountArr; - var money; - - mp.events.add("openTradeWindow", (money1, itemIdArr1, itemAmountArr1) => { - if (!globalData.InMenu) { - if (invBrowser !== null) { - invBrowser.destroy() - invBrowser = null; - mp.gui.cursor.show(false, false); - return; - } - mp.gui.cursor.show(true, true); - invBrowser = mp.browsers.new("package://assets/html/inventory/handel/handelakzeptieren.html"); - - itemIdArr = itemIdArr1; - itemAmountArr = itemAmountArr1; - money = money1; - - } - }); - - mp.events.add('inventoryShow', (itemIdArr1, itemAmountArr1) => { - if (!globalData.InMenu) { - if (invBrowser !== null) { - invBrowser.destroy() - invBrowser = null; - mp.gui.cursor.show(false, false); - return; - } - - mp.gui.cursor.show(true, true); - invBrowser = mp.browsers.new("package://assets/html/inventory/index.html"); - - itemIdArr = itemIdArr1; - itemAmountArr = itemAmountArr1; - } - }); - - mp.events.add("CEF:BrowserLoaded", () => { - invBrowser.execute(`setItems("${JSON.stringify(itemIdArr)}","${JSON.stringify(itemAmountArr)}");`); - }); - mp.events.add("CEF:BrowserLoadedTrade", () => { - invBrowser.execute(`setItems("${JSON.stringify(itemIdArr)}","${JSON.stringify(itemAmountArr)}","${JSON.stringify(money)}");`); - }); - - mp.events.add("CEF:acceptTrade", () => { - mp.events.callRemote('acceptTrade'); - invBrowser.destroy() - invBrowser = null; - mp.gui.cursor.show(false, false); - }); - - mp.events.add("CEF:declineTrade", () => { - mp.events.callRemote('declineTrade'); - invBrowser.destroy() - invBrowser = null; - mp.gui.cursor.show(false, false); - }); - - mp.events.add("CEF:UseItemInv", (itemId) => { - mp.events.callRemote('invUseItem', itemId); - }); - - mp.events.add("CEF:tradeItem", (money, User, tradeItems, tradeItemAmount) => { - mp.events.callRemote('tradeItem', money, User, tradeItems, tradeItemAmount); - invBrowser.destroy() - invBrowser = null; - mp.gui.cursor.show(false, false); - }); - -} \ No newline at end of file diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index 3d1946de..c81f02c3 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -287,7 +287,7 @@ namespace ReallifeGamemode.Server.Events public void KeyPressI(Client player) { if (!player.IsLoggedIn()) return; - ManagerOfInventory.GetUserItems(player); + InventoryManager.GetUserItems(player); } [RemoteEvent("keyPress:O")] @@ -368,19 +368,12 @@ namespace ReallifeGamemode.Server.Events public void KeyPressN(Client player) { if (!player.IsLoggedIn()) return; - } [RemoteEvent("keyPress:X")] public void KeyPressX(Client player) { if (!player.IsLoggedIn()) return; - - if (player.HasData("inTrade") && player.GetData("inTrade") == true) - { - ManagerOfInventory.OpenTradeAccept(player); - } - if (player.IsInVehicle && player.VehicleSeat == -1) { ServerVehicle veh = player.Vehicle.GetServerVehicle(); diff --git a/ReallifeGamemode.Server/Inventory/Items/Cheeseburger.cs b/ReallifeGamemode.Server/Inventory/Items/Cheeseburger.cs index 507ddb93..818ada87 100644 --- a/ReallifeGamemode.Server/Inventory/Items/Cheeseburger.cs +++ b/ReallifeGamemode.Server/Inventory/Items/Cheeseburger.cs @@ -14,9 +14,9 @@ namespace ReallifeGamemode.Server.Inventory.Items public class Cheeseburger : FoodItem { public override int Id => 2; - public override string Name => "Hamburger"; - public override string Description => "Ein Burger"; - public override int Gewicht => 300; + public override string Name => "Cheeseburger"; + public override string Description => "Wie der Hamburger, nur mit Käse."; + public override int Gewicht => 320; public override string Einheit => "g"; public override int HpAmount => 20; public override uint Object => 2240524752;