[+] Improved Inventory System based on old Inventory Manager and new GUI. (test version)

This commit is contained in:
Lukas Moungos
2019-09-12 21:40:27 +02:00
parent df82f8f291
commit deb6b7092e
60 changed files with 2856 additions and 2813 deletions

View File

@@ -27,6 +27,7 @@
<ItemGroup>
<Folder Include="assets\css\atm\" />
<Folder Include="assets\img\atm\" />
<Folder Include="assets\img\items\" />
</ItemGroup>
<ItemGroup>

View File

@@ -0,0 +1,895 @@
@font-face {
font-family: OSL;
src: url(../font/OSL.ttf);
}
* {
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
body {
width: 100%;
height: 100%;
margin: 0px auto;
background-color: transparent;
}
.main2 {
z-index: 2;
background: #0c0c0cc4;
position: absolute;
padding-left: 100%;
padding-top: 100%;
}
.main {
z-index: 1;
background: #272727;
position: absolute;
left: 19vw;
padding-left: 53vw;
padding-top: 33vw;
top: 5vw;
transition: 0.2s;
}
.title {
font-size: 2vw;
position: absolute;
color: #fff;
font-family: 'OSL';
left: 1vw;
top: 0.2vw;
background: #1b1b1b;
}
.titletext {
position: absolute;
left: 21vw;
background: #1b1b1b;
padding-right: 22.7vw;
}
.sidebar {
z-index: 1;
position: absolute;
right: 72.5vw;
cursor: pointer;
z-index: 200;
top: 9.5vw;
}
.sidebaritem1 {
z-index: 1;
margin-bottom: 0.2vw;
color: #fff;
font-family: OSL;
width: 6vw;
background: #1b1b1b;
height: 4vw;
text-align: center;
line-height: 6.1vw;
transition: 0.2s;
}
.sidebaritem2 {
z-index: 1;
margin-bottom: 0.2vw;
color: #fff;
font-family: OSL;
width: 6vw;
background: #1b1b1b;
height: 4vw;
text-align: center;
line-height: 6.1vw;
transition: 0.2s;
}
.sidebaritem3 {
z-index: 1;
margin-bottom: 0.2vw;
color: #fff;
font-family: OSL;
width: 6vw;
background: #1b1b1b;
height: 4vw;
text-align: center;
line-height: 6.1vw;
transition: 0.2s;
}
.sidebaritem4 {
z-index: 1;
margin-bottom: 0.2vw;
color: #fff;
font-family: OSL;
width: 6vw;
background: #1b1b1b;
height: 4vw;
text-align: center;
line-height: 6.1vw;
transition: 0.2s;
}
.sidebaritem5 {
z-index: 1;
margin-bottom: 0.2vw;
color: #fff;
font-family: OSL;
width: 6vw;
background: #1b1b1b;
height: 4vw;
text-align: center;
line-height: 6.1vw;
transition: 0.2s;
}
.sidebaritem6 {
z-index: 1;
margin-bottom: 0.2vw;
color: #fff;
font-family: OSL;
width: 6vw;
background: #1b1b1b;
height: 4vw;
text-align: center;
line-height: 6.1vw;
transition: 0.2s;
}
.sidebaritem {
z-index: 1;
margin-bottom: 0.2vw;
color: #fff;
font-family: OSL;
width: 6vw;
background: #1b1b1b;
height: 4vw;
text-align: center;
line-height: 6.1vw;
transition: 0.2s;
}
.items {
position: absolute;
left: 5.5vw;
top: 2.5vw;
cursor: default;
width: 6vw;
}
.item {
}
ul {
float: left;
}
li {
display: block;
}
.titlecount {
position: absolute;
font-size: 0.7vw;
width: 16.3vw;
top: 0vw;
background: #1b1b1b;
padding-top: 1.8vw;
left: -1vw;
padding-right: 10vw;
padding-left: 0.2vw;
}
.sideicon1 {
padding-top: 0.2vw;
}
.sideicon2 {
padding-top: 0.2vw;
}
.sideicon3 {
padding-top: 0.2vw !important;
}
.sideicon4 {
padding-top: 0.2vw;
}
.sideicon5 {
}
.sideicon6 {
}
.sideicon7 {
width: 5vw;
}
.sideicon8 {
width: 5vw;
}
.sideicon9 {
width: 5vw;
}
.sideicon10 {
width: 5vw;
}
.sideicon11 {
width: 5vw;
}
.sideicon12 {
width: 5vw;
}
.sideicon13 {
width: 5vw;
}
.sideicon14 {
width: 5vw;
}
.sideicon15 {
width: 2vw;
}
.sideicon16 {
width: 5vw;
}
.sideicon17 {
width: 5vw;
}
.sideicon18 {
width: 5vw;
}
.sideicon7, .sideicon8, .sideicon9, .sideicon10, .sideicon11, .sideicon12, .sideicon13, .sideicon14, .sideicon15, .sideicon16, .sideicon17, .sideicon18 {
position: absolute;
left: 2.1vw;
top: 0.6vw;
}
.sideicon1, .sideicon2, .sideicon3, .sideicon4, .sideicon5, .sideicon6 {
width: 2vw;
padding-bottom: 1.8vw;
}
.bartext {
margin-top: -6.5vw;
font-size: 0.8vw;
}
.sidebaritem1:hover {
background: #131313;
}
.sidebaritem2:hover {
background: #131313;
}
.sidebaritem3:hover {
background: #131313;
}
.sidebaritem4:hover {
background: #131313;
}
.sidebaritem5:hover {
background: #131313;
}
.sidebaritem6:hover {
background: #131313;
}
li.item1 {
}
li.item2 {
top: -22vw;
left: 9vw;
}
li.item3 {
top: -46vw;
left: 16vw;
}
li.item4 {
top: -70vw;
left: 23vw;
}
li.item5 {
top: -94vw;
left: 30vw;
}
li.item6 {
top: -118vw;
left: 37vw;
}
.item1, .item2, .item3, .item4, .item5, .item6 {
color: #fff;
font-family: 'OSL';
position: relative;
margin-bottom: 2vw;
color: #fff;
font-family: OSL;
width: 6vw;
background: #1b1b1b;
height: 4vw;
text-align: center;
line-height: 6.5vw;
transition: 0.2s;
font-size: 0.5vw;
left: 2vw;
top: 2vw;
}
.show {
display: show !important;
}
.hidden {
display: none !important;
}
.green {
z-index: 1;
position: relative;
width: 6vw;
background: #55ff0096;
height: 4vw;
line-height: 1;
top: -8vw;
cursor: pointer;
opacity: 0.0;
transition: 0.3s;
}
.green:hover {
opacity: 1
}
.red {
z-index: 1;
position: relative;
width: 2.5vw;
left: 3.5vw;
background: #6d2525;
height: 1.5vw;
line-height: 1;
top: -2.4vw;
cursor: pointer;
opacity: 0.5;
transition: 0.3s;
}
.red:hover {
opacity: 1
}
.blue {
z-index: 1;
position: relative;
width: 2.5vw;
left: 0vw;
background: #0d91af8c;
height: 1.5vw;
line-height: 1;
top: -7.9vw;
cursor: pointer;
opacity: 0.5;
transition: 0.3s;
}
.blue:hover {
opacity: 1
}
.blue2 {
z-index: 1;
position: relative;
width: 2.5vw;
left: 0vw;
background: #0d91af8c;
height: 1.5vw;
line-height: 1;
top: -3.9vw;
cursor: pointer;
opacity: 0.5;
transition: 0.3s;
}
.blue2:hover {
opacity: 1
}
.redImg {
width: 1.3vw;
margin-top: 0.1vw;
}
.blueImg {
width: 1.3vw;
margin-top: 0.1vw;
}
.greenImg {
width: 1.3vw;
margin-top: 1.2vw;
}
body select {
display: block;
padding: 10px 70px 11px 13px !important;
margin-top: -29.9vw;
margin-left: -30.6vw;
height: auto !important;
border: 1px solid #000000;
border-radius: 3px;
background: url(https://i.ibb.co/b7xjLrB/selectbox-arrow.png) right center no-repeat;
background-color: #404040;
color: #fffbfb;
font-size: 12px;
line-height: 12px !important;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
}
/* body select.select_box option */
body select option {
padding: 0 4px;
}
/* for IE and Edge */
select::-ms-expand {
display: none;
}
select:disabled::-ms-expand {
background: #f60;
}
.Betrag {
z-index: 2;
background: rgba(0,0,0,0.6);
height: 100%;
width: 100%;
display: block;
transform: translate(-50%, -50%);
position: absolute;
left: 50%;
top: 50%;
}
.Betrag4 {
z-index: 2;
background: rgba(0,0,0,0.6);
height: 100%;
width: 100%;
display: block;
transform: translate(-50%, -50%);
position: absolute;
left: 50%;
top: 50%;
}
.Betrag3 {
z-index: 2;
background: rgba(0,0,0,0.6);
height: 100%;
width: 100%;
display: block;
transform: translate(-50%, -50%);
position: absolute;
left: 50%;
top: 50%;
}
.Betrag2 {
z-index: 2;
background: rgba(0,0,0,0.6);
height: 100%;
width: 100%;
display: block;
transform: translate(-50%, -50%);
position: absolute;
left: 50%;
top: 50%;
}
t#tf_nameorid {
background-color: #313131;
border: none;
height: 1.2vw;
width: 6vw;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
position: relative;
left: -30.1vw;
top: -29.9vw;
color: #ffffff;
}
#tf_submitTrade {
background-color: #267d00;
border: none;
height: 1.2vw;
width: 4vw;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
font-color: white;
position: relative;
left: -30vw;
top: -29.9vw;
color: #ffffff;
opacity: 0.5;
transition: 0.3s;
}
#tf_submitTrade {
opacity: 1;
}
#tf_zahl {
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: 42%;
top: 40%;
color: #ffffff;
}
#tf_cancle {
background-color: #ff0000;
border: none;
height: 32px;
width: 124px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
font-color: white;
position: relative;
left: 33.7%;
top: 44%;
color: #ffffff;
opacity: 0.5;
transition: 0.3s;
}
#tf_submitZahl {
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: 42%;
top: 40%;
color: #ffffff;
opacity: 0.5;
transition: 0.3s;
}
#tf_submitZahl {
opacity: 1;
}
#tf_zahl4 {
background-color: #313131;
border: none;
height: 1.5vw;
width: 5vw;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 0.5vw;
position: relative;
left: 19vw;
top: 13vw;
color: #ffffff;
}
#tf_cancle4 {
background-color: #ff0000;
border: none;
height: 0.9vw;
width: 3vw;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
font-color: white;
position: relative;
left: 17.8vw;
top: 9.4vw;
color: #ffffff;
opacity: 0.5;
transition: 0.3s;
}
#tf_cancle4 {
opacity: 1;
}
#tf_submitZahl4 {
background-color: #008CBA;
border: none;
height: 1.5vw;
width: 8vw;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 0.5vw;
font-color: white;
position: relative;
left: 21vw;
top: 13vw;
color: #ffffff;
opacity: 0.5;
transition: 0.3s;
}
#tf_submitZahl4 {
opacity: 1;
}
#tf_submitTrade {
background-color: #009b03;
border: none;
height: 1.6vw;
width: 4vw;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 0.5vw;
font-color: white;
position: absolute;
color: #ffffff;
top: 3vw;
left: 29.3vw;
opacity: 0.5;
transition: 0.3s;
}
#tf_submitTrade:hover {
opacity: 1;
}
#tf_cancle3 {
background-color: #ff0000;
border: none;
height: 0.9vw;
width: 3vw;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
font-color: white;
position: relative;
left: 17.8vw;
top: 9.4vw;
color: #ffffff;
opacity: 0.5;
transition: 0.3s;
}
#tf_cancle3:hover {
opacity: 1
}
#tf_cancle:hover {
opacity: 1
}
#tf_cancle2:hover {
opacity: 1
}
#tf_zahl3 {
background-color: #313131;
border: none;
height: 1.5vw;
width: 5vw;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 0.5vw;
position: relative;
left: 19vw;
top: 13vw;
color: #ffffff;
}
#tf_submitZahl3 {
background-color: #008CBA;
border: none;
height: 1.5vw;
width: 8vw;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 0.5vw;
font-color: white;
position: relative;
left: 21vw;
top: 13vw;
color: #ffffff;
opacity: 0.5;
transition: 0.3s;
}
#tf_submitZahl3 {
opacity: 1;
}
.BoxBlue {
background-color: #1b1b1b;
height: 10vw;
width: 20vw;
position: relative;
margin-top: 11vw;
margin-left: 16vw;
}
#tf_cancle2 {
background-color: #ff0000;
border: none;
height: 1vw;
width: 3vw;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 0.5vw;
position: relative;
left: 5.45vw;
top: 0vw;
color: #ffffff;
}
#tf_submitZahlToHandel {
background-color: #008CBA;
border: none;
height: 1vw;
width: 7vw;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 0.4vw;
position: relative;
left: -3vw;
top: 7vw;
color: #ffffff;
opacity: 0.5;
transition: 0.3s;
}
#tf_submitZahlToHandel:hover {
opacity: 1;
}
#tf_submitZahlToVehicle {
background-color: #008CBA;
border: none;
height: 1vw;
width: 8vw;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 0.5vw;
position: relative;
left: 10.8vw;
top: 5.95vw;
color: #ffffff;
opacity: 0.5;
transition: 0.3s;
}
#tf_submitZahlToVehicle:hover {
opacity: 1
}
#tf_zahl2 {
background-color: #313131;
border: none;
height: 1vw;
width: 4.3vw;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 0.5vw;
position: relative;
left: 7.5vw;
top: 4.4vw;
color: #ffffff;
}
select.select_box2 {
margin-top: -1vw;
margin-left: 11.3vw;
}
.blueIcon1 {
position: relative;
height: 3vw;
margin-bottom: -4vw;
margin-left: 13.4vw;
}
.blueIcon2 {
position: relative;
height: 3vw;
margin-bottom: -3.1vw;
margin-left: 3.4vw;
}
.blue3 {
z-index: 1;
position: relative;
width: 2.5vw;
left: 0vw;
background: #0d91af8c;
height: 1.5vw;
line-height: 1;
top: -2.45vw;
z-index: 10000;
cursor: pointer;
opacity: 0.5;
transition: 0.3s;
}
.blue3:hover {
opacity: 1
}
#tf_nameorid {
background-color: #313131;
border: none;
height: 1.5vw;
width: 6vw;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
position: absolute;
left: 23vw;
top: 3vw;
color: #ffffff;
}

View File

@@ -1,24 +0,0 @@
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Inventory</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div class="pakWrapper">
<div>
<div class=box1><h2> Handel Akzeptieren</h2></div>
<div class=box2><h4 id="gewicht"> Preis: 0$</h4></div>
</div>
<div id="invContainer">
</div>
<button id='buttonakzeptieren' onclick="akzeptieren()">Akzeptieren</button>
<button id='buttonablehnen' onclick="ablehnen()">Ablehnen</button>
</div>
<script src="package://assets/js/jquery-3.3.1.min.js" type="text/javascript"></script>
<script src="./script.js"></script>
</body>
</html>

View File

@@ -1,336 +0,0 @@
$(document).ready(function () {
//fire functions before page load
drawToPage();
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 holz = {
name: "Holz",
rarity: 'common',
selected: 'false',
usable: 'true',
amount: 1,
currentWeight: 0.65,
stackable: 'true',
object: 'true',
itemId: 1,
img: "package://assets/img/items/wood.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 flunder = {
name: "Flunder",
weight: 7.7,
currentWeight: 1,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 5,
img: 'package://assets/img/items/flounder.svg'
}
var aal = {
name: "Aal",
weight: 3.6,
currentWeight: 1,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 6,
img: 'package://assets/img/items/aal.svg'
}
var barsch = {
name: "Barsch",
weight: 2.6,
currentWeight: 1,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 7,
img: 'package://assets/img/items/perch.svg'
}
var lachs = {
name: "Lachs",
weight: 4.2,
currentWeight: 1,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 8,
img: 'package://assets/img/items/salmon.svg'
}
var thunfisch = {
name: "Thunfisch",
weight: 11,
currentWeight: 1,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 9,
img: 'package://assets/img/items/salmon.svg'
}
var zander = {
name: "Zander",
weight: 5,
currentWeight: 1,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 10,
img: 'package://assets/img/items/zander.svg'
}
var allItems = [holz, hamburger, cocaine, cannabis, flunder, aal, barsch, lachs, thunfisch, zander];
////////////////////////
// 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();
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();
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();
break;
}
else if (unfininshedStack == undefined && playerInventory[i].object === 'false') {
playerInventory[i] = cloneItem;
drawToPage();
break;
}
}
}
var getItemSlotData;
function getAllItemSlotData() {
getItemSlotData = document.getElementsByClassName('itemSlot');
}
var currentSelected;
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();
},
}
//Handel Akzeptierenfenster
$("#buttonakzeptieren").click(function () {
mp.trigger('CEF:acceptTrade');
});
$("#buttonablehnen").click(function () {
mp.trigger('CEF:declineTrade');
});

View File

@@ -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 */

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 662 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 487.62 487.62" style="enable-background:new 0 0 487.62 487.62;" xml:space="preserve">
<g>
<g>
<circle style="fill:#EED26A;" cx="243.81" cy="243.81" r="243.81"/>
<circle style="fill:#D97077;" cx="243.81" cy="243.81" r="243.81"/>
<path style="fill:#CA6168;" d="M478.911,308.624l-89.888-88.498l-48.789,0.011l-87.074-68.253l-107.582,69.344l-9.862,61.071
l193.077,190.094C401.735,445.267,458.1,384.258,478.911,308.624z"/>
<polygon style="fill:#FFFFFF;" points="98.053,244.956 222.413,368.263 254.59,335.58 184.584,267.215 389.746,265.618
389.389,219.754 184.206,221.352 253.16,151.884 220.477,119.706 "/>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
<g>
<g>
<path style="fill:#E3001E;" d="M368.11,40h40c8.837,0,16,7.163,16,16v92c0,3.375-2.117,6.391-5.297,7.531
c-0.883,0.316-1.797,0.469-2.703,0.469c-2.344,0-4.625-1.031-6.172-2.914l-56.006-68.007c-1.178-1.43-1.822-3.226-1.822-5.078V56
C352.11,47.163,359.274,40,368.11,40z"/>
</g>
<g>
<path style="fill:#E3001E;" d="M144.329,40h-40c-8.837,0-16,7.163-16,16v92c0,3.375,2.117,6.391,5.297,7.531
c0.883,0.316,1.797,0.469,2.703,0.469c2.344,0,4.625-1.031,6.172-2.914l56.006-68.007c1.178-1.43,1.822-3.226,1.822-5.078V56
C160.329,47.163,153.165,40,144.329,40z"/>
</g>
<g>
<g>
<path style="fill:#5C546A;" d="M320.329,64c-4.422,0-8-3.582-8-8V32c0-4.418-3.582-8-8-8h-96c-4.418,0-8,3.582-8,8v24
c0,4.418-3.578,8-8,8s-8-3.582-8-8V32c0-17.673,14.327-32,32-32h80c17.673,0,32,14.327,32,32v24
C328.329,60.418,324.751,64,320.329,64z"/>
</g>
</g>
<g>
<path style="fill:#FF4F19;" d="M80.329,272h-16c-13.234,0-24,10.766-24,24v144c0,13.234,10.766,24,24,24h16c4.422,0,8-3.582,8-8
V280C88.329,275.582,84.751,272,80.329,272z"/>
</g>
<g>
<rect x="40.11" y="320" style="fill:#E3001E;" width="40" height="16"/>
</g>
<g>
<path style="fill:#FF4F19;" d="M432.038,272h15.855c13.114,0,23.782,10.766,23.782,24v144c0,13.234-10.668,24-23.782,24h-15.855
c-4.382,0-7.927-3.582-7.927-8V280C424.11,275.582,427.656,272,432.038,272z"/>
</g>
<g>
<rect x="432.254" y="320" style="fill:#E3001E;" width="39.637" height="16"/>
</g>
<g>
<path style="fill:#FFCD00;" d="M256.329,40c-101.461,0-184,82.543-184,184v216c0,39.699,32.297,72,72,72h224
c39.703,0,72-32.301,72-72V224C440.329,122.543,357.79,40,256.329,40z"/>
</g>
<g>
<path style="fill:#FF4F19;" d="M368.329,272h-224c-13.234,0-24,10.766-24,24v144c0,13.234,10.766,24,24,24h224
c13.234,0,24-10.766,24-24V296C392.329,282.766,381.563,272,368.329,272z"/>
</g>
<g>
<path style="fill:#FF4F19;" d="M322.267,123.777C302.665,110.84,279.86,104,256.329,104s-46.336,6.84-65.937,19.773
c-8.805,5.809-14.063,15.738-14.063,26.563V224c0,4.418,3.578,8,8,8h144c4.422,0,8-3.582,8-8v-73.664
C336.329,139.512,331.071,129.582,322.267,123.777z"/>
</g>
<g>
<g>
<path style="fill:#E3001E;" d="M272.11,160h-31.562c-8.836,0-16-7.164-16-16s7.164-16,16-16h31.562c8.836,0,16,7.164,16,16
S280.946,160,272.11,160z"/>
</g>
</g>
<g>
<rect x="120.11" y="320" style="fill:#E3001E;" width="272" height="16"/>
</g>
<g>
<g>
<path style="fill:#5C546A;" d="M176.329,368c-4.422,0-8-3.582-8-8v-32c0-4.418,3.578-8,8-8s8,3.582,8,8v32
C184.329,364.418,180.751,368,176.329,368z"/>
</g>
</g>
<g>
<path style="fill:#FFE671;" d="M184.109,400h-16c-4.418,0-8-3.582-8-8v-24c0-8.837,7.163-16,16-16l0,0c8.837,0,16,7.163,16,16v24
C192.109,396.418,188.529,400,184.109,400z"/>
</g>
<g>
<path style="fill:#FF4F19;" d="M415.493,216c-4.094,0-7.508-3.195-7.938-7.434C399.704,130.711,334.688,72,256.329,72
s-143.375,58.711-151.227,136.566c-0.43,4.238-3.844,7.434-7.937,7.434H72.532c-0.114,2.655-0.203,5.317-0.203,8v8h24.836
c12.344,0,22.602-9.383,23.859-21.824C128.048,140.523,186.219,88,256.329,88s128.281,52.523,135.305,122.176
C392.892,222.617,403.149,232,415.493,232h24.617c0.078,0,0.142-0.042,0.219-0.044V224c0-2.682-0.088-5.342-0.203-7.997
c-0.006,0-0.01-0.003-0.016-0.003H415.493z"/>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 496.474 496.474" style="enable-background:new 0 0 496.474 496.474;" xml:space="preserve">
<path style="fill:#E95353;" d="M489.544,269.628c-0.729-14.739-6.206-28.858-15.205-40.572
c-20.294-26.422-24.25-47.399-24.25-47.399c-15.934-41.751-30.099-69.57-40.51-87.226c-10.954-18.541-29.898-31.03-51.262-33.776
c-42.961-5.554-177.23-5.554-220.191,0c-21.349,2.762-40.293,15.251-51.247,33.776c-10.411,17.656-24.56,45.475-40.51,87.226
c0,0-3.956,20.977-24.25,47.399c-8.983,11.714-14.476,25.833-15.189,40.572c-1.536,31.977,7.727,39.005,16.012,111.368
c0.652,5.694,5.461,9.976,11.202,9.976h428.203c5.741,0,10.55-4.298,11.202-9.976c2.327-20.294,9.232-61.456,9.232-61.456
C488.83,299.076,490.149,282.397,489.544,269.628z"/>
<path style="fill:#168DE2;" d="M441.074,179.982c-12.567-31.449-25.383-58.911-38.136-80.803
c-9.666-16.555-26.717-28.113-45.583-30.642c-43.055-5.71-175.476-5.663-218.221,0c-18.866,2.529-35.918,14.088-45.584,30.642
c-12.924,22.171-25.91,50.005-38.291,80.803C183.662,190.082,312.655,190.082,441.074,179.982z"/>
<path style="fill:#FFFFFF;" d="M422.844,216.349c-4.903,1.536-9.464,3.693-13.281,5.834c-6.951,3.879-14.088,7.494-21.535,10.318
c-12.35,4.686-14.445,11.683-14.445,11.683c-0.372,0.481-0.729,0.962-1.071,1.458c-9.371,13.917,2.932,32.442,19.549,30.084
c24.033-3.398,43.83-10.364,53.884-14.398c5.756-2.312,10.255-7.121,11.729-13.157c0.14-0.574,0.264-1.148,0.372-1.707
C461.74,226.543,442.191,210.314,422.844,216.349z"/>
<path style="fill:#FFE21F;" d="M448.522,327.857h-26.733c-4.018,0-6.035,4.856-3.196,7.711l26.733,26.733
c2.839,2.839,7.711,0.822,7.711-3.196v-26.733C453.036,329.874,451.019,327.857,448.522,327.857z"/>
<path style="fill:#454545;" d="M473.547,380.965c-0.652,5.71-5.477,10.007-11.217,10.007h-51.433v29.851
c0,10.566,8.564,19.146,19.146,19.146h32.303c10.566,0,19.146-8.564,19.146-19.146v-93.448
C479.366,340.315,475.239,366.179,473.547,380.965z"/>
<path style="fill:#ED6262;" d="M496.107,159.083c-1.552-6.951-8.083-11.667-15.205-11.667h-12.909
c-8.27,0-14.972,6.703-14.972,14.972v9.2h-6.842l3.925,9.325h15.05c7.789,0,15.5-1.676,22.575-4.918
C494.105,173.078,497.674,166.096,496.107,159.083z"/>
<circle style="fill:#FFBD49;" cx="431.315" cy="240.46" r="18.82"/>
<circle style="fill:#FFDB6F;" cx="393.458" cy="255.308" r="13.824"/>
<polygon style="fill:#6F6F6F;" points="357.634,255.324 336.021,292.963 160.452,292.963 138.839,255.324 "/>
<path style="fill:#FFFFFF;" d="M123.945,245.642c-0.326-0.496-0.683-0.977-1.071-1.458c0,0-2.095-6.997-14.445-11.683
c-7.447-2.824-14.569-6.439-21.535-10.318c-3.832-2.141-8.378-4.298-13.281-5.834c-19.332-6.051-38.896,10.193-35.219,30.115
c0.109,0.574,0.233,1.133,0.357,1.707c1.474,6.035,5.973,10.845,11.729,13.157c10.054,4.034,29.851,11,53.9,14.398
C121.012,278.084,133.316,259.559,123.945,245.642z"/>
<path style="fill:#FFE21F;" d="M74.684,327.857H47.951c-2.498,0-4.515,2.017-4.515,4.515v26.733c0,4.018,4.872,6.035,7.711,3.196
l26.733-26.733C80.719,332.729,78.702,327.857,74.684,327.857z"/>
<path style="fill:#777777;" d="M426.226,374.511c-27.834-48.159-59.842-46.654-59.842-46.654H130.073
c0,0-31.992-1.505-59.842,46.654H22.119l0.59,6.206c0.543,5.834,5.415,10.256,11.248,10.256h428.56
c5.834,0,10.705-4.422,11.249-10.255l0.59-6.206L426.226,374.511L426.226,374.511z"/>
<path style="fill:#454545;" d="M34.143,390.988c-5.741,0-10.566-4.313-11.217-10.007c-1.691-14.786-5.834-40.665-7.944-53.589
v93.448c0,10.566,8.564,19.146,19.146,19.146H66.43c10.566,0,19.146-8.564,19.146-19.146v-29.851H34.143z"/>
<path style="fill:#ED6262;" d="M43.436,171.588v-9.2c0-8.27-6.703-14.972-14.957-14.972H15.571c-7.121,0-13.653,4.717-15.205,11.667
c-1.567,6.997,2.017,13.995,8.378,16.896c7.09,3.243,14.786,4.918,22.575,4.918h15.05l3.925-9.325h-6.858V171.588z"/>
<circle style="fill:#FFBD49;" cx="65.142" cy="240.46" r="18.82"/>
<circle style="fill:#FFDB6F;" cx="103.03" cy="255.308" r="13.824"/>
<g>
<path style="fill:#6F6F6F;" d="M348.294,341.029H148.179c-3.134,0-5.663,2.544-5.663,5.663c0,3.134,2.529,5.663,5.663,5.663
h200.099c3.134,0,5.663-2.544,5.663-5.663C353.957,343.558,351.412,341.029,348.294,341.029z"/>
<path style="fill:#6F6F6F;" d="M348.294,363.635H148.179c-3.134,0-5.663,2.544-5.663,5.663c0,3.134,2.529,5.663,5.663,5.663
h200.099c3.134,0,5.663-2.544,5.663-5.663C353.957,366.164,351.412,363.635,348.294,363.635z"/>
</g>
<path style="fill:#3AA2EB;" d="M420.098,132.009v1.939c0,7.804-6.408,14.057-14.367,13.731c-7.339-0.465-12.955-7.028-12.955-14.522
v-27.834c0-6.563-5.461-11.559-12.024-11.388c-0.155,0-0.155,0-0.31,0c0,0,0,0-0.155,0c-6.563-0.155-12.024,4.841-12.024,11.388
v25.181c0,7.804-6.718,14.057-14.522,13.576c-7.339-0.31-12.955-7.028-12.955-14.367v-21.892c0-6.563-5.461-12.024-12.179-12.024
h-0.931c-6.253,0-11.404,5.151-11.404,11.404v28.47c0,7.804-6.563,14.041-14.522,13.731c-7.339-0.465-12.8-7.028-12.8-14.522V96.712
c0-6.082-5.306-11.233-11.559-10.768h-0.931c-6.408,0-11.543,5.151-11.543,11.404v39.021c0,7.494-6.082,13.731-13.731,13.731
c-7.339,0-13.421-5.927-13.576-13.265v-32.752c0-7.494-5.616-14.041-12.955-14.522c-7.959-0.31-14.367,5.927-14.367,13.731
l-0.155,30.255c0,7.804-6.392,14.041-14.367,13.731c-7.199-0.45-12.66-6.78-12.878-13.948V97.829c0-7.37-5.539-13.964-12.909-14.398
c-7.897-0.341-14.414,5.88-14.414,13.7v37.19c-0.217,7.618-6.609,13.684-14.445,13.374c-7.339-0.465-12.8-7.028-12.8-14.522v-27.85
c0-6.563-5.616-11.559-12.179-11.388c-0.155,0-0.155,0-0.155,0c-0.155,0-0.155,0-0.155,0c-6.718-0.155-12.179,4.841-12.179,11.388
v25.181c0,7.804-6.563,14.057-14.367,13.576c-6.796-0.264-11.854-5.942-12.722-12.521c-7.215,14.941-14.367,31.123-21.318,48.407
c128.403,10.116,257.412,10.116,385.815,0C434.139,162.636,427.126,146.655,420.098,132.009z"/>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 56 56" style="enable-background:new 0 0 56 56;" xml:space="preserve">
<g id="XMLID_80_">
<rect id="XMLID_115_" y="16" style="fill:#56B46F;" width="56" height="32"/>
<polygon id="XMLID_114_" style="fill:#74BE86;" points="52,16 2,16 2,12 "/>
<path id="XMLID_79_" style="fill:#4D8157;" d="M41,32c0,7.18-5.82,13-13,13c-7.18,0-13-5.82-13-13c0-7.18,5.82-13,13-13
C35.18,19,41,24.82,41,32"/>
<path id="XMLID_112_" style="fill:#EAEAD7;" d="M21.094,43C17.438,40.699,15,36.639,15,32c0-4.639,2.438-8.699,6.094-11H10.975
C10.99,21.165,11,21.331,11,21.5c0,3.038-2.463,5.5-5.5,5.5c-0.169,0-0.335-0.01-0.5-0.025v10.05C5.165,37.01,5.331,37,5.5,37
c3.037,0,5.5,2.462,5.5,5.5c0,0.169-0.01,0.335-0.025,0.5H21.094z"/>
<path id="XMLID_111_" style="fill:#EAEAD7;" d="M50.5,27c-3.038,0-5.5-2.462-5.5-5.5c0-0.169,0.01-0.335,0.025-0.5H34.906
C38.562,23.301,41,27.361,41,32c0,4.639-2.438,8.699-6.094,11h10.119C45.01,42.835,45,42.669,45,42.5c0-3.038,2.462-5.5,5.5-5.5
c0.169,0,0.335,0.01,0.5,0.025v-10.05C50.835,26.99,50.669,27,50.5,27"/>
<path id="XMLID_110_" style="fill:#EAEAD7;" d="M5.5,24C4.121,24,3,22.879,3,21.5S4.121,19,5.5,19C6.879,19,8,20.121,8,21.5
S6.879,24,5.5,24"/>
<path id="XMLID_109_" style="fill:#EAEAD7;" d="M50.5,24c-1.379,0-2.5-1.121-2.5-2.5s1.121-2.5,2.5-2.5c1.379,0,2.5,1.121,2.5,2.5
S51.879,24,50.5,24"/>
<path id="XMLID_108_" style="fill:#EAEAD7;" d="M5.5,45C4.121,45,3,43.879,3,42.5S4.121,40,5.5,40C6.879,40,8,41.121,8,42.5
S6.879,45,5.5,45"/>
<path id="XMLID_107_" style="fill:#EAEAD7;" d="M50.5,45c-1.379,0-2.5-1.121-2.5-2.5s1.121-2.5,2.5-2.5c1.379,0,2.5,1.121,2.5,2.5
S51.879,45,50.5,45"/>
<polygon id="XMLID_106_" style="fill:#83C38E;" points="5,8 5,12.24 52,16 55,16 "/>
<path id="XMLID_105_" style="fill:#EAEAD7;" d="M33.568,35.025c0.71-0.22,1.232-0.876,1.232-1.656v-0.87
c0-0.667-0.384-1.243-0.938-1.535c-0.384-3.274-2.548-4.599-6.027-4.599c-0.164,0-0.326,0.006-0.484,0.019
c-1.183,0.094-2.379-0.128-3.362-0.791c-0.409-0.276-0.753-0.568-0.995-0.876c-0.111-0.14-0.332-0.051-0.311,0.127
c0.035,0.304,0.086,0.66,0.164,1.048c0.287,1.445,0.115,1.234-0.444,2.598c-0.309,0.754-0.508,1.591-0.601,2.477
c-0.55,0.294-0.932,0.867-0.932,1.532v0.87c0,0.78,0.523,1.436,1.232,1.656c0.471,1.762,1.438,3.171,3.121,3.896v0.997
c0,0.255-0.145,0.487-0.373,0.6l-3.361,1.656c-0.291,0.158-0.531,0.375-0.745,0.614C22.816,44.184,25.313,45,28,45
c2.587,0,4.992-0.765,7.017-2.068c-0.249-0.302-0.562-0.554-0.926-0.736l-3.279-1.676c-0.224-0.114-0.365-0.344-0.365-0.595v-1.004
C32.13,38.196,33.097,36.787,33.568,35.025"/>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
<g>
<g>
<g>
<path d="M508.271,194.568l-149.333-128c-3.146-2.708-7.583-3.323-11.396-1.594c-3.781,1.74-6.208,5.521-6.208,9.688v74.813
c-119.188,3.313-176.688,62.312-204.021,112.031c-23.771,43.219-29.104,86.01-30.302,103.573
c-0.229,2.688-0.344,5.427-0.344,8.219v0.031c0,0,0,0.01,0,0.021v0.01c0,0.01,0,0.01,0,0.01v0.031v0.01c0,0,0,0.01,0,0.021v0.01
c0,0.01,0,0.021,0,0.021c0,0.01,0,0.01,0,0.01v0.031c0,0.01,0,0.021,0,0.031c0,0,0,0.01,0,0.031v0.01v0.021v0.01
c0,0.01,0,0.021,0,0.031l0.01,0.031c0,0,0,0,0,0.01c0,0.021,0,0.031,0,0.031c0,0.01,0,0.021,0,0.031v0.031v0.031v0.01v0.031
c0,0.01,0,0.021,0,0.031c0,0,0,0.021,0.01,0.031c0,0,0,0.01,0,0.031v0.01c0,0.01,0,0.021,0,0.031v0.031c0,0.01,0,0.021,0,0.031
c-0.01,0.031,0.021,0.042,0.01,0.042v0.031c0,0.01,0,0.021,0,0.031v0.031c0,0.021,0.01,0.042,0.01,0.042v0.031
c0,0.01,0,0.021,0,0.031v0.01v0.021v0.01l0.01,0.021v0.01c0,0.01,0,0.021,0,0.021c0,0.01,0,0.01,0,0.01v0.031v0.01
c0.01,0.01,0.01,0.01,0.01,0.021c0,0,0,0.01,0,0.021v0.01c0,0.01,0,0.01,0,0.01v0.021c0.01,0.031,0.01,0.031,0.01,0.031
c0,0.01,0,0.021,0,0.031v0.01v0.021v0.01c0.01,0.01,0.01,0.021,0.01,0.021c0,0.021,0,0.031,0,0.031
c0.667,5.26,5.156,9.323,10.583,9.323c5.885,0,10.656-4.76,10.667-10.646v-0.01c0-0.542,0.01-1.865,0.104-3.885
c4.656-88.698,168.521-108.823,213.229-112.667v73.875c0,4.167,2.427,7.948,6.208,9.688c3.802,1.729,8.229,1.125,11.396-1.594
l149.333-128c2.365-2.021,3.729-4.979,3.729-8.094C512,199.547,510.635,196.589,508.271,194.568z M362.667,307.474v-62.146
c0-2.917-1.188-5.698-3.302-7.708c-1.979-1.906-4.625-2.958-7.365-2.958c-0.156,0-0.323,0-0.49,0.01
c-7.51,0.344-142.177,7.281-208.521,64.323c21.948-57.885,75.969-128.333,208.958-128.333H352c2.833,0,5.542-1.125,7.542-3.125
s3.125-4.708,3.125-7.542V97.849l122.281,104.812L362.667,307.474z"/>
<path d="M437.333,303.047c-5.896,0-10.667,4.771-10.667,10.667v91.615c0,11.76-9.573,21.333-21.333,21.333H42.667
c-11.76,0-21.333-9.573-21.333-21.333V191.995c0-11.76,9.573-21.333,21.333-21.333h147.729c5.896,0,10.667-4.771,10.667-10.667
s-4.771-10.667-10.667-10.667H42.667C19.135,149.329,0,168.464,0,191.995v213.333c0,23.531,19.135,42.667,42.667,42.667h362.667
c23.531,0,42.667-19.135,42.667-42.667v-91.615C448,307.818,443.229,303.047,437.333,303.047z"/>
</g>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -0,0 +1 @@
<svg height="479pt" viewBox="-33 0 479 479.75203" width="479pt" xmlns="http://www.w3.org/2000/svg"><path d="m300.964844 398.578125 70.199218-33.15625c15.480469-7.816406 34.363282-2.085937 42.890626 13.007813l-142.6875 92.300781c-19.132813 8.828125-40.601563 11.257812-61.222657 6.929687l-98.410156-27.621094c-9.054687-2.539062-18.746094-1.480468-27.039063 2.960938l-20.578124 11.011719 2.769531-100.371094.820312.019531c29.40625-20.894531 68.027344-23.597656 100.058594-7l5.890625 3.050782c9.210938 4.769531 19.378906 7.398437 29.75 7.679687l57.851562 1.597656c18.152344.496094 34.042969 12.335938 39.707032 29.589844zm0 0" fill="#f7caa5"/><path d="m320.226562 222.5c0 59.652344-48.359374 108.011719-108.011718 108.011719s-108.007813-48.359375-108.007813-108.011719 48.355469-108.011719 108.007813-108.011719 108.011718 48.359375 108.011718 108.011719zm0 0" fill="#fedb41"/><path d="m212.214844 213.878906c-10.027344 0-18.160156-8.128906-18.160156-18.160156 0-10.027344 8.132812-18.160156 18.160156-18.160156 10.03125 0 18.160156 8.132812 18.160156 18.160156 0 4.417969 3.582031 8 8 8s8-3.582031 8-8c-.019531-16.160156-11.34375-30.101562-27.160156-33.433594v-7.285156c0-4.417969-3.582032-8-8-8-4.417969 0-8 3.582031-8 8v7.773438c-16.503906 4.503906-27.132813 20.53125-24.855469 37.488281 2.273437 16.960937 16.746094 29.621093 33.855469 29.617187 9.953125-.078125 18.117187 7.871094 18.300781 17.820313.183594 9.953125-7.683594 18.195312-17.632813 18.480469-.898437-.195313-1.820312-.230469-2.726562-.101563-9.1875-1.003906-16.136719-8.785156-16.101562-18.027344 0-4.417969-3.582032-8-8-8-4.417969 0-8 3.582031-8 8-.050782 15.417969 10.273437 28.941407 25.160156 32.957031v7.992188c0 4.417969 3.582031 8 8 8 4.417968 0 8-3.582031 8-8v-7.515625c17.132812-3.585937 28.78125-19.546875 26.980468-36.957031-1.804687-17.410156-16.472656-30.644532-33.980468-30.648438zm0 0" fill="#00acea"/><path d="m303.085938 421.179688h-.21875l-95.089844-2.621094c-4.417969-.121094-7.898438-3.800782-7.777344-8.214844.121094-4.417969 3.800781-7.898438 8.214844-7.777344l86.179687 2.375c-.265625-1.304687-.609375-2.589844-1.027343-3.855468-4.625-14.039063-17.550782-23.675782-32.328126-24.097657l-57.855468-1.601562c-11.570313-.328125-22.921875-3.261719-33.207032-8.574219l-5.886718-3.046875c-29.355469-15.300781-64.8125-12.820313-91.75 6.417969-3.601563 2.558594-8.597656 1.710937-11.15625-1.890625-2.558594-3.601563-1.710938-8.597657 1.890625-11.15625 31.816406-22.71875 73.699219-25.648438 108.371093-7.578125l5.890626 3.046875c8.140624 4.207031 17.125 6.523437 26.285156 6.789062l57.855468 1.597657c13.53125.363281 26.363282 6.089843 35.667969 15.921874 9.304688 9.828126 14.320313 22.957032 13.9375 36.484376-.117187 4.335937-3.664062 7.785156-8 7.78125zm0 0" fill="#edb288"/><g fill="#00acea"><path d="m212.214844 92c-4.417969 0-8-3.582031-8-8v-76c0-4.417969 3.582031-8 8-8 4.417968 0 8 3.582031 8 8v76c0 4.417969-3.582032 8-8 8zm0 0"/><path d="m272.214844 92c-4.417969 0-8-3.582031-8-8v-36c0-4.417969 3.582031-8 8-8 4.417968 0 8 3.582031 8 8v36c0 4.417969-3.582032 8-8 8zm0 0"/><path d="m152.214844 92c-4.417969 0-8-3.582031-8-8v-36c0-4.417969 3.582031-8 8-8 4.417968 0 8 3.582031 8 8v36c0 4.417969-3.582032 8-8 8zm0 0"/></g><path d="m64.117188 464.011719-.3125 11.296875-63.429688-1.738282 3.832031-139.210937 63.4375 1.742187-.757812 27.539063zm0 0" fill="#00efd1"/></svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -0,0 +1 @@
<svg height="512" viewBox="0 0 512 512" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m472 336h-144v-128.936a32 32 0 0 1 21.881-30.358l26.119-8.706v-24h48v24l26.119 8.706a32 32 0 0 1 21.881 30.358z" fill="#a8d6da"/><g fill="#b8eaee"><rect height="32" rx="16" width="176" x="312" y="264"/><rect height="32" rx="16" width="176" x="312" y="200"/><rect height="32" rx="16" width="160" x="320" y="328"/></g><path d="m368 112h64v32h-64z" fill="#e4e4e2"/><path d="m192 328v-64a80.013 80.013 0 0 0 -61.655-77.862l13.655-34.138h-64l13.655 34.138a80.013 80.013 0 0 0 -61.655 77.862v64l-8 16 8 16h160l8-16z" fill="#99d8aa"/><path d="m341.9 99.09-35.45-45.512-6.526 19.627a187.992 187.992 0 0 0 -169.261 42.668l10.67 11.922a172.011 172.011 0 0 1 153.524-39.349l-6.076 18.271z" fill="#6cbae5"/><path d="m388.18 389.688-11.25-11.376a172.256 172.256 0 0 1 -198.288 31.393l10.479-15.115-53.121-7.624 21.215 53.646 12.225-17.633a188.271 188.271 0 0 0 218.74-33.291z" fill="#428dc5"/><path d="m128 297.61a6.965 6.965 0 0 1 -3.5 6.034l-.954.544a23.357 23.357 0 0 1 -23.089 0l-.956-.546a6.963 6.963 0 0 1 -3.501-6.032v-1.61a6.933 6.933 0 0 1 3.094-5.781l34.687-23.125a22.948 22.948 0 0 0 0-38.188 39.292 39.292 0 0 0 -13.781-5.774v-15.132h-16v15.132a39.329 39.329 0 0 0 -13.781 5.774 22.9 22.9 0 0 0 -10.219 19.094v8h16v-8a6.933 6.933 0 0 1 3.094-5.781 23.2 23.2 0 0 1 25.812 0 6.948 6.948 0 0 1 0 11.562l-34.687 23.125a22.9 22.9 0 0 0 -10.219 19.094v1.61a23 23 0 0 0 11.562 19.924l.956.547a39.032 39.032 0 0 0 11.482 4.319v13.6h16v-13.6a39.041 39.041 0 0 0 11.483-4.322l.955-.545a23 23 0 0 0 11.562-19.923v-9.61h-16z" fill="#5e8569"/><path d="m376 144h48v16h-48z" fill="#9dc7cb"/></svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
<g>
<g>
<path d="M465.423,48.241h-137.61V23.955C327.813,10.746,317.082,0,303.893,0h-95.785c-13.19,0-23.92,10.746-23.92,23.955V48.24
H46.577c-6.655,0-12.049,5.394-12.049,12.049c0,6.655,5.394,12.049,12.049,12.049h22.332l15.228,396.396
C85.069,492.995,104.818,512,129.099,512h253.804c24.281,0,44.03-19.006,44.96-43.267l15.228-396.396h22.332
c6.653,0,12.049-5.394,12.049-12.049C477.472,53.635,472.078,48.241,465.423,48.241z M208.285,24.097h95.43v24.143h-95.43V24.097z
M403.784,467.809c-0.433,11.268-9.605,20.094-20.882,20.094H129.099c-11.276,0-20.448-8.827-20.882-20.095L93.025,72.338h325.952
L403.784,467.809z"/>
</g>
</g>
<g>
<g>
<path d="M182.63,181.571c-0.127-6.575-5.494-11.817-12.042-11.817c-0.078,0-0.158,0-0.236,0.002
c-6.652,0.128-11.943,5.626-11.815,12.278l3.781,196.634c0.126,6.575,5.495,11.817,12.042,11.817c0.078,0,0.158,0,0.236-0.002
c6.653-0.128,11.943-5.624,11.815-12.278L182.63,181.571z"/>
</g>
</g>
<g>
<g>
<path d="M255.998,169.753c-6.654,0-12.049,5.394-12.049,12.049v196.634c0,6.654,5.394,12.049,12.049,12.049
c6.655,0,12.049-5.394,12.049-12.049V181.802C268.047,175.148,262.653,169.753,255.998,169.753z"/>
</g>
</g>
<g>
<g>
<path d="M341.645,169.756c-6.628-0.147-12.151,5.162-12.278,11.815l-3.781,196.634c-0.129,6.653,5.162,12.15,11.815,12.278
c0.078,0.001,0.158,0.002,0.236,0.002c6.546,0,11.916-5.244,12.042-11.817l3.781-196.634
C353.588,175.38,348.299,169.883,341.645,169.756z"/>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
<g>
<g>
<g>
<path d="M256,0C114.844,0,0,114.844,0,256s114.844,256,256,256s256-114.844,256-256S397.156,0,256,0z M256,490.667
C126.604,490.667,21.333,385.396,21.333,256S126.604,21.333,256,21.333S490.667,126.604,490.667,256S385.396,490.667,256,490.667
z"/>
<path d="M387.125,152.458L202.667,336.917l-99.125-99.125c-4.167-4.167-10.917-4.167-15.083,0
c-4.167,4.167-4.167,10.917,0,15.083l106.667,106.667c2.083,2.083,4.813,3.125,7.542,3.125c2.729,0,5.458-1.042,7.542-3.125
l192-192c4.167-4.167,4.167-10.917,0-15.083C398.042,148.292,391.292,148.292,387.125,152.458z"/>
</g>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -1,57 +0,0 @@
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Inventory</title>
<link rel="stylesheet" href="package://assets/css/inventory/style.css">
</head>
<!-- partial:index.partial.html -->
<body>
<div class="pInvWrapper">
<div>
<div class=box1><h2> Inventar</h2></div>
<div class=box2><h4 id="gewicht"> 0/25 kg</h4></div>
</div>
<br>
<p>
<div id="invContainer">
</div>
<button id='buttonbenutzen' onclick="benutzen()">Benutzen</button>
<button id='buttonwegwerfen' onclick="wegwerfen()">Wegwerfen</button>
<button id='buttonhandeln' onclick="handeln()">Handeln</button>
</div>
<div class="phanWrapper" style="display: none;">
<div><h2> Handel</h2></div>
<div id="handelContainer">
</div>
<input type="text" id="tf_betrag" name="fnumber" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
<input type="text" id="tf_name" placeholder="Spielername">
<button id='tf_submit' onclick="submit()">Handeln</button>
</div>
<div class="Betrag" style="display: none;">
<input type="text" id="tf_zahl" name="number" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
<button id='tf_submitZahl' onclick="submitZahl()">Bestätigen</button>
</div>
<!-- Task Systems -->
<div class="tasksWrapper">
<div id="tasksContainer">
<div id="taskOneElem">
</div>
</div>
</div><br />
<!-- partial -->
<script src="package://assets/js/jquery-3.3.1.min.js" type="text/javascript"></script>
<script src="package://assets/js/inventory/script.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -0,0 +1,874 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Inventar</title>
<link rel="stylesheet" href="css/inventory.css" />
</head>
<body>
<div class="sidebar">
<ul>
<li name="side1" class="sidebaritem1" onclick="switchSite('backpackClass')"><img class="sideicon1" src="img/backpack/backpack.svg"><p class="bartext">Rucksack</p></li>
<li name="side2" class="sidebaritem2" onclick="switchSite('vehClass')"><img class="sideicon2" src="img/backpack/car.svg"><p class="bartext">Fahrzeug</p></li>
<li name="side3" class="sidebaritem3" onclick="switchSite('tradeClass')"><img class="sideicon4" src="img/backpack/trading.svg"><p class="bartext">Handel</p></li>
<li name="side4" class="sidebaritem4 hidden" onclick="switchSite('handelClass')"><img class="sideicon4" src="img/backpack/trading.svg"><p class="bartext">Handeln</p></li>
<li name="side5" class="sidebaritem5 hidden" onclick="getTrade()"><img class="sideicon4" src="img/backpack/save-money.svg"><p class="bartext">Anfrage</p></li>
<li name="side6" class="sidebaritem6 hidden" onclick="switchSite('backClass')"><img class="sideicon4" src="img/backpack/back.svg"><p class="bartext">Zurück</p></li>
</ul>
</div>
<div name="backpackClass" class="backpack">
<div class="main">
<div class="Betrag" style="display:none;">
<input type="text" id="tf_zahl" name="number" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
<button id='tf_submitZahl' onclick="">Bestätigen</button>
<button id='tf_cancle' onclick="">Schließen</button>
</div>
<div class="Betrag2" style="display:none;">
<div class="BoxBlue">
<input type="text" id="tf_zahl2" name="number" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
<button id="tf_submitZahlToHandel" onclick="">Zum handeln transferieren</button>
<button id="tf_cancle2" onclick="">Schließen</button>
<button id="tf_submitZahlToVehicle" onclick="">Zum Fahrzeug transferieren</button>
<img class="blueIcon1" src="img/backpack/car.svg">
<img class="blueIcon2" src="img/backpack/trading.svg">
</div>
</div>
<div class="title"><div class="titlecount"><span id="count1">0</span> / 40 Kilogramm</div><div class="titletext">Rucksack</div></div>
<div class="items">
<ul id="List0"></ul>
</div>
</div>
</div>
<div name="vehClass" class="veh hidden">
<div class="main">
<div class="title"><div class="titlecount"><span id="count2">0</span> / 250 Kilogramm</div><div class="titletext">Fahrzeug</div></div>
<div class="Betrag4" style="display:none;">
<input type="text" id="tf_zahl4" name="number" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
<button id='tf_submitZahl4' onclick="">Zum Rucksack transferieren</button>
<button id='tf_cancle4' onclick="">Schließen</button>
</div>
<div class="items">
<ul id="List4"></ul>
</div>
</div>
</div>
<div name="handelClass" class="handel hidden">
<div class="main">
<div class="Betrag3" style="display:none;">
<input type="text" id="tf_zahl3" name="number" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
<button id='tf_submitZahl3' onclick="">Bestätigen</button>
<button id='tf_cancle3' onclick="">Schließen</button>
</div>
<input type="text" id="tf_nameorid" name="number" placeholder="Zum Rucksack transferieren" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
<button id='tf_submitTrade' onclick="">Senden</button>
<div class="title"><div class="titlecount"><span id="count3">0</span> Kilogramm</div><div class="titletext">Handeln</div></div>
<div class="items">
<ul id="List2"></ul>
</div>
</div>
</div>
<div name="anfrageClass" class="something hidden">
<div class="main">
<div class="title"><div class="titlecount"><span id="count4">0</span> Kilogramm</div><div class="titletext">Anfrage</div></div>
<div class="items">
<ul id="List3"></ul>
</div>
</div>
</div>
<div id="invisible" style="display:none"></div>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
var lastClass = "backpackClass";
var val = 0;
function changeTradeStatus(value) {
val = JSON.parse(value);
}
function getTrade() {
if (val == 1) {
switchSite('anfrageClass');
}
}
$("#tf_submitTrade").unbind('click').click(function () {
if (handelInv.length > 0) {
var handelItemID = [];
var handelItemAmount = [];
for (i = 0; i < handelInv.length; i++) {
handelItemID.push(handelInv[i].ID);
handelItemAmount.push(handelInv[i].Amount);
}
mop.trigger("CEF:submitTrade")
}
});
$("#tf_cancle4").unbind('click').click(function () {
$(".Betrag4").hide();
});
$("#tf_cancle3").unbind('click').click(function () {
$(".Betrag3").hide();
});
$("#tf_cancle").unbind('click').click(function () {
$(".Betrag").hide();
});
$("#tf_cancle2").unbind('click').click(function () {
$(".Betrag2").hide();
});
function setAnfrage(jsonIdArr, jsonAmountArr, jsonNameArr, jsonWeight) {
var parsedIdArr = JSON.parse(jsonIdArr);
var parsedAmountArr = JSON.parse(jsonAmountArr);
var parsedNameArr = JSON.parse(jsonNameArr);
var parsedWeight = JSON.parse(jsonWeight);
for (var i = 0; i < parsedNameArr.length; i++) {
var num = parsedAmountArr[i];
var newItem = { Name: parsedNameArr[i], ID: parsedIdArr[i], Amount: num, Category: 3 };
anfrageInv[i] = newItem;
}
$('#count4').html(parsedWeight / 1000);
drawAnfrage();
}
function switchSite(site) {
if (site != lastClass) {
if (site == "tradeClass") {
document.getElementsByName("side1")[0].classList.toggle("hidden");
document.getElementsByName("side2")[0].classList.toggle("hidden");
document.getElementsByName("side3")[0].classList.toggle("hidden");
document.getElementsByName("side4")[0].classList.remove("hidden");
document.getElementsByName("side5")[0].classList.remove("hidden");
document.getElementsByName("side6")[0].classList.remove("hidden");
var givenClass = document.getElementsByName("handelClass")[0];
givenClass.classList.remove("hidden");
document.getElementsByName(lastClass)[0].classList.toggle("hidden");
lastClass = "handelClass";
return;
}
else if (site == "backClass") {
document.getElementsByName("side1")[0].classList.remove("hidden");
document.getElementsByName("side2")[0].classList.remove("hidden");
document.getElementsByName("side3")[0].classList.remove("hidden");
document.getElementsByName("side4")[0].classList.toggle("hidden");
document.getElementsByName("side5")[0].classList.toggle("hidden");
document.getElementsByName("side6")[0].classList.toggle("hidden");
var givenClass = document.getElementsByName("backpackClass")[0];
givenClass.classList.remove("hidden");
document.getElementsByName(lastClass)[0].classList.toggle("hidden");
lastClass = "backpackClass";
return;
} else {
var givenClass = document.getElementsByName(site)[0];
givenClass.classList.remove("hidden");
document.getElementsByName(lastClass)[0].classList.toggle("hidden");
lastClass = site;
}
}
}
$(document).ready(function () {
mp.trigger('CEF:InventoryLoaded');
mp.trigger('CEF:getNearVehicles');
});
function setItems(jsonName, jsonID, jsonAmount, nearPlayers) {
var parsedName = JSON.parse(jsonName);
var parsedID = JSON.parse(jsonID);
var parsedAmount = JSON.parse(jsonAmount);
for (var i = 0; i < parsedName.length; i++) {
var num = parsedAmount[i];
var newItem = { Name: parsedName[i], ID: parsedID[i], Amount: num, Category: 0 };
rucksackInv[i] = newItem;
}
jsonInv = JSON.stringify(rucksackInv);
ReceiveClientInformation(jsonInv);
var parsedPlayers = JSON.parse(nearPlayers);
Players = parsedPlayers;
for (var x = 0; x < parsedPlayers.length; x++) {
$('.dropdown-content').append("<a value=" + x + ">" + parsedPlayers[x] + "</a>");
}
}
var Players = [];
function setWeight(jsonWeight) {
var parsedWeight = JSON.parse(jsonWeight);
$('#count1').html(parsedWeight / 1000);
}
function setVehiclesInv(jsonVehInv) {
var parsedVehInv = JSON.parse(jsonVehInv);
vehInvItem.push(parsedVehInv);
var vehicle = vehInvItem[0];
for (i = 0; i < vehicle.ivehName.length; i++) {
var newItem = { Name: vehicle.ivehName[i], ID: vehicle.ivehId[i], Amount: vehicle.ivehAmount[i], Category: 1 };
vehInv.push(newItem);
Origin.push(0);
Origin.push(vehicle.ID);
}
var jsonVehInv = JSON.stringify(vehInv);
$('#count2').html(vehInvItem[0].currentWeight / 1000);
RecieveVehicleInfo(jsonVehInv);
}
function RecieveVehicleInfo(json) {
var parsed = JSON.parse(json);
for (var i = 0; i < parsed.length; i++) {
var item = parsed[i];
console.log(item);
var quantity = parsed[i].Amount;
var list = document.getElementById("List4");
var pictureElement = document.createElement("img");
pictureElement.setAttribute("class", "sideicon15");
pictureElement.setAttribute("src", "img/inventory/" + item.ID + ".svg");
var redButton = document.createElement("div");
var redButtonImg = document.createElement("img");
redButton.setAttribute("class", "red");
redButton.setAttribute("onclick", "onAction(1," + item.ID + "," + item.Amount + ");");
redButtonImg.setAttribute("src", "img/backpack/trash.svg");
redButtonImg.setAttribute("class", "redImg");
redButton.appendChild(redButtonImg);
var blueButton = document.createElement("div");
var blueButtonImg = document.createElement("img");
blueButton.setAttribute("class", "blue2");
blueButton.setAttribute("onclick", "onAction(4," + item.ID + "," + item.Amount + ");");
blueButtonImg.setAttribute("src", "img/backpack/paper-plane.svg");
blueButtonImg.setAttribute("class", "blueImg");
blueButton.appendChild(blueButtonImg);
var listLength = list.length;
var row = 1;
if (listLength > 3) {
row = 2;
}
if (listLength > 7) {
row = 3;
}
if (listLength > 11) {
row = 4;
}
if (listLength > 15) {
row = 5;
}
if (listLength > 19) {
row = 6;
}
var Litem = document.createElement("li");
Litem.setAttribute("class", "item" + row);
Litem.appendChild(document.createTextNode(quantity + "x " + item.Name));
Litem.appendChild(pictureElement);
Litem.appendChild(redButton);
Litem.appendChild(blueButton);
list.appendChild(Litem);
}
}
var rucksackInv = [];
var handelInv = [];
var vehInv = [];
var anfrageInv = [];
var Origin = [];
var vehInvItem = [];
function ReceiveClientInformation(json) {
var parsed = JSON.parse(json);
rucksackInv = parsed;
for (var i = 0; i < parsed.length; i++) {
var item = parsed[i];
item.Category = 0;
console.log(item);
var quantity = parsed[i].Amount;
var list = document.getElementById("List" + item.Category);
var pictureElement = document.createElement("img");
pictureElement.setAttribute("class", "sideicon15");
pictureElement.setAttribute("src", "img/inventory/" + item.ID + ".svg");
var redButton = document.createElement("div");
var redButtonImg = document.createElement("img");
redButton.setAttribute("class", "red");
redButton.setAttribute("onclick", "onAction(1," + item.ID + "," + item.Amount + "," + i + ");");
redButtonImg.setAttribute("src", "img/backpack/trash.svg");
redButtonImg.setAttribute("class", "redImg");
redButton.appendChild(redButtonImg);
var greenButton = document.createElement("div");
var greenButtonImg = document.createElement("img");
greenButton.setAttribute("class", "green");
greenButton.setAttribute("onclick", "onAction(0," + item.ID + "," + item.Amount + "," + i + ");");
greenButtonImg.setAttribute("src", "img/backpack/use.svg");
greenButtonImg.setAttribute("class", "greenImg");
greenButton.appendChild(greenButtonImg);
var blueButton = document.createElement("div");
var blueButtonImg = document.createElement("img");
blueButton.setAttribute("class", "blue");
blueButton.setAttribute("onclick", "onAction(2," + item.ID + "," + item.Amount + ", " + i + ");");
blueButtonImg.setAttribute("src", "img/backpack/paper-plane.svg");
blueButtonImg.setAttribute("class", "blueImg");
blueButton.appendChild(blueButtonImg);
var listLength = list.length;
var row = 1;
if (listLength > 3) {
row = 2;
}
if (listLength > 7) {
row = 3;
}
if (listLength > 11) {
row = 4;
}
if (listLength > 15) {
row = 5;
}
if (listLength > 19) {
row = 6;
}
var Litem = document.createElement("li");
Litem.setAttribute("class", "item" + row);
Litem.appendChild(document.createTextNode(quantity + "x " + item.Name));
Litem.appendChild(pictureElement);
Litem.appendChild(redButton);
Litem.appendChild(greenButton);
Litem.appendChild(blueButton);
list.appendChild(Litem);
}
}
var clnc = 1;
function onAction(action, id, ammount, i) {
$(".Betrag").hide();
if (action == 0)//green
{
$(".Betrag").show();
$("#tf_submitZahl").unbind('click').click(function () {
if ($('#tf_zahl').val() < ammount && ammount > 0) {
rucksackInv[i].Amount -= $('#tf_zahl').val();
} else if ($('#tf_zahl').val() >= ammount) {
rucksackInv.splice(i, 1);
}
console.log(i);
$(".Betrag").hide();
drawRucksack();
event.preventDefault()
event.stopPropagation()
});
}
if (action == 1)//red
{
$(".Betrag").show();
$("#tf_submitZahl").unbind('click').click(function () {
if ($('#tf_zahl').val() < ammount && ammount > 0) {
rucksackInv[i].Amount -= $('#tf_zahl').val();
mp.trigger("CEF:throwItem", JSON.stringify("drop"), JSON.stringify($('#tf_zahl').val()), JSON.stringify(rucksackInv[i].ID))
} else if ($('#tf_zahl').val() >= ammount) {
mp.trigger("CEF:throwItem", JSON.stringify("drop"), JSON.stringify(0), JSON.stringify(rucksackInv[i].ID))
rucksackInv.splice(i, 1);
}
console.log(i);
$(".Betrag").hide();
drawRucksack();
drawVehicle();
event.preventDefault()
event.stopPropagation()
});
}
if (action == 2) //blue
{
$(".Betrag2").show();
var Copy = Object.assign({}, rucksackInv[i]);
$("#tf_submitZahlToHandel").unbind('click').click(function () {
var y = parseInt($('#tf_zahl2').val(), 10);
if ($('#tf_zahl2').val() < ammount && ammount > 0) {
for (x = 0; x < handelInv.length; x++) {
if (handelInv[x].ID == Copy.ID) {
handelInv[x].Amount += y;
rucksackInv[i].Amount -= y;
$(".Betrag2").hide();
drawHandel();
drawRucksack();
event.preventDefault()
event.stopPropagation()
return;
}
}
handelInv.push(Copy);
handelInv[handelInv.length - 1].Amount = y;
handelInv[handelInv.length - 1].Category = 2;
rucksackInv[i].Amount -= y;
} else if ($('#tf_zahl2').val() >= ammount) {
for (x = 0; x < handelInv.length; x++) {
if (handelInv[x].ID == Copy.ID) {
handelInv[x].Amount += y;
rucksackInv.splice(i, 1);
$(".Betrag2").hide();
drawHandel();
drawRucksack();
event.preventDefault()
event.stopPropagation()
return;
}
}
handelInv.push(Copy);
handelInv[handelInv.length - 1].Category = 2;
rucksackInv.splice(i, 1);
}
$(".Betrag2").hide();
drawHandel();
drawRucksack();
event.preventDefault()
event.stopPropagation()
});
$("#tf_submitZahlToVehicle").unbind('click').click(function () {
var y = parseInt($('#tf_zahl2').val(), 10);
if ($('#tf_zahl2').val() < ammount && ammount > 0) {
for (x = 0; x < vehInv.length; x++) {
if (vehInv[x].ID == Copy.ID) {
vehInv[x].Amount += y;
rucksackInv[i].Amount -= y;
$(".Betrag2").hide();
mp.trigger("CEF:saveVehicleTransfer",0, JSON.stringify(Origin), JSON.stringify(rucksackInv[i].ID), JSON.stringify(rucksackInv[i].Amount), JSON.stringify(y));
drawVehicle();
drawRucksack();
event.preventDefault()
event.stopPropagation()
return;
}
}
vehInv.push(Copy);
vehInv[vehInv.length - 1].Amount = y;
vehInv[vehInv.length - 1].Category = 2;
rucksackInv[i].Amount -= y;
mp.trigger("CEF:saveVehicleTransfer",0, JSON.stringify(Origin), JSON.stringify(rucksackInv[i].ID), JSON.stringify(rucksackInv[i].Amount), JSON.stringify(y));
} else if ($('#tf_zahl2').val() >= ammount) {
for (x = 0; x < vehInv.length; x++) {
if (vehInv[x].ID == Copy.ID) {
vehInv[x].Amount += y;
rucksackInv.splice(i, 1);
$(".Betrag2").hide();
mp.trigger("CEF:saveVehicleTransfer",0, JSON.stringify(Origin), JSON.stringify(Copy.ID), JSON.stringify(0), JSON.stringify(ammount));
drawVehicle();
drawRucksack();
event.preventDefault()
event.stopPropagation()
return;
}
}
vehInv.push(Copy);
vehInv[vehInv.length - 1].Category = 2;
rucksackInv.splice(i, 1);
mp.trigger("CEF:saveVehicleTransfer",0, JSON.stringify(Origin), JSON.stringify(Copy.ID), JSON.stringify(0), JSON.stringify(ammount));
}
$(".Betrag2").hide();
drawVehicle();
drawRucksack();
event.preventDefault()
event.stopPropagation()
});
}
if (action == 3) {
$(".Betrag3").show();
var Copy = Object.assign({}, handelInv[i]);
$("#tf_submitZahl3").unbind('click').click(function () {
var y = parseInt($('#tf_zahl3').val(), 10);
if ($('#tf_zahl3').val() < ammount && ammount > 0) {
for (x = 0; x < rucksackInv.length; x++) {
if (rucksackInv[x].ID == Copy.ID) {
rucksackInv[x].Amount += y;
handelInv[i].Amount -= y;
$(".Betrag3").hide();
drawHandel();
drawRucksack();
event.preventDefault()
event.stopPropagation()
return;
}
}
rucksackInv.push(Copy);
rucksackInv[rucksackInv.length - 1].Amount = y;
rucksackInv[rucksackInv.length - 1].Category = 0;
handelInv[i].Amount -= y;
} else if ($('#tf_zahl3').val() >= ammount) {
for (x = 0; x < rucksackInv.length; x++) {
if (rucksackInv[x].ID == Copy.ID) {
rucksackInv[x].Amount += y;
handelInv.splice(i, 1);
$(".Betrag3").hide();
drawHandel();
drawRucksack();
event.preventDefault()
event.stopPropagation()
return;
}
}
rucksackInv.push(Copy);
rucksackInv[rucksackInv.length - 1].Category = 0;
handelInv.splice(i, 1);
}
$(".Betrag3").hide();
drawHandel();
drawRucksack();
event.preventDefault()
event.stopPropagation()
});
}
if (action == 4) {
$(".Betrag4").show();
var Copy = Object.assign({}, vehInv[i]);
$("#tf_submitZahl4").unbind('click').click(function () {
var y = parseInt($('#tf_zahl4').val(), 10);
if ($('#tf_zahl4').val() < ammount && ammount > 0) {
for (x = 0; x < rucksackInv.length; x++) {
if (rucksackInv[x].ID == Copy.ID) {
rucksackInv[x].Amount += y;
vehInv[i].Amount -= y;
$(".Betrag2").hide();
mp.trigger("CEF:saveVehicleTransfer",1, JSON.stringify(Origin), JSON.stringify(Copy.ID), JSON.stringify(vehInv[i].Amount), JSON.stringify(y));
drawVehicle();
drawRucksack();
event.preventDefault()
event.stopPropagation()
return;
}
}
rucksackInv.push(Copy);
rucksackInv[rucksackInv.length - 1].Amount = y;
rucksackInv[rucksackInv.length - 1].Category = 2;
vehInv[i].Amount -= y;
mp.trigger("CEF:saveVehicleTransfer",0, JSON.stringify(Origin), JSON.stringify(Copy.ID), JSON.stringify(vehInv[i].Amount), JSON.stringify(y));
} else if ($('#tf_zahl4').val() >= ammount) {
for (x = 0; x < rucksackInv.length; x++) {
if (rucksackInv[x].ID == Copy.ID) {
rucksackInv[x].Amount += y;
vehInv.splice(i, 1);
$(".Betrag2").hide();
mp.trigger("CEF:saveVehicleTransfer",1, JSON.stringify(Origin), JSON.stringify(Copy.ID), JSON.stringify(0), JSON.stringify(ammount));
drawVehicle();
drawRucksack();
event.preventDefault()
event.stopPropagation()
return;
}
}
rucksackInv.push(Copy);
rucksackInv[rucksackInv.length - 1].Category = 2;
vehInv.splice(i, 1);
mp.trigger("CEF:saveVehicleTransfer",1, JSON.stringify(Origin), JSON.stringify(Copy.ID), JSON.stringify(0), JSON.stringify(ammount));
}
$(".Betrag4").hide();
drawVehicle();
drawRucksack();
event.preventDefault()
event.stopPropagation()
});
}
}
function drawHandel() {
var e = document.getElementById("List2");
//e.firstElementChild can be used.
var child = e.lastElementChild;
while (child) {
e.removeChild(child);
child = e.lastElementChild;
} console.log(handelInv);
for (var i = 0; i < handelInv.length; i++) {
var item = handelInv[i];
var quantity = handelInv[i].Amount;
var list = document.getElementById("List" + item.Category);
var pictureElement = document.createElement("img");
pictureElement.setAttribute("class", "sideicon15");
pictureElement.setAttribute("src", "img/inventory/" + item.ID + ".svg");
var blueButton = document.createElement("div");
var blueButtonImg = document.createElement("img");
blueButton.setAttribute("class", "blue3");
blueButton.setAttribute("onclick", "onAction(3," + item.ID + "," + item.Amount + "," + i + ");");
blueButtonImg.setAttribute("src", "img/backpack/paper-plane.svg");
blueButtonImg.setAttribute("class", "blueImg");
blueButton.appendChild(blueButtonImg);
var listLength = list.length;
var row = 1;
if (listLength > 3) {
row = 2;
}
if (listLength > 7) {
row = 3;
}
if (listLength > 11) {
row = 4;
}
if (listLength > 15) {
row = 5;
}
if (listLength > 19) {
row = 6;
}
var Litem = document.createElement("li");
Litem.setAttribute("class", "item" + row);
Litem.setAttribute("id", i);
Litem.setAttribute("name", "List" + item.Category);
Litem.appendChild(document.createTextNode(quantity + "x " + item.Name));
Litem.appendChild(pictureElement);
Litem.appendChild(blueButton);
list.appendChild(Litem);
}
}
function drawRucksack() {
var e = document.getElementById("List0");
//e.firstElementChild can be used.
var child = e.lastElementChild;
while (child) {
e.removeChild(child);
child = e.lastElementChild;
} console.log(rucksackInv);
for (var i = 0; i < rucksackInv.length; i++) {
var item = rucksackInv[i];
var quantity = rucksackInv[i].Amount;
var list = document.getElementById("List" + item.Category);
var pictureElement = document.createElement("img");
pictureElement.setAttribute("class", "sideicon15");
pictureElement.setAttribute("src", "img/inventory/" + item.ID + ".svg");
var redButton = document.createElement("div");
var redButtonImg = document.createElement("img");
redButton.setAttribute("class", "red");
redButton.setAttribute("onclick", "onAction(1," + item.ID + "," + item.Amount + "," + i + ");");
redButtonImg.setAttribute("src", "img/backpack/trash.svg");
redButtonImg.setAttribute("class", "redImg");
redButton.appendChild(redButtonImg);
var greenButton = document.createElement("div");
var greenButtonImg = document.createElement("img");
greenButton.setAttribute("class", "green");
greenButton.setAttribute("onclick", "onAction(0," + item.ID + "," + item.Amount + "," + i + ");");
greenButtonImg.setAttribute("src", "img/backpack/use.svg");
greenButtonImg.setAttribute("class", "greenImg");
greenButton.appendChild(greenButtonImg);
var blueButton = document.createElement("div");
var blueButtonImg = document.createElement("img");
blueButton.setAttribute("class", "blue");
blueButton.setAttribute("onclick", "onAction(2," + item.ID + "," + item.Amount + "," + i + ");");
blueButtonImg.setAttribute("src", "img/backpack/paper-plane.svg");
blueButtonImg.setAttribute("class", "blueImg");
blueButton.appendChild(blueButtonImg);
var listLength = list.length;
var row = 1;
if (listLength > 3) {
row = 2;
}
if (listLength > 7) {
row = 3;
}
if (listLength > 11) {
row = 4;
}
if (listLength > 15) {
row = 5;
}
if (listLength > 19) {
row = 6;
}
var Litem = document.createElement("li");
Litem.setAttribute("class", "item" + row);
Litem.setAttribute("id", i);
Litem.setAttribute("name", "List" + item.Category);
Litem.appendChild(document.createTextNode(quantity + "x " + item.Name));
Litem.appendChild(pictureElement);
Litem.appendChild(redButton);
Litem.appendChild(greenButton);
Litem.appendChild(blueButton);
list.appendChild(Litem);
}
}
function drawVehicle() {
var e = document.getElementById("List4");
//e.firstElementChild can be used.
var child = e.lastElementChild;
while (child) {
e.removeChild(child);
child = e.lastElementChild;
} console.log(handelInv);
for (var i = 0; i < vehInv.length; i++) {
var item = vehInv[i];
console.log(item);
var quantity = vehInv[i].Amount;
var list = document.getElementById("List4");
var pictureElement = document.createElement("img");
pictureElement.setAttribute("class", "sideicon15");
pictureElement.setAttribute("src", "img/inventory/" + item.ID + ".svg");
var redButton = document.createElement("div");
var redButtonImg = document.createElement("img");
redButton.setAttribute("class", "red");
redButton.setAttribute("onclick", "onAction(1," + item.ID + "," + item.Amount + ");");
redButtonImg.setAttribute("src", "img/backpack/trash.svg");
redButtonImg.setAttribute("class", "redImg");
redButton.appendChild(redButtonImg);
var blueButton = document.createElement("div");
var blueButtonImg = document.createElement("img");
blueButton.setAttribute("class", "blue2");
blueButton.setAttribute("onclick", "onAction(4," + item.ID + "," + item.Amount + ");");
blueButtonImg.setAttribute("src", "img/backpack/paper-plane.svg");
blueButtonImg.setAttribute("class", "blueImg");
blueButton.appendChild(blueButtonImg);
var listLength = list.length;
var row = 1;
if (listLength > 3) {
row = 2;
}
if (listLength > 7) {
row = 3;
}
if (listLength > 11) {
row = 4;
}
if (listLength > 15) {
row = 5;
}
if (listLength > 19) {
row = 6;
}
var Litem = document.createElement("li");
Litem.setAttribute("class", "item" + row);
Litem.appendChild(document.createTextNode(quantity + "x " + item.Name));
Litem.appendChild(pictureElement);
Litem.appendChild(redButton);
Litem.appendChild(blueButton);
list.appendChild(Litem);
}
}
function drawAnfrage() {
var e = document.getElementById("List4");
//e.firstElementChild can be used.
var child = e.lastElementChild;
while (child) {
e.removeChild(child);
child = e.lastElementChild;
} console.log(anfrageInv);
for (var i = 0; i < anfrageInv.length; i++) {
var item = anfrageInv[i];
var quantity = anfrageInv[i].Amount;
var list = document.getElementById("List" + item.Category);
var pictureElement = document.createElement("img");
pictureElement.setAttribute("class", "sideicon15");
pictureElement.setAttribute("src", "img/inventory/" + item.ID + ".svg");
var listLength = list.length;
var row = 1;
if (listLength > 3) {
row = 2;
}
if (listLength > 7) {
row = 3;
}
if (listLength > 11) {
row = 4;
}
if (listLength > 15) {
row = 5;
}
if (listLength > 19) {
row = 6;
}
var Litem = document.createElement("li");
Litem.setAttribute("class", "item" + row);
Litem.setAttribute("id", i);
Litem.setAttribute("name", "List" + item.Category);
Litem.appendChild(document.createTextNode(quantity + "x " + item.Name));
Litem.appendChild(pictureElement);
Litem.appendChild(blueButton);
list.appendChild(Litem);
}
}
</script>
</body>
</html>

View File

@@ -1,47 +0,0 @@
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Inventory</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<!-- partial:index.partial.html -->
<head>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,700" rel="stylesheet">
</head>
<body background="180610.jpg">
<div class="pKofWrapper">
<div>
<div class=box1><h2> Inventar </h2></div>
<div class=box2><h4 id="gewicht"> 0/45kg</h4></div>
</div>
<div id="invContainer">
</div>
<div>
<button id='buttonbenutzen' onclick="benutzen()">Benutzen</button>
<button id='buttonwegwerfen' onclick="wegwerfen()">Wegwerfen</button>
<button id='Fahrzeug'>Fahrzeug</button>
</div>
</div>
<div class="fahrzeugWrapper" style="display: none;">
<div class=box1><h2> Kofferraum </h2></div>
<div class=box2><h4 id="vehGewicht"> 0/250kg</h4></div>
<div id="kofContainer">
</div>
</div>
<div class="Betrag" style="display: none;">
<input type="text" id="tf_zahl" name="number" placeholder="Betrag eingeben" min="1" step="1" oninput="this.value=this.value.replace(/[^0-9]/g,'');">
<button id='tf_submitZahl' onclick="submitZahl()">Bestätigen</button>
</div>
<script src="package://assets/js/jquery-3.3.1.min.js" type="text/javascript"></script>
<script src="./script.js"></script>
</body>
</html>

View File

@@ -1,608 +0,0 @@
$(document).ready(function () {
//fire functions before page load
drawToKofferraum();
drawToPage();
moveItemsInv();
mp.trigger("CEF:BrowserLoadedVehicle");
console.log("loading finished");
});
var vehID;
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]);
}
}
}
function setVehItems(itemIdArr1, itemAmountArr1, vehID1) {
vehID = vehID1;
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.addToVehInv(itemIdArr[i]);
}
}
}
var holz = {
name: "Holz",
rarity: 'common',
selected: 'false',
usable: 'true',
amount: 1,
currentWeight: 0.65,
stackable: 'true',
object: 'true',
itemId: 1,
img: "package://assets/img/items/wood.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 flunder = {
name: "Flunder",
weight: 7.7,
currentWeight: 7.7,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 5,
img: 'package://assets/img/items/flounder.svg'
}
var aal = {
name: "Aal",
weight: 3.6,
currentWeight: 3.6,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 6,
img: 'package://assets/img/items/aal.svg'
}
var barsch = {
name: "Barsch",
weight: 2.6,
currentWeight: 2.6,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 7,
img: 'package://assets/img/items/perch.svg'
}
var lachs = {
name: "Lachs",
weight: 4.2,
currentWeight: 4.2,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 8,
img: 'package://assets/img/items/salmon.svg'
}
var thunfisch = {
name: "Thunfisch",
weight: 11,
currentWeight: 11,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 9,
img: 'package://assets/img/items/salmon.svg'
}
var zander = {
name: "Zander",
weight: 5,
currentWeight: 5,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 10,
img: 'package://assets/img/items/zander.svg'
}
var allItems = [holz, hamburger, cocaine, cannabis, flunder, aal, barsch, lachs, thunfisch, zander];
////////////////////////
// Player Invenotry //
////////////////////////
var playerInventory = [];
var EmptySlot = { name: 'blankSpace', rarity: '', object: 'false' };
function addToVehInvenotry(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 = 24; 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 >= 250) {
return;
}
//Adds item to inventory
for (var i = 24; i < playerInventory.length; i++) {
if (unfininshedStack != undefined) {
if (playerInventory[unfininshedStack].amount + cloneItem.amount <= 30) {
playerInventory[unfininshedStack].amount += cloneItem.amount;
unfininshedStack = undefined;
drawToKofferraum();
moveItemsInv();
break;
}
else if (playerInventory[unfininshedStack].amount + cloneItem.amount > 30) {
var stackRemainder = 30 - playerInventory[unfininshedStack].amount;
playerInventory[unfininshedStack].amount += stackRemainder;
cloneItem.amount -= stackRemainder;
var recycleCloned = cloneItem;
addToInvenotry(recycleCloned);
unfininshedStack = undefined;
drawToKofferraum();
moveItemsInv();
break;
}
}
else if (cloneItem.amount > 30 && playerInventory[i].object === 'false') {
var reduceCloneAmount = Object.assign({}, cloneItem);
reduceCloneAmount.amount = 30;
playerInventory[i] = reduceCloneAmount;
cloneItem.amount -= 30;
addToInvenotry(cloneItem);
drawToKofferraum();
moveItemsInv();
break;
}
else if (unfininshedStack == undefined && playerInventory[i].object === 'false') {
playerInventory[i] = cloneItem;
drawToKofferraum();
moveItemsInv();
break;
}
}
}
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 >= 45) {
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]).click(function () {
if (this.getAttribute('inv-type') != 'p') {
return;
}
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) {
if (playerInventory[this.getAttribute('data-value')] == EmptySlot && this.getAttribute('data-value') > 23 && currentSelected < 24) {
var hItem = this.getAttribute('data-value');
var iItem = currentSelected;
var Copy = Object.assign({}, playerInventory[iItem]);
playerInventory.splice(hItem, 0, Copy);
if (playerInventory[currentSelected].stackable === 'false') {
playerInventory[hItem].amount = playerInventory[iItem].amount;
playerInventory[iItem] = EmptySlot;
} else {
$(".Betrag").show();
$("#tf_submitZahl").click(function () {
if ($('#tf_zahl').val() < playerInventory[iItem].amount && playerInventory[currentSelected].stackable) {
console.log(playerInventory[hItem].amount + " " + playerInventory[iItem].amount + " " + hItem);
var y = parseInt($('#tf_zahl').val(), 10);
playerInventory[iItem].amount -= y;
console.log(playerInventory[hItem].amount + " " + playerInventory[iItem] + " " + parseInt($('#tf_zahl').val(), 10) + " " + hItem);
playerInventory[hItem].amount = y;
console.log(playerInventory[hItem].amount + " " + playerInventory[iItem].amount + " " + parseInt($('#tf_zahl').val(), 10) + " " + hItem);
} else {
playerInventory[hItem].amount = playerInventory[iItem].amount;
playerInventory[iItem] = EmptySlot;
}
drawToPage();
drawToKofferraum();
currentSelected = undefined;
getItemSlotData = document.getElementsByClassName('itemSlot');
moveItemsInv();
$(".Betrag").hide();
saveAllItems();
});
}
return;
} else {
var swap = playerInventory[this.getAttribute('data-value')];
playerInventory[this.getAttribute('data-value')] = playerInventory[currentSelected];
playerInventory[currentSelected] = swap;
drawToPage();
drawToKofferraum();
currentSelected = undefined;
getItemSlotData = document.getElementsByClassName('itemSlot');
moveItemsInv();
}
}
else if ((playerInventory[currentSelected].itemId == playerInventory[this.getAttribute('data-value')].itemId && playerInventory[currentSelected].stackable) && this.getAttribute('inv-type') === 'p') {
$(".Betrag").show();
$("#tf_submitZahl").click(function () {
playerInventory[this.getAttribute('data-value')].amount += playerInventory[currentSelected].amount
playerInventory[currentSelected] = EmptySlot;
drawToPage();
drawToKofferraum();
currentSelected = undefined;
getItemSlotData = document.getElementsByClassName('itemSlot');
moveItemsInv();
$(".Betrag").hide();
saveAllItems();
});
}
}
else {
this.className += ' selected';
currentSelected = this.getAttribute('data-value');
}
});
}
}
//Inventar
function saveAllItems() {
mp.trigger("CEF:saveItemsHelper", JSON.stringify(vehId));
for (var i = 0; i < playerInventory.length; i++) {
if (playerInventory[i].object === 'true') {
mp.trigger("CEF:saveItems", JSON.stringify(playerInventory[i].itemId), JSON.stringify(playerInventory[i].amount), JSON.stringify(i));
}
}
}
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 + "/45 kg";
}
}
}
fillOutEmptyInv();
}
//Kofferraum
function refreshAllCurrentKofItems() {
var remove = document.getElementById('kofContainer');
while (remove.firstChild) remove.removeChild(remove.firstChild);
}
function fillOutEmptyInvKofferraum() {
for (var i = 24; i < 54; i++) {
if (!playerInventory[i]) {
playerInventory.push(EmptySlot);
drawToKofferraum();
}
}
}
var vehWeightInv = 0;
function drawToKofferraum() {
refreshAllCurrentKofItems();
vehWeightInv = 0;
for (var i = 24; i < playerInventory.length; i++) {
if (playerInventory[i].selected == 'true') {
var className = ' selected';
}
else {
var className = '';
}
if (i >= 54) {
//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("kofContainer").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);
vehWeightInv += playerInventory[i].currentWeight * playerInventory[i].amount;
document.getElementById('vehGewicht').innerText = Math.round(weightInv * 100) / 100 + "/250 kg";
}
}
}
fillOutEmptyInvKofferraum();
}
///////////////////
// Dev Commands //
///////////////////
var commands = {
addToPlayerInv: function (itemGiveId) {
for (var i = 0; i < allItems.length; i++) {
if (allItems[i].itemId === itemGiveId) {
addToInvenotry(allItems[i]);
}
}
},
addToVehInv: function(itemGiveId) {
for (var i = 0; i < allItems.length; i++) {
if (allItems[i].itemId === itemGiveId) {
addToVehInvenotry(allItems[i]);
}
}
},
clearPlayerInv: function () {
playerInventory = [];
drawToPage();
drawToKofferraum();
},
}
//Handel Akzeptierenfenster
var trade = 1;
$("#Fahrzeug").click(function () {
if (trade == 1) {
$(".fahrzeugWrapper").show();
drawToKofferraum();
drawToPage();
moveItemsInv();
trade = 0;
} else {
$(".fahrzeugWrapper").hide();
trade = 1;
}
currentSelected = undefined;
});

View File

@@ -1,360 +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;
}
/* buttons */
#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%;
}
#Fahrzeug {
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;
padding-bottom:30px;
}
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%;
}
.pInvWrapper {
background: rgba(0,0,0,0.6);
height: 395px;
width: 394px;
display: block;
padding: 5px;
position: absolute;
left: 10%;
}
.pKofWrapper {
background: rgba(0,0,0,0.6);
height: 395px;
width: 394px;
display: block;
padding: 5px;
position: absolute;
left: 40%;
}
.fahrzeugWrapper {
background: rgba(0,0,0,0.6);
height: 395px;
width: 394px;
display: block;
padding: 5px;
position: absolute;
left: 40%;
top: 50%;
}
#invContainer{
width: 110%;
height: auto;
}
#invContainer h3 {
padding: 0px 10px;
}
#kofContainer{
width: 110%;
height: auto;
}
#kofContainer h3 {
padding: 0px 10px;
}
#fahrzeugContainer{
width: 110%;
height: auto;
}
#fahrzeugContainer 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 */
.Betrag {
background: rgba(0,0,0,0.6);
height: 100%;
width: 100%;
display: block;
transform: translate(-50%, -50%);
position: absolute;
left: 50%;
top: 50%;
}
#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 */

View File

@@ -1,619 +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 holz = {
name: "Holz",
rarity: 'common',
selected: 'false',
usable: 'true',
amount: 1,
currentWeight: 0.65,
stackable: 'true',
object: 'true',
itemId: 1,
img: "package://assets/img/items/wood.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 flunder = {
name: "Flunder",
weight: 7.7,
currentWeight: 7.7,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 5,
img: 'package://assets/img/items/flounder.svg'
}
var aal = {
name: "Aal",
weight: 3.6,
currentWeight: 3.6,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 6,
img: 'package://assets/img/items/aal.svg'
}
var barsch = {
name: "Barsch",
weight: 2.6,
currentWeight: 2.6,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 7,
img: 'package://assets/img/items/perch.svg'
}
var lachs = {
name: "Lachs",
weight: 4.2,
currentWeight: 4.2,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 8,
img: 'package://assets/img/items/salmon.svg'
}
var thunfisch = {
name: "Thunfisch",
weight: 11,
currentWeight: 11,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 9,
img: 'package://assets/img/items/salmon.svg'
}
var zander = {
name: "Zander",
weight: 5,
currentWeight: 5,
rarity: 'fishes',
statSlots: [],
runes: [],
amount: 1,
usable: 'false',
selected: 'false',
stackable: 'false',
object: 'true',
itemId: 10,
img: 'package://assets/img/items/zander.svg'
}
var allItems = [holz, hamburger, cocaine, cannabis, flunder, aal, barsch, lachs, thunfisch, zander];
////////////////////////
// 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 >= 45) {
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]).click(function () {
if (this.getAttribute('inv-type') != 'p') {
return;
}
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) {
if (playerInventory[this.getAttribute('data-value')] == EmptySlot && this.getAttribute('data-value') > 23) {
var hItem = this.getAttribute('data-value');
var iItem = currentSelected;
var Copy = Object.assign({}, playerInventory[iItem]);
playerInventory.splice(hItem, 0, Copy);
$(".Betrag").show();
$("#tf_submitZahl").click(function () {
if ($('#tf_zahl').val() < playerInventory[iItem].amount && playerInventory[currentSelected].stackable) {
console.log(playerInventory[hItem].amount + " " + playerInventory[iItem].amount + " " + hItem);
var y = parseInt($('#tf_zahl').val(), 10);
playerInventory[iItem].amount -= y;
console.log(playerInventory[hItem].amount + " " + playerInventory[iItem] + " " + parseInt($('#tf_zahl').val(), 10) + " " + hItem);
playerInventory[hItem].amount = y;
console.log(playerInventory[hItem].amount + " " + playerInventory[iItem].amount + " " + parseInt($('#tf_zahl').val(), 10) + " " + hItem);
} else {
playerInventory[hItem].amount = playerInventory[iItem].amount;
playerInventory[iItem] = EmptySlot;
}
drawToPage();
drawToHandel();
currentSelected = undefined;
getItemSlotData = document.getElementsByClassName('itemSlot');
moveItemsInv();
$(".Betrag").hide();
});
return;
} else {
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) && this.getAttribute('inv-type') === 'p') {
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;
document.getElementById('gewicht').innerText = "0/45 kg";
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!')
}
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 + "/45 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
$("#buttonbenutzen").click(function () {
if (currentSelected) {
if (playerInventory[currentSelected].usable == 'true') {
if (playerInventory[currentSelected].stackable == 'true') {
playerInventory[currentSelected].amount -= 1;
if (playerInventory[currentSelected].amount <= 0) {
mp.trigger("CEF:UseItemInv", playerInventory[currentSelected].itemId);
playerInventory[currentSelected] = EmptySlot;
} else {
if (getItemSlotData[currentSelected].classList.contains('selected')) {
getItemSlotData[currentSelected].classList.remove('selected');
playerInventory[currentSelected].selected = 'false';
}
}
drawToPage();
drawToHandel();
moveItemsInv();
} else {
mp.trigger("CEF:UseItemInv", playerInventory[currentSelected].itemId);
playerInventory[currentSelected] = EmptySlot;
drawToPage();
drawToHandel();
moveItemsInv();
}
currentSelected = undefined;
}
}
});
$("#buttonwegwerfen").click(function () {
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();
});
}
});
var trade = 1;
$("#buttonhandeln").click(function () {
if (trade == 1) {
$(".phanWrapper").show();
drawToPage();
drawToHandel();
moveItemsInv();
trade = 0;
} else {
$(".phanWrapper").hide();
trade = 1;
}
currentSelected = undefined;
});
$("#tf_submit").click(function () {
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);
}
}
}
}
}

View File

@@ -5,34 +5,24 @@ export default function inventory(globalData: GlobalData): void {
var invBrowser: BrowserMp = null;
var itemIdArr;
var itemAmountArr;
var vehItemIdArr;
var vehItemAmountArr;
var money;
var vehId;
var invWeight;
var itemNameArr;
mp.events.add("openTradeWindow", (money1, itemIdArr1, itemAmountArr1) => {
if (!globalData.InMenu) {
if (invBrowser !== null) {
try {
invBrowser.destroy()
invBrowser = null;
} finally {
mp.gui.cursor.show(false, false);
}
return;
}
mp.gui.cursor.show(true, true);
invBrowser = mp.browsers.new("package://assets/html/inventory/handel/handelakzeptieren.html");
var ivehArr;
itemIdArr = itemIdArr1;
itemAmountArr = itemAmountArr1;
money = money1;
}
var Players;
mp.events.add('setVehiclesInventory', (vehInvArr) => {
ivehArr = vehInvArr;
invBrowser.execute(`setVehiclesInv('${JSON.stringify(ivehArr)}');`);
});
mp.events.add('showVehInventory', () => {
invBrowser.execute(`execVehInv();`);
});
mp.events.add('vehInventoryShow', (itemIdArr1, itemAmountArr1, vehItemIdArr1, vehItemAmountArr1, vehId1) => {
mp.events.add('inventoryShow', (iWeight, iNameArr, iAmountArr, iIdArr, playersArr) => {
if (!globalData.InMenu) {
if (invBrowser !== null) {
try {
@@ -46,53 +36,53 @@ export default function inventory(globalData: GlobalData): void {
}
mp.gui.cursor.show(true, true);
invBrowser = mp.browsers.new("package://assets/html/inventory/vehicle/index.html");
itemIdArr = itemIdArr1;
itemAmountArr = itemAmountArr1;
vehItemIdArr = vehItemIdArr1;
vehItemAmountArr = vehItemAmountArr1;
vehId = vehId1;
Players = playersArr;
itemIdArr = iIdArr;
itemAmountArr = iAmountArr;
itemNameArr = iNameArr;
invWeight = iWeight;
invBrowser = mp.browsers.new("package://assets/html/inventory/inventory.html");
}
});
mp.events.add('inventoryShow', (itemIdArr1, itemAmountArr1) => {
if (!globalData.InMenu) {
if (invBrowser !== null) {
try {
invBrowser.destroy()
invBrowser = null;
}
finally {
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.addDataHandler("tradeOffer", (entity, value) => {
if (entity.type === "player") {
let offer = parseInt(value);
invBrowser.execute(`changeTradeStatus('${JSON.stringify(offer)}')`);
}
});
mp.events.add("addTradeItems", (itemId, itemAmount, itemName, weight) => {
invBrowser.execute(`setAnfrage('${JSON.stringify(itemId)}','${JSON.stringify(itemAmount)}','${JSON.stringify(itemName)}','${JSON.stringify(weight)}');`);
});
mp.events.add("CEF:saveVehicleTransfer", (val, jsonOrigin, jsonInvID, jsonInvAmount, jsonVehAmount) => {
if (val == 0) {
mp.events.callRemote('saveInventory', jsonInvID, jsonInvAmount, jsonOrigin, jsonVehAmount);
} else if(val == 1){
mp.events.callRemote('saveVehicleInventory', jsonInvID, jsonInvAmount, jsonOrigin, jsonVehAmount);
}
});
mp.events.add("CEF:invThrowItem", (itemId, amount) => {
mp.events.callRemote('invThrowItem', itemId, amount);
});
mp.events.add("CEF:throwItem", (type, amount, id) => {
mp.events.callRemote("itemInteract", type, amount, id);
});
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:BrowserLoadedVehicle", () => {
invBrowser.execute(`setItems("${JSON.stringify(itemIdArr)}","${JSON.stringify(itemAmountArr)}");`);
invBrowser.execute(`setVehItems("${JSON.stringify(vehItemIdArr)}","${JSON.stringify(vehItemAmountArr)}","${JSON.stringify(vehId)}");`);
mp.events.add("CEF:InventoryLoaded", () => {
invBrowser.execute(`setItems('${JSON.stringify(itemNameArr)}','${JSON.stringify(itemIdArr)}','${JSON.stringify(itemAmountArr)}','${JSON.stringify(Players)}');`);
invBrowser.execute(`setWeight('${JSON.stringify(invWeight)}');`);
});
mp.events.add("CEF:getNearVehicles", () => {
mp.events.callRemote('getNearVehicles');
});
mp.events.add("CEF:acceptTrade", () => {
if (invBrowser !== null) {

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ReallifeGamemode.Server.Entities
{
public class VehicleInventory
{
public int ID;
public int currentWeight;
public int totalWeight;
public string[] ivehName;
public int[] ivehAmount;
public int[] ivehId;
}
}

View File

@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GTANetworkAPI;
using ReallifeGamemode.Server.Entities;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Inventory.Interfaces;
using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Models;
using ReallifeGamemode.Server.Util;
namespace ReallifeGamemode.Server.Events
{
public class Inventory : Script
{
[RemoteEvent("getNearVehicles")]
public void SrvEvent_GetNearVehicles(Client client)
{
var user = client.GetUser();
var inventoryWeight = 0;
List<VehicleInventory> vehicleInventory = new List<VehicleInventory>();
if (!client.IsInVehicle)
{
using (var context = new DatabaseContext())
{
foreach (Vehicle veh in NAPI.Pools.GetAllVehicles())
{
List<string> iName = new List<string>();
List<int> iAmount = new List<int>();
List<int> iId = new List<int>();
inventoryWeight = 0;
int vehID = 0;
if (veh.Position.DistanceTo(client.Position) < 2)
{
if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen)
{
ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh, context);
List<VehicleItem> vehicleItems = context.VehicleItems.ToList().FindAll(i => i.VehicleId == serverVehicle.Id);
foreach (var vehItem in vehicleItems)
{
IItem iItem = InventoryManager.GetItemById(vehItem.ItemId);
var currentItemWeight = iItem.Gewicht * vehItem.Amount;
inventoryWeight += currentItemWeight;
iName.Add(iItem.Name);
iAmount.Add(vehItem.Amount);
iId.Add(iItem.Id);
vehID = vehItem.VehicleId;
}
var vehInv = new VehicleInventory
{
ID = vehID,
currentWeight = inventoryWeight,
totalWeight = 250,
ivehName = iName.ToArray(),
ivehAmount = iAmount.ToArray(),
ivehId = iId.ToArray()
};
vehicleInventory.Add(vehInv);
}
}
}
}
client.TriggerEvent("setVehiclesInventory", vehicleInventory.ToArray());
}
}
}
}

View File

@@ -134,6 +134,8 @@ namespace ReallifeGamemode.Server.Events
{
if (!player.IsLoggedIn()) return;
var user = player.GetUser();
if (user?.FactionId != null)
{
DutyPoint nearestDuty = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5 && d.FactionId == user.FactionId);
@@ -294,7 +296,7 @@ namespace ReallifeGamemode.Server.Events
public void KeyPressI(Client player)
{
if (!player.IsLoggedIn()) return;
ManagerOfInventory.GetUserItems(player);
InventoryManager.GetUserItems(player);
}
[RemoteEvent("keyPress:O")]
@@ -384,10 +386,9 @@ namespace ReallifeGamemode.Server.Events
{
if (!player.IsLoggedIn()) return;
if (player.HasData("inTrade") && player.GetData("inTrade") == true)
if (!player.IsInVehicle)
{
ManagerOfInventory.OpenTradeAccept(player);
return;
GroundItem.PickUpGroundItem(player);
}
if (player.IsInVehicle && player.VehicleSeat == -1)

View File

@@ -108,3 +108,4 @@ namespace ReallifeGamemode.Server.Inventory
}
}
}

View File

@@ -14,8 +14,8 @@ namespace ReallifeGamemode.Server.Inventory.Items
public class Aal : DropItem
{
public override int Id => 6;
public override string Name => "Kraftstoff";
public override string Description => "Der Stoff gibt dir Kraft.";
public override string Name => "Aal";
public override string Description => "Ein Fisch";
public override int Gewicht => 3600;
public override string Einheit => "g";
public override int HpAmount => 20;

View File

@@ -14,8 +14,8 @@ namespace ReallifeGamemode.Server.Inventory.Items
public class Barsch : DropItem
{
public override int Id => 7;
public override string Name => "Kraftstoff";
public override string Description => "Der Stoff gibt dir Kraft.";
public override string Name => "Barsch";
public override string Description => "Ein Fisch";
public override int Gewicht => 2600;
public override string Einheit => "g";
public override int HpAmount => 20;

View File

@@ -18,6 +18,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public string Description => "puff puff and pass";
public int Gewicht => 50;
public string Einheit => "g";
public uint Object => 1805779401;
public uint Object => 3076948544;
}
}

View File

@@ -11,11 +11,11 @@ using System.Text;
namespace ReallifeGamemode.Server.Inventory.Items
{
public class Kraftstoff : DropItem
public class Flunder : DropItem
{
public override int Id => 5;
public override string Name => "Flunder";
public override string Description => "ja";
public override string Description => "Ein Fisch";
public override int Gewicht => 7700;
public override string Einheit => "g";
public override int HpAmount => 20;

View File

@@ -14,8 +14,8 @@ namespace ReallifeGamemode.Server.Inventory.Items
public class Lachs : DropItem
{
public override int Id => 8;
public override string Name => "Kraftstoff";
public override string Description => "Der Stoff gibt dir Kraft.";
public override string Name => "Lachs";
public override string Description => "Du Lachs";
public override int Gewicht => 4200;
public override string Einheit => "g";
public override int HpAmount => 20;

View File

@@ -14,8 +14,8 @@ namespace ReallifeGamemode.Server.Inventory.Items
public class Thunfisch : DropItem
{
public override int Id => 9;
public override string Name => "Kraftstoff";
public override string Description => "Der Stoff gibt dir Kraft.";
public override string Name => "Thunfisch";
public override string Description => "Ein Fisch";
public override int Gewicht => 11000;
public override string Einheit => "g";
public override int HpAmount => 20;

View File

@@ -14,8 +14,8 @@ namespace ReallifeGamemode.Server.Inventory.Items
public class Zander : DropItem
{
public override int Id => 10;
public override string Name => "Kraftstoff";
public override string Description => "Der Stoff gibt dir Kraft.";
public override string Name => "Zander";
public override string Description => "Ein Fisch";
public override int Gewicht => 5000;
public override string Einheit => "g";
public override int HpAmount => 20;

View File

@@ -6,7 +6,9 @@ using ReallifeGamemode.Server.Inventory;
using ReallifeGamemode.Server.Inventory.Interfaces;
using ReallifeGamemode.Server.Models;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Util;
using System;
using System.Timers;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@@ -23,6 +25,11 @@ namespace ReallifeGamemode.Server.Managers
{
public static List<IItem> itemList;
private static Dictionary<int, (int[], int[])> TradeItems { get; set; } = new Dictionary<int, (int[], int[])>();
private static Dictionary<int, Timer> TradeTimer { get; set; } = new Dictionary<int, Timer>();
private static Dictionary<int, int> TradeValue { get; set; } = new Dictionary<int, int>();
public static void LoadItems()
{
itemList = new List<IItem>();
@@ -77,26 +84,36 @@ namespace ReallifeGamemode.Server.Managers
{
var user = player.GetUser();
var inventoryWeight = 0;
List<string> iName = new List<string>();
List<int> iAmount = new List<int>();
List<int> iId = new List<int>();
List<int> iWeight = new List<int>();
using (var context = new DatabaseContext())
{
List<UserItem> userItems = context.UserItems.ToList().FindAll(i => i.UserId == user.Id);
string[][] items = new string[userItems.Count][];
foreach (var item in userItems)
{
IItem iItem = GetItemById(item.ItemId);
var currentItemWeight = iItem.Gewicht * item.Amount;
inventoryWeight += currentItemWeight;
items[userItems.IndexOf(item)] = new string[6];
items[userItems.IndexOf(item)][0] = iItem.Name;
items[userItems.IndexOf(item)][1] = iItem.Description;
items[userItems.IndexOf(item)][2] = iItem.Gewicht.ToString();
items[userItems.IndexOf(item)][3] = item.Amount.ToString();
items[userItems.IndexOf(item)][4] = item.Slot.ToString();
items[userItems.IndexOf(item)][5] = item.Id.ToString();
iName.Add(iItem.Name);
iAmount.Add(item.Amount);
iId.Add(iItem.Id);
}
player.TriggerEvent("showInventory", inventoryWeight, items);
List<Client> targetList = NAPI.Player.GetPlayersInRadiusOfPlayer(2, player);
List<string> username = new List<string>();
foreach (var target in targetList)
{
User cl = target.GetUser();
username.Add(cl.Name);
}
player.TriggerEvent("inventoryShow", inventoryWeight, iName.ToArray(), iAmount.ToArray(), iId.ToArray(), username.ToArray());
}
}
@@ -155,43 +172,199 @@ namespace ReallifeGamemode.Server.Managers
}
}
[RemoteEvent("saveInventory")]
public void SavePlayerInventory(Client player, string itemArray)
public bool CheckOriginOfItem(Client client, string jsonItemID, string jsonItemAmount, string jsonOrigin, string jsonVehAmount)
{
var origin = JsonConvert.DeserializeObject<int[]>(jsonOrigin);
var itemID = JsonConvert.DeserializeObject<int>(jsonItemID);
var itemAmount = JsonConvert.DeserializeObject<int>(jsonItemAmount);
var vehAmount = JsonConvert.DeserializeObject<int>(jsonVehAmount);
var user = client.GetUser();
using (var context = new DatabaseContext())
{
if (origin[0] == 1)
{
foreach (Vehicle veh in NAPI.Pools.GetAllVehicles())
{
if (veh.Position.DistanceTo(client.Position) < 2)
{
if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen)
{
var user = player.GetUser();
var items = JsonConvert.DeserializeObject<string[][]>(itemArray);
UserItem vItem = new UserItem
{
Amount = vehAmount,
ItemId = itemID,
UserId = user.Id,
Slot = -1
};
ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh, context);
VehicleItem vehItem = context.VehicleItems.Where(v => v.VehicleId == origin[1] && v.ItemId == vItem.ItemId).FirstOrDefault();
if (vehItem != null)
{
if (itemAmount < vehItem.Amount)
{
UserItem uItem = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == vItem.ItemId).FirstOrDefault();
if (uItem == null)
{
context.Add(vItem);
}
else
{
uItem.Amount += vItem.Amount;
}
context.SaveChanges();
return true;
}
else if (itemAmount == vehItem.Amount)
{
UserItem uItem = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == vItem.ItemId).FirstOrDefault();
if (uItem == null)
{
context.Add(vItem);
}
else
{
uItem.Amount += vItem.Amount;
}
context.SaveChanges();
return true;
}
return false;
}
}
}
}
}
else if (origin[0] == 0)
{
VehicleItem cItem = new VehicleItem
{
Amount = vehAmount,
ItemId = itemID,
VehicleId = origin[1],
Slot = -1,
};
UserItem uItem = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == cItem.ItemId).FirstOrDefault();
if (uItem != null)
{
if (vehAmount < uItem.Amount)
{
VehicleItem vehItem = context.VehicleItems.Where(v => v.VehicleId == cItem.VehicleId && v.ItemId == cItem.ItemId).FirstOrDefault();
if (vehItem == null)
{
context.Add(cItem);
}
else
{
vehItem.Amount += cItem.Amount;
}
context.SaveChanges();
return true;
}
else if (vehAmount == uItem.Amount)
{
VehicleItem vehItem = context.VehicleItems.Where(v => v.VehicleId == cItem.VehicleId && v.ItemId == cItem.ItemId).FirstOrDefault();
if (vehItem == null)
{
context.Add(cItem);
}
else
{
vehItem.Amount += cItem.Amount;
}
context.SaveChanges();
return true;
}
return false;
}
}
return false;
}
}
[RemoteEvent("saveVehicleInventory")]
public void SaveVehicleInventory(Client player, string jsonItemID, string jsonItemAmount, string jsonGotFrom, string vehAmount)
{
var itemID = JsonConvert.DeserializeObject<int>(jsonItemID);
var itemAmount = JsonConvert.DeserializeObject<int>(jsonItemAmount);
var origin = JsonConvert.DeserializeObject<int[]>(jsonGotFrom);
if (!CheckOriginOfItem(player, jsonItemID, jsonItemAmount, jsonGotFrom, vehAmount))
return;
using (var context = new DatabaseContext())
{
for (var i = 0; i < items.Length; i++)
VehicleItem vItem = new VehicleItem
{
Amount = itemAmount,
ItemId = itemID,
VehicleId = origin[1],
Slot = -1
};
VehicleItem vehItem = context.VehicleItems.Where(v => v.VehicleId == vItem.VehicleId && v.ItemId == vItem.ItemId).FirstOrDefault();
if (vehItem == null)
{
context.VehicleItems.Add(vItem);
}
else if (vItem.Amount <= 0)
{
context.VehicleItems.Remove(vehItem);
}
else
{
vehItem.Amount = vItem.Amount;
}
context.SaveChanges();
}
}
[RemoteEvent("saveInventory")]
public void SavePlayerInventory(Client player, string jsonItemID,string jsonItemAmount, string jsonGotFrom, string vehAmount)
{
var user = player.GetUser();
var itemID = JsonConvert.DeserializeObject<int>(jsonItemID);
var itemAmount = JsonConvert.DeserializeObject<int>(jsonItemAmount);
if (!CheckOriginOfItem(player,jsonItemID, jsonItemAmount,jsonGotFrom, vehAmount))
return;
using (var context = new DatabaseContext())
{
UserItem cItem = new UserItem
{
Amount = int.Parse(items[i][3]),
ItemId = GetItemByName(items[i][0]).Id,
Amount = itemAmount,
ItemId = itemID,
UserId = user.Id,
Slot = int.Parse(items[i][4]),
Slot = -1,
};
if (int.Parse(items[i][5]) == -1)
UserItem item = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == cItem.ItemId).FirstOrDefault();
if (item == null)
{
context.UserItems.Add(cItem);
}
else if (cItem.Slot == -1)
else if (cItem.Amount <= 0)
{
UserItem fItem = context.UserItems.FirstOrDefault(j => j.Id == int.Parse(items[i][5]));
context.UserItems.Remove(fItem);
context.UserItems.Remove(item);
}
else
{
UserItem fItem = context.UserItems.FirstOrDefault(j => j.Id == int.Parse(items[i][5]));
fItem.Amount = cItem.Amount;
fItem.Slot = cItem.Slot;
item.Amount = cItem.Amount;
}
}
context.SaveChanges();
player.TriggerEvent("SERVER:INVENTORY_SYNC");
}
}
@@ -230,7 +403,7 @@ namespace ReallifeGamemode.Server.Managers
}
[RemoteEvent("removeItemAsAdmin")]
public void SavePlayerInventory(Client player, string amount, string userItemId, string targetPlayerName)
public void RemoveAsAdminInventory(Client player, string amount, string userItemId, string targetPlayerName)
{
using (var context = new DatabaseContext())
{
@@ -253,12 +426,20 @@ namespace ReallifeGamemode.Server.Managers
context.SaveChanges();
}
}
[RemoteEvent("itemInteract")]
public void ItemInteract(Client player, string type, string itemId, int amount)
public void ItemInteract(Client player, string jsonType, string jsonItemId, string jsonAmount)
{
int amount = JsonConvert.DeserializeObject<int>(jsonAmount);
int itemId = JsonConvert.DeserializeObject<int>(jsonItemId);
string type = JsonConvert.DeserializeObject<string>(jsonType);
User user = player.GetUser();
using (var context = new DatabaseContext())
{
UserItem fItem = context.UserItems.FirstOrDefault(j => j.Id == int.Parse(itemId));
UserItem fItem = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == itemId).FirstOrDefault();
IItem iItem = GetItemById(fItem.ItemId);
switch (type)
@@ -282,7 +463,7 @@ namespace ReallifeGamemode.Server.Managers
usableItemObj.Use(fItem);
player.TriggerEvent("removeItem", itemId, amount);
}
else ChatService.SendMessage(player, "not useable");
else ChatService.SendMessage(player, "Du kannst dieses Item nicht benutzen.");
break;
case "drop":
@@ -308,13 +489,246 @@ namespace ReallifeGamemode.Server.Managers
GroundItem grndItem = new GroundItem { ItemId = iItem.Id, Amount = amount, Position = dropPosition };
TextLabel grndTxtLbl = NAPI.TextLabel.CreateTextLabel(iItem.Name + " ~s~(~y~" + amount + "~s~)", dropPosition, 5, 0.5f, 4, new Color(255, 255, 255), false, 0);
GroundItem.AddGroundItem(grndItem, grndObject, grndTxtLbl);
fItem.Amount -= amount;
player.TriggerEvent("removeItem", itemId, amount);
if(fItem.Amount > amount)
{
fItem.Amount -= amount;
}else if(fItem.Amount == amount)
{
context.UserItems.Remove(fItem);
}
}
break;
}
context.SaveChanges();
}
}
[RemoteEvent("tradeItem")]
public void ServerEvent_tradeItem(Client client, int value, string nameOrId, string itemIdArrStr, string itemAmountArrStr)
{
User user = client.GetUser();
Client target = ClientService.GetClientByNameOrId(nameOrId);
if (target == null || !target.IsLoggedIn() || target == client)
{
ChatService.PlayerNotFound(client);
return;
}
if (client.Position.DistanceTo(target.Position) >= 5)
{
ChatService.ErrorMessage(client, "Spieler ist zu weit entfernt.");
return;
}
int[] itemIdArr = JsonConvert.DeserializeObject<int[]>(itemIdArrStr);
int[] itemAmountArr = JsonConvert.DeserializeObject<int[]>(itemAmountArrStr);
List<string> itemNameList = new List<string>();
if (target.HasData("inTrade") && target.GetData("inTrade") == true)
{
ChatService.SendMessage(client, $"~r~[FEHLER] ~w~{target.Name} befindet sich bereits in einem Handel.");
return;
}
int inventoryWeight = 0;
using (var context = new DatabaseContext())
{
int targetInvWeight = GetUserInventoryWeight(target);
for (int i = 0; i < itemIdArr.Length; i++)
{
int itemId = itemIdArr[i];
int itemAmount = itemAmountArr[i];
UserItem uitem = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == itemId).FirstOrDefault();
IItem iItem = GetItemById(uitem.ItemId);
var currentItemWeight = iItem.Gewicht * itemAmount;
inventoryWeight += currentItemWeight;
}
if (((targetInvWeight + inventoryWeight) / 1000) > 40)
{
ChatService.ErrorMessage(client, "Handel kann nicht getätigt werden.");
return;
}
for (int x = 0; x < itemIdArr.Length; x++)
{
int itemId = itemIdArr[x];
int itemAmount = itemAmountArr[x];
UserItem item = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == itemId).FirstOrDefault();
if (item.Amount - itemAmount > 0)
{
item.Amount -= itemAmount;
}
else
{
context.UserItems.Remove(item);
}
IItem iItem = GetItemById(itemId);
itemNameList.Add(iItem.Name);
context.SaveChanges();
}
}
ChatService.SendMessage(client, $"~b~Du hast eine Handelsanfrage an {target.Name} gesendet.");
TradeItems[user.Id] = (itemIdArr, itemAmountArr);
TradeValue[user.Id] = value;
target.SetData("tradePartner", user.Id);
target.SetData("trade", client.Name);
SendTradeOffer(target, client);
target.TriggerEvent("addTradeItems", itemIdArr, itemAmountArr, itemNameList.ToArray(), inventoryWeight);
}
public void SendTradeOffer(Client client, Client sender)
{
client.SetData("inTrade", true);
sender.SetData("inTrade", true);
ChatService.SendMessage(client, $"~b~ Du hast eine Handelsanfrage von {sender.Name} bekommen.");
client.SetSharedData("tradeOffer", 1);
User user = sender.GetUser();
Timer tradeTimer = new Timer(30000);
TradeTimer[user.Id] = tradeTimer;
tradeTimer.Start();
tradeTimer.Elapsed += (s, e) => { SendBackToSender(sender); client.SetData("inTrade", false); sender.SetData("inTrade", false); client.SetSharedData("tradeOffer", 0); };
}
public void SendBackToSender(Client client)
{
User user = client.GetUser();
ChatService.SendMessage(client, "Dein Handelspartner hat die Anfrage nicht angenommen.");
(int[] itemIdArr, int[] itemAmountArr) = TradeItems[user.Id];
Timer timer = TradeTimer[user.Id];
timer.Stop();
using (var context = new DatabaseContext())
{
for (int x = 0; x < itemIdArr.Length; x++)
{
int itemId = itemIdArr[x];
int itemAmount = itemAmountArr[x];
UserItem item = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == itemId).FirstOrDefault();
if (item != null)
{
item.Amount += itemAmount;
}
else
{
var newItem = new UserItem
{
ItemId = itemId,
UserId = user.Id,
Amount = itemAmount,
Slot = -1
};
context.UserItems.Add(newItem);
}
context.SaveChanges();
}
}
}
[RemoteEvent("declineTrade")]
public void ServerEvent_declineTrade(Client client)
{
client.SetSharedData("tradeOffer", 0);
if (!client.GetData("inTrade"))
{
ChatService.ErrorMessage(client, "Das Handelsangebot ist abgelaufen.");
return;
}
string name = client.GetData("trade");
Client target = ClientService.GetClientByNameOrId(name);
if (target == null || !target.IsLoggedIn())
{
ChatService.PlayerNotFound(client);
return;
}
client.SetData("inTrade", false);
target.SetData("inTrade", false);
SendBackToSender(target);
}
public static void OpenTradeAccept(Client client)
{
User user = client.GetUser();
int id = client.GetData("tradePartner");
(int[] itemIdArr, int[] itemAmountArr) = TradeItems[id];
Timer tradeTimer = TradeTimer[id];
tradeTimer.Stop();
tradeTimer.Start();
client.TriggerEvent("openTradeWindow", TradeValue[id], itemIdArr, itemAmountArr);
}
[RemoteEvent("acceptTrade")]
public void ServerEvent_AcceptTrade(Client client)
{
if (!client.GetData("inTrade"))
{
ChatService.ErrorMessage(client, "Das Handelsangebot ist abgelaufen.");
return;
}
client.SetSharedData("tradeOffer", 0);
client.SetData("inTrade", false);
User user = client.GetUser();
int id = client.GetData("tradePartner");
(int[] itemIdArr, int[] itemAmountArr) = TradeItems[id];
Timer tradeTimer = TradeTimer[id];
tradeTimer.Stop();
string name = client.GetData("trade");
Client target = ClientService.GetClientByNameOrId(name);
if (target == null || !target.IsLoggedIn())
{
ChatService.PlayerNotFound(client);
return;
}
target.SetData("inTrade", false);
using (var context = new DatabaseContext())
{
int targetInvWeight = GetUserInventoryWeight(client);
int inventoryWeight = 0;
for (int i = 0; i < itemIdArr.Length; i++)
{
int itemId = itemIdArr[i];
int itemAmount = itemAmountArr[i];
UserItem uitem = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == itemId).FirstOrDefault();
IItem iItem = GetItemById(uitem.ItemId);
var currentItemWeight = iItem.Gewicht * itemAmount;
inventoryWeight += currentItemWeight;
}
if (((targetInvWeight + inventoryWeight) / 1000) > 40)
{
ChatService.ErrorMessage(client, "Handel kann nicht getätigt werden.");
return;
}
for (int x = 0; x < itemIdArr.Length; x++)
{
int itemId = itemIdArr[x];
int itemAmount = itemAmountArr[x];
UserItem item = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == itemId).FirstOrDefault();
if (item != null)
{
item.Amount += itemAmount;
}
else
{
var newItem = new UserItem
{
ItemId = itemId,
UserId = user.Id,
Amount = itemAmount,
Slot = -1
};
context.UserItems.Add(newItem);
}
context.SaveChanges();
}
}
ChatService.SendMessage(target, $"{client.Name} hat deine Anfrage angenommen.");
}
}
}

View File

@@ -1,368 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using GTANetworkAPI;
using Newtonsoft.Json;
using ReallifeGamemode.Server.Entities;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Models;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Util;
namespace ReallifeGamemode.Server.Managers
{
class ManagerOfInventory : Script
{
private static Dictionary<int, (int[],int[])> TradeItems { get; set; } = new Dictionary<int, (int[], int[])>();
private static Dictionary<int, Timer> TradeTimer { get; set; } = new Dictionary<int,Timer>();
private static Dictionary<int, int> TradeValue { get; set; } = new Dictionary<int, int>();
public static void GetUserItems(Client client)
{
User user = client.GetUser();
List<int> ItemId = new List<int>();
List<int> amount = new List<int>();
List<int> vehItemId = new List<int>();
List<int> vehAmount = new List<int>();
using (var context = new DatabaseContext())
{
List<UserItem> userItems = context.UserItems.ToList().FindAll(i => i.UserId == user.Id);
foreach (var item in userItems)
{
ItemId.Add(item.ItemId);
amount.Add(item.Amount);
}
foreach(Vehicle veh in NAPI.Pools.GetAllVehicles())
{
if(veh.Position.DistanceTo(client.Position) < 1)
{
if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen)
{
ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh, context);
List<VehicleItem> vehicleItems = context.VehicleItems.ToList().FindAll(i => i.VehicleId == serverVehicle.Id);
foreach (var vehItem in vehicleItems)
{
vehItemId.Add(vehItem.ItemId);
vehAmount.Add(vehItem.Amount);
}
client.TriggerEvent("vehInventoryShow", ItemId.ToArray(), amount.ToArray(), vehItemId.ToArray(), vehAmount.ToArray(), serverVehicle.Id);
return;
}
ChatService.SendMessage(client, "Kofferraum ist zu nigger!");
break;
}
}
client.TriggerEvent("inventoryShow", ItemId.ToArray(), amount.ToArray());
}
}
[RemoteEvent("invUseItem")]
public void ServerEvent_invUseItem(Client client, int itemId)
{
User user = client.GetUser();
using (var context = new DatabaseContext())
{
UserItem item = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == itemId).FirstOrDefault();
if (item.Amount > 1)
{
item.Amount -= 1;
}
else
{
context.UserItems.Remove(item);
}
client.SendNotification("Du hast ~g~" + item.Amount + " ~y~" + InventoryManager.GetItemById(itemId).Name + " ~s~ benutzt.", false);
context.SaveChanges();
return;
}
}
[RemoteEvent("saveHelper")]
public void ServerEvent_invSaveHelper(Client client, string vehID)
{
User user = client.GetUser();
int serVehID = JsonConvert.DeserializeObject<int>(vehID);
}
[RemoteEvent("saveItems")]
public void ServerEvent_invSaveItems(Client client, string itemIdArr, string itemAmountArr, string SlotArr)
{
User user = client.GetUser();
int itemId = JsonConvert.DeserializeObject<int>(itemIdArr);
int itemAmount = JsonConvert.DeserializeObject<int>(itemAmountArr);
int Slot = JsonConvert.DeserializeObject<int>(SlotArr);
using (var context = new DatabaseContext())
{
if (Slot < 24)
{
UserItem item = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == itemId).FirstOrDefault();
if (item != null)
{
item.Amount += itemAmount;
}
else
{
var newItem = new UserItem
{
ItemId = itemId,
UserId = user.Id,
Amount = itemAmount,
Slot = -1
};
context.UserItems.Add(newItem);
}
context.SaveChanges();
}
else
{
foreach (Vehicle veh in NAPI.Pools.GetAllVehicles())
{
if (veh.Position.DistanceTo(client.Position) < 1)
{
if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen)
{
ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh, context);
VehicleItem vehItem = context.VehicleItems.Where(v => v.VehicleId == serverVehicle.Id && v.ItemId == itemId).FirstOrDefault();
if (vehItem != null)
{
vehItem.Amount = itemAmount;
}
else
{
var newItem = new VehicleItem
{
ItemId = itemId,
VehicleId = serverVehicle.Id,
Amount = itemAmount,
Slot = -1
};
context.VehicleItems.Add(newItem);
}
context.SaveChanges();
}
}
}
}
}
}
[RemoteEvent("invThrowItem")]
public void ServerEvent_invThrowItem(Client client, int itemId, int amount)
{
User user = client.GetUser();
using (var context = new DatabaseContext())
{
UserItem item = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == itemId).FirstOrDefault();
if (item.Amount > amount)
{
item.Amount -= amount;
client.SendNotification("Du hast ~g~" + amount + " ~y~" + InventoryManager.GetItemById(itemId).Name + " ~s~weggeworfen.", false);
}
else
{
client.SendNotification("Du hast ~g~" + item.Amount + " ~y~" + InventoryManager.GetItemById(itemId).Name + " ~s~weggeworfen.", false);
context.UserItems.Remove(item);
}
context.SaveChanges();
return;
}
}
[RemoteEvent("tradeItem")]
public void ServerEvent_tradeItem(Client client, int value, string nameOrId, string itemIdArrStr, string itemAmountArrStr)
{
User user = client.GetUser();
Client target = ClientService.GetClientByNameOrId(nameOrId);
if (target == null || !target.IsLoggedIn() || target == client)
{
ChatService.PlayerNotFound(client);
return;
}
if(client.Position.DistanceTo(target.Position) >= 5)
{
ChatService.ErrorMessage(client, "Spieler ist zu weit entfernt.");
return;
}
int[] itemIdArr = JsonConvert.DeserializeObject<int[]>(itemIdArrStr);
int[] itemAmountArr = JsonConvert.DeserializeObject<int[]>(itemAmountArrStr);
if (target.HasData("inTrade") && target.GetData("inTrade") == true)
{
ChatService.SendMessage(client, $"~r~[FEHLER] ~w~{target.Name} befindet sich bereits in einem Handel.");
return;
}
using (var context = new DatabaseContext())
{
for (int x = 0; x < itemIdArr.Length; x++)
{
int itemId = itemIdArr[x];
int itemAmount = itemAmountArr[x];
UserItem item = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == itemId).FirstOrDefault();
if (item.Amount - itemAmount > 0)
{
item.Amount -= itemAmount;
}
else
{
context.UserItems.Remove(item);
}
context.SaveChanges();
}
}
ChatService.SendMessage(client, $"~b~Du hast eine Handelsanfrage an {target.Name} gesendet.");
TradeItems[user.Id] = (itemIdArr, itemAmountArr);
TradeValue[user.Id] = value;
target.SetData("tradePartner", user.Id);
target.SetData("trade", client.Name);
SendTradeOffer(target,client);
}
public void SendTradeOffer(Client client, Client sender)
{
client.SetData("inTrade", true);
sender.SetData("inTrade", true);
ChatService.SendMessage(client, $"~b~ Du hast eine Handelsanfrage von {sender.Name} bekommen.");
ChatService.SendMessage(client, $"~b~ Drücke '~w~X~b~' um die Handelsanfrage zu akzeptieren.");
User user = sender.GetUser();
Timer tradeTimer = new Timer(30000);
TradeTimer[user.Id] = tradeTimer;
tradeTimer.Start();
tradeTimer.Elapsed += (s, e) => { SendBackToSender(sender); client.SetData("inTrade", false); sender.SetData("inTrade", false); };
}
public void SendBackToSender(Client client)
{
User user = client.GetUser();
ChatService.SendMessage(client, "Dein Handelspartner hat die Anfrage nicht angenommen.");
(int[] itemIdArr, int[] itemAmountArr) = TradeItems[user.Id];
Timer timer = TradeTimer[user.Id];
timer.Stop();
using (var context = new DatabaseContext())
{
for (int x = 0; x < itemIdArr.Length; x++)
{
int itemId = itemIdArr[x];
int itemAmount = itemAmountArr[x];
UserItem item = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == itemId).FirstOrDefault();
if (item != null)
{
item.Amount += itemAmount;
}
else
{
var newItem = new UserItem
{
ItemId = itemId,
UserId = user.Id,
Amount = itemAmount,
Slot = -1
};
context.UserItems.Add(newItem);
}
context.SaveChanges();
}
}
}
[RemoteEvent("declineTrade")]
public void ServerEvent_declineTrade(Client client)
{
if (!client.GetData("inTrade"))
{
ChatService.ErrorMessage(client, "Das Handelsangebot ist abgelaufen.");
return;
}
string name = client.GetData("trade");
Client target = ClientService.GetClientByNameOrId(name);
if (target == null || !target.IsLoggedIn())
{
ChatService.PlayerNotFound(client);
return;
}
client.SetData("inTrade", false);
target.SetData("inTrade", false);
SendBackToSender(target);
}
public static void OpenTradeAccept(Client client)
{
User user = client.GetUser();
int id = client.GetData("tradePartner");
(int[] itemIdArr, int[] itemAmountArr) = TradeItems[id];
Timer tradeTimer = TradeTimer[id];
tradeTimer.Stop();
tradeTimer.Start();
client.TriggerEvent("openTradeWindow", TradeValue[id], itemIdArr, itemAmountArr);
}
[RemoteEvent("acceptTrade")]
public void ServerEvent_AcceptTrade(Client client)
{
if (!client.GetData("inTrade"))
{
ChatService.ErrorMessage(client, "Das Handelsangebot ist abgelaufen.");
return;
}
client.SetData("inTrade", false);
User user = client.GetUser();
int id = client.GetData("tradePartner");
(int[] itemIdArr, int[] itemAmountArr) = TradeItems[id];
Timer tradeTimer = TradeTimer[id];
tradeTimer.Stop();
string name = client.GetData("trade");
Client target = ClientService.GetClientByNameOrId(name);
if (target == null || !target.IsLoggedIn())
{
ChatService.PlayerNotFound(client);
return;
}
target.SetData("inTrade", false);
ChatService.SendMessage(target, $"{client.Name} hat deine Anfrage angenommen.");
using (var context = new DatabaseContext())
{
for (int x = 0; x < itemIdArr.Length; x++)
{
int itemId = itemIdArr[x];
int itemAmount = itemAmountArr[x];
UserItem item = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == itemId).FirstOrDefault();
if (item != null)
{
item.Amount += itemAmount;
}
else
{
var newItem = new UserItem
{
ItemId = itemId,
UserId = user.Id,
Amount = itemAmount,
Slot = -1
};
context.UserItems.Add(newItem);
}
context.SaveChanges();
}
}
}
}
}