Inventory System
This commit is contained in:
55
Client/Gui/Inventory/inventory-style.css
Normal file
55
Client/Gui/Inventory/inventory-style.css
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
|
||||||
|
|
||||||
|
body {
|
||||||
|
width: 50%;
|
||||||
|
position: center;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inventory-table {
|
||||||
|
background-color: darkgray;
|
||||||
|
position: absolute;
|
||||||
|
padding: 2%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inventory-row {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: flex-start; /* align items in Main Axis */
|
||||||
|
align-items: flex-start; /* align items in Cross Axis */
|
||||||
|
align-content: flex-start; /* Extra space in Cross Axis */
|
||||||
|
}
|
||||||
|
.inventory-item.axe1 {
|
||||||
|
background-position: -170px -340px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inventory-cell {
|
||||||
|
width: 160px;
|
||||||
|
height: 160px;
|
||||||
|
background-color: dimgray;
|
||||||
|
border: solid;
|
||||||
|
border-color: darkorange;
|
||||||
|
border-width: 1px;
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inventory-slot {
|
||||||
|
font-family: Pricedown;
|
||||||
|
color: white;
|
||||||
|
background-color: black;
|
||||||
|
padding: 2px;
|
||||||
|
font-size: 25px;
|
||||||
|
vertical-align: top;
|
||||||
|
width: 20%;
|
||||||
|
text-align: center;
|
||||||
|
text-shadow: 2px 2px 3px orange;
|
||||||
|
|
||||||
|
}
|
||||||
|
.inventory-item {
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
background-color: red;
|
||||||
|
margin: 0 auto;
|
||||||
|
text-align: center;
|
||||||
|
font-family:'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
|
||||||
|
}
|
||||||
315
Client/Gui/Inventory/inventory.html
Normal file
315
Client/Gui/Inventory/inventory.html
Normal file
@@ -0,0 +1,315 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="stylesheet" href="inventory-style.css" />
|
||||||
|
<!--<script src="Inventory/inventory.js"></script>-->
|
||||||
|
<script src="jquery-3.3.1.min.js"></script>
|
||||||
|
<script>
|
||||||
|
function allowDrop(ev) {
|
||||||
|
ev.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
function drag(ev) {
|
||||||
|
ev.dataTransfer.setData("text", ev.target.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function drop(ev) {
|
||||||
|
ev.preventDefault();
|
||||||
|
var data = ev.dataTransfer.getData("text");
|
||||||
|
ev.target.appendChild(document.getElementById(data));
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="inventory-table" id="personal-inventory">
|
||||||
|
<div class="inventory-row">
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot0">
|
||||||
|
<div class="inventory-slot">1</div>
|
||||||
|
<div class="inventory-item" draggable="true" ondragstart="drag(event)" id="item1">Hamburger</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot1">
|
||||||
|
<div class="inventory-slot">2</div>
|
||||||
|
<div class="inventory-item" draggable="true" ondragstart="drag(event)" id="item2" style="background-color:yellow;">Cheeseburger</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot2">
|
||||||
|
<div class="inventory-slot">3</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot3">
|
||||||
|
<div class="inventory-slot">4</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot4">
|
||||||
|
<div class="inventory-slot">5</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-row">
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot5">
|
||||||
|
<div class="inventory-slot">6</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot6">
|
||||||
|
<div class="inventory-slot">7</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot7">
|
||||||
|
<div class="inventory-slot">8</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot8">
|
||||||
|
<div class="inventory-slot">9</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot9">
|
||||||
|
<div class="inventory-slot">10</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-row">
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot10">
|
||||||
|
<div class="inventory-slot">11</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot11">
|
||||||
|
<div class="inventory-slot">12</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot12">
|
||||||
|
<div class="inventory-slot">13</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot13">
|
||||||
|
<div class="inventory-slot">14</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot14">
|
||||||
|
<div class="inventory-slot">15</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-row">
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot15">
|
||||||
|
<div class="inventory-slot">16</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot16">
|
||||||
|
<div class="inventory-slot">17</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot17">
|
||||||
|
<div class="inventory-slot">18</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot18">
|
||||||
|
<div class="inventory-slot">19</div>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot19">
|
||||||
|
<div class="inventory-slot">20</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
jQuery.fn.extend({
|
||||||
|
addRemoveItems: function (targetCount) {
|
||||||
|
return this.each(function () {
|
||||||
|
var $children = $(this).children();
|
||||||
|
var rowCountDifference = targetCount - $children.length;
|
||||||
|
//console.log('row count diff: ' + rowCountDifference);
|
||||||
|
|
||||||
|
if (rowCountDifference > 0) {
|
||||||
|
// Add items
|
||||||
|
for (var i = 0; i < rowCountDifference; i++) {
|
||||||
|
//console.log($rows.first());
|
||||||
|
$children.last().clone().appendTo(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (rowCountDifference < 0) {
|
||||||
|
// remove items
|
||||||
|
$children.slice(rowCountDifference).remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// Modified and Updated by MLM
|
||||||
|
// Origin: Davy8 (http://stackoverflow.com/a/5212193/796832)
|
||||||
|
parentToAnimate: function (newParent, duration) {
|
||||||
|
duration = duration || 'slow';
|
||||||
|
|
||||||
|
var $element = $(this);
|
||||||
|
//console.log($element);
|
||||||
|
if ($element.length > 0) {
|
||||||
|
|
||||||
|
newParent = $(newParent); // Allow passing in either a JQuery object or selector
|
||||||
|
var oldOffset = $element.offset();
|
||||||
|
$(this).appendTo(newParent);
|
||||||
|
var newOffset = $element.offset();
|
||||||
|
|
||||||
|
|
||||||
|
var temp = $element.clone().appendTo('body');
|
||||||
|
|
||||||
|
temp.css({
|
||||||
|
'position': 'absolute',
|
||||||
|
'left': oldOffset.left,
|
||||||
|
'top': oldOffset.top,
|
||||||
|
'zIndex': 1000
|
||||||
|
});
|
||||||
|
|
||||||
|
$element.hide();
|
||||||
|
|
||||||
|
temp.animate({
|
||||||
|
'top': newOffset.top,
|
||||||
|
'left': newOffset.left
|
||||||
|
}, duration, function () {
|
||||||
|
$element.show();
|
||||||
|
temp.remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
//console.log("parentTo Animate done");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#row-count').on('input propertychange change', function () {
|
||||||
|
var targetRowCount = $(this).val();
|
||||||
|
//console.log('target count: ' + targetRowCount);
|
||||||
|
$('label[for="' + $(this).attr('id') + '"]').html(targetRowCount);
|
||||||
|
|
||||||
|
$('#personal-inventory.inventory-table').addRemoveItems(targetRowCount);
|
||||||
|
|
||||||
|
refreshSortableInventoryList();
|
||||||
|
}).trigger('change');
|
||||||
|
|
||||||
|
$('#column-count').on('input propertychange change', function () {
|
||||||
|
var targetColumnCount = $(this).val();
|
||||||
|
//console.log('target count: ' + targetColumnCount);
|
||||||
|
$('label[for="' + $(this).attr('id') + '"]').html(targetColumnCount);
|
||||||
|
|
||||||
|
$('#personal-inventory.inventory-table .inventory-row').addRemoveItems(targetColumnCount);
|
||||||
|
|
||||||
|
refreshSortableInventoryList();
|
||||||
|
}).trigger('change');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Sorting, dragging, dropping, etc
|
||||||
|
|
||||||
|
refreshSortableInventoryList();
|
||||||
|
function refreshSortableInventoryList() {
|
||||||
|
$('.inventory-cell').sortable({
|
||||||
|
connectWith: '.inventory-cell',
|
||||||
|
placeholder: 'inventory-item-sortable-placeholder',
|
||||||
|
receive: function (event, ui) {
|
||||||
|
var attrWhitelist = $(this).closest('.inventory-table').attr('data-item-filter-whitelist');
|
||||||
|
var attrBlackList = $(this).closest('.inventory-table').attr('data-item-filter-blacklist');
|
||||||
|
var itemFilterWhitelistArray = attrWhitelist ? attrWhitelist.split(/\s+/) : [];
|
||||||
|
var itemFilterBlacklistArray = attrBlackList ? attrBlackList.split(/\s+/) : [];
|
||||||
|
//console.log(itemFilterWhitelistArray);
|
||||||
|
//console.log(itemFilterBlacklistArray);
|
||||||
|
|
||||||
|
var attrTypeList = $(ui.item).attr('data-item-type');
|
||||||
|
var itemTypeListArray = attrTypeList ? attrTypeList.split(/\s+/) : [];
|
||||||
|
//console.log(itemTypeListArray);
|
||||||
|
|
||||||
|
var canMoveIntoSlot = verifyWithWhiteBlackLists(itemTypeListArray, itemFilterWhitelistArray, itemFilterBlacklistArray)
|
||||||
|
|
||||||
|
if (!canMoveIntoSlot) {
|
||||||
|
console.log("Can't move to this slot");
|
||||||
|
//$(ui.sender).sortable('cancel');
|
||||||
|
$(ui.item).parentToAnimate($(ui.sender), 200);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
// Swap places of items if dragging on top of another
|
||||||
|
// Add the items in this list to the list the new item was from
|
||||||
|
$(this).children().not(ui.item).parentToAnimate($(ui.sender), 200);
|
||||||
|
|
||||||
|
// $(this) is the list the item is being moved into
|
||||||
|
// $(ui.sender) is the list the item came from
|
||||||
|
// Don't forget the move swap items as well
|
||||||
|
|
||||||
|
// $(this).attr('data-slot-position-x');
|
||||||
|
// $(this).attr('data-slot-position-y');
|
||||||
|
// $(ui.sender).attr('data-slot-position-x');
|
||||||
|
// $(ui.sender).attr('data-slot-position-y');
|
||||||
|
//console.log("Moving to: (" + $(this).attr('data-slot-position-x') + ", " + $(this).attr('data-slot-position-y') + ") - From: (" + $(ui.sender).attr('data-slot-position-x') + ", " + $(ui.sender).attr('data-slot-position-y') + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).each(function () {
|
||||||
|
// Setup some nice attributes for everything
|
||||||
|
// Makes it easier to update the backend
|
||||||
|
$(this).attr('data-slot-position-x', $(this).prevAll('.inventory-cell').length);
|
||||||
|
$(this).attr('data-slot-position-y', $(this).closest('.inventory-row').prevAll('.inventory-row').length);
|
||||||
|
}).disableSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
function verifyWithWhiteBlackLists(itemList, whiteList, blackList) {
|
||||||
|
// itemList should contain tags
|
||||||
|
// whiteList and blackList can contain tags and tag queries
|
||||||
|
|
||||||
|
// If we have a matching tags to some tag query in the whiteList but not in the blackList, then return true
|
||||||
|
// Else return false
|
||||||
|
|
||||||
|
|
||||||
|
console.group("Lists");
|
||||||
|
console.log(itemList);
|
||||||
|
console.log(whiteList);
|
||||||
|
console.log(blackList);
|
||||||
|
console.groupEnd();
|
||||||
|
|
||||||
|
// If white and black lists are empty, return true
|
||||||
|
// Save the calculations, no filtering
|
||||||
|
if (whiteList.length == 0 && blackList.length == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Check if the itemList has an item in the blackList
|
||||||
|
var inBlackList = false;
|
||||||
|
$.each(blackList, function (index, value) {
|
||||||
|
var itemBlack = value;
|
||||||
|
var itemBlackAndArray = itemBlack.split(/\+/);
|
||||||
|
console.log(itemBlackAndArray);
|
||||||
|
|
||||||
|
var andedResult = true;
|
||||||
|
for (var i = 0; i < itemBlackAndArray.length; i++) {
|
||||||
|
if (blackList.length > 0 && $.inArray(itemBlackAndArray[i], itemList) !== -1) {
|
||||||
|
andedResult = andedResult && true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
andedResult = andedResult && false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (andedResult)
|
||||||
|
inBlackList = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
inBlackList = blackList.length > 0 ? inBlackList : false;
|
||||||
|
|
||||||
|
|
||||||
|
// Check if the itemList has an item in the whiteList
|
||||||
|
var inWhiteList = false;
|
||||||
|
$.each(whiteList, function (index, value) {
|
||||||
|
var itemWhite = value;
|
||||||
|
var itemWhiteAndArray = itemWhite.split(/\+/);
|
||||||
|
//console.log(itemWhiteAndArray);
|
||||||
|
|
||||||
|
var andedResult = true;
|
||||||
|
for (var i = 0; i < itemWhiteAndArray.length; i++) {
|
||||||
|
if (whiteList.length > 0 && $.inArray(itemWhiteAndArray[i], itemList) !== -1) {
|
||||||
|
andedResult = andedResult && true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
andedResult = andedResult && false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//console.log("andedResult: " + andedResult);
|
||||||
|
|
||||||
|
if (andedResult)
|
||||||
|
inWhiteList = true;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
inWhiteList = whiteList.length > 0 ? inWhiteList : false;
|
||||||
|
|
||||||
|
|
||||||
|
console.log("inWhite: " + inWhiteList + " - inBlack: " + inBlackList);
|
||||||
|
|
||||||
|
if ((whiteList.length == 0 || inWhiteList) && !inBlackList)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
15
Client/Gui/Inventory/inventory.js
Normal file
15
Client/Gui/Inventory/inventory.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
var inventoryBrowser;
|
||||||
|
|
||||||
|
mp.events.add("showInventory", (show) => {
|
||||||
|
if (show === true) {
|
||||||
|
inventoryBrowser = mp.browsers.new('package://Gui/Inventory/inventory.html');
|
||||||
|
mp.gui.chat.activate(false);
|
||||||
|
mp.gui.cursor.show(true, true);
|
||||||
|
} else {
|
||||||
|
if (inventoryBrowser) {
|
||||||
|
inventoryBrowser.destroy();
|
||||||
|
mp.gui.chat.activate(true);
|
||||||
|
mp.gui.cursor.show(false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
2
Client/Gui/Inventory/jquery-3.3.1.min.js
vendored
Normal file
2
Client/Gui/Inventory/jquery-3.3.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -7,6 +7,7 @@
|
|||||||
//https://docs.microsoft.com/de-de/windows/desktop/inputdev/virtual-key-codes
|
//https://docs.microsoft.com/de-de/windows/desktop/inputdev/virtual-key-codes
|
||||||
|
|
||||||
var chat = false;
|
var chat = false;
|
||||||
|
var showInventory = false;
|
||||||
|
|
||||||
//ENTER
|
//ENTER
|
||||||
mp.keys.bind(0x0D, false, function () {
|
mp.keys.bind(0x0D, false, function () {
|
||||||
@@ -23,6 +24,17 @@ mp.keys.bind(0x49, false, function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//J
|
||||||
|
mp.keys.bind(0x4A, false, function () {
|
||||||
|
if (showInventory === false) {
|
||||||
|
mp.events.call("showInventory", true);
|
||||||
|
showInventory = true;
|
||||||
|
} else {
|
||||||
|
mp.events.call("showInventory", false);
|
||||||
|
showInventory = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//N
|
//N
|
||||||
mp.keys.bind(0x4E, false, function () {
|
mp.keys.bind(0x4E, false, function () {
|
||||||
if (!chat) {
|
if (!chat) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ require('./Save/main.js');
|
|||||||
require('./Gui/deathscreen.js');
|
require('./Gui/deathscreen.js');
|
||||||
require('./Gui/infobox.js');
|
require('./Gui/infobox.js');
|
||||||
require('./Gui/playerlist.js');
|
require('./Gui/playerlist.js');
|
||||||
|
require('./Gui/Inventory/inventory.js');
|
||||||
|
|
||||||
require('./Player/keys.js');
|
require('./Player/keys.js');
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
{
|
{
|
||||||
public class Admin : Script
|
public class Admin : Script
|
||||||
{
|
{
|
||||||
[Command("eat")]
|
[Command("myitems")]
|
||||||
public void CmdAdminEat(Client player)
|
public void CmdAdminMyItems(Client player)
|
||||||
{
|
{
|
||||||
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
|
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
|
||||||
{
|
{
|
||||||
@@ -36,11 +36,28 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hamburger hamburger = new Hamburger();
|
List<UserItem> itemList = player.GetData("items");
|
||||||
if(hamburger is IUsableItem)
|
|
||||||
|
foreach (var item in itemList)
|
||||||
{
|
{
|
||||||
var usableItemObj = hamburger as IUsableItem;
|
IItem iitem = item;
|
||||||
usableItemObj.Use(player);
|
player.SendChatMessage(item. + );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("giveitem", "~m~Benutzung: ~s~/giveitem [Target] [Item ID] [Anzahl]")]
|
||||||
|
public void CmdAdminGiveItem(Client player, Client target, int itemId, int amount)
|
||||||
|
{
|
||||||
|
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
|
||||||
|
{
|
||||||
|
ChatService.NotAuthorized(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target == null || !target.IsLoggedIn())
|
||||||
|
{
|
||||||
|
ChatService.PlayerNotFound(player);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[Command("vmod", "~m~Benutzung: ~s~/vmod [Slot] [Mod ID]")]
|
[Command("vmod", "~m~Benutzung: ~s~/vmod [Slot] [Mod ID]")]
|
||||||
|
|||||||
@@ -51,34 +51,9 @@ namespace reallife_gamemode.Server.Events
|
|||||||
var userBankAccount = loginUser.UserBankAccounts.SingleOrDefault(u => u.UserId == user.Id);
|
var userBankAccount = loginUser.UserBankAccounts.SingleOrDefault(u => u.UserId == user.Id);
|
||||||
userBankAccount.Balance = userBankAccount.Balance;
|
userBankAccount.Balance = userBankAccount.Balance;
|
||||||
|
|
||||||
if (user.Dead == true)
|
var userItems = loginUser.UserItems.ToList().FindAll(u => u.UserId == user.Id);
|
||||||
{
|
player.SetData("items", userItems);
|
||||||
if (user.IsAdmin(AdminLevel.ADMIN) == true)
|
|
||||||
{
|
|
||||||
player.TriggerEvent("startDeathTimer", true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.TriggerEvent("startDeathTimer", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
player.SetData("isDead", true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.SetData("isDead", false);
|
|
||||||
}
|
|
||||||
if (user.Dead == true)
|
|
||||||
{
|
|
||||||
//player.TriggerEvent("startDeathTimer");
|
|
||||||
//player.SetData("isDead", true);
|
|
||||||
//TODO: Deathlog entfernen
|
|
||||||
player.Health = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.SetData("isDead", false);
|
|
||||||
}
|
|
||||||
if (user.CharacterId == null)
|
if (user.CharacterId == null)
|
||||||
{
|
{
|
||||||
var currentPlayerCreatorDimension = (uint) NAPI.Data.GetWorldData("playerCreatorDimension");
|
var currentPlayerCreatorDimension = (uint) NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||||
@@ -94,6 +69,24 @@ namespace reallife_gamemode.Server.Events
|
|||||||
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
||||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||||
}
|
}
|
||||||
|
if (user.Dead == true)
|
||||||
|
{
|
||||||
|
if (user.IsAdmin(AdminLevel.ADMIN) == true)
|
||||||
|
{
|
||||||
|
player.TriggerEvent("startDeathTimer", true);
|
||||||
|
player.Health = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.TriggerEvent("startDeathTimer", false);
|
||||||
|
player.Health = 0;
|
||||||
|
}
|
||||||
|
player.SetData("isDead", true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.SetData("isDead", false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
23
Server/Inventory/Items/Cheeseburger.cs
Normal file
23
Server/Inventory/Items/Cheeseburger.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using reallife_gamemode.Server.Inventory.Interfaces;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||||
|
* @author VegaZ
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Inventory.Items
|
||||||
|
{
|
||||||
|
public class Cheeseburger : FoodItem, IItem
|
||||||
|
{
|
||||||
|
public int Id => 2;
|
||||||
|
public string Name => "Cheeseburger";
|
||||||
|
public string Description => "Wie der Hamburger, nur mit Käse.";
|
||||||
|
public int Gewicht => 320;
|
||||||
|
public string Einheit => "g";
|
||||||
|
public override int HpAmount => 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,6 @@ namespace reallife_gamemode.Server.Inventory.Items
|
|||||||
public string Description => "Ein leckerer Hamburger.";
|
public string Description => "Ein leckerer Hamburger.";
|
||||||
public int Gewicht => 300;
|
public int Gewicht => 300;
|
||||||
public string Einheit => "g";
|
public string Einheit => "g";
|
||||||
public override int HpAmount => 50;
|
public override int HpAmount => 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
22
Server/Managers/InventoryManager.cs
Normal file
22
Server/Managers/InventoryManager.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using reallife_gamemode.Model;
|
||||||
|
using reallife_gamemode.Server.Inventory.Interfaces;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - Managers InventoryManager (InventoryManager.cs)
|
||||||
|
* @author hydrant, VegaZ
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Managers
|
||||||
|
{
|
||||||
|
public class InventoryManager
|
||||||
|
{
|
||||||
|
public static IItem GetItemById(this int id, DatabaseContext context = null)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user