Code formatiert

This commit is contained in:
Lennart Kampshoff
2019-12-21 14:03:06 +01:00
parent c5f72c2ce5
commit ed95acc24d
56 changed files with 1771 additions and 1764 deletions

View File

@@ -138,7 +138,7 @@ namespace ReallifeGamemode.Server.Managers
}
public static int GetVehicleInventoryWeight(Vehicle veh)
public static int GetVehicleInventoryWeight(Vehicle veh)
{
var inventoryWeight = 0;
@@ -229,19 +229,20 @@ namespace ReallifeGamemode.Server.Managers
{
IItem iItem = GetItemById(vItem.ItemId);
if (GetUserInventoryWeight(client) + (iItem.Gewicht * vItem.Amount) > 40000)
if (GetUserInventoryWeight(client) + (iItem.Gewicht * vItem.Amount) > 40000)
{
for(int i = 0; i <= vItem.Amount; i++)
for (int i = 0; i <= vItem.Amount; i++)
{
if(GetUserInventoryWeight(client) + (iItem.Gewicht * i) > 40000) {
if (GetUserInventoryWeight(client) + (iItem.Gewicht * i) > 40000)
{
vItem.Amount = i - 1;
break;
}
}
}
if(vItem.Amount == 0)
if (vItem.Amount == 0)
{
return false;
}
@@ -282,7 +283,7 @@ namespace ReallifeGamemode.Server.Managers
}
else if (origin[0] == 0)
{
VehicleItem cItem = new VehicleItem
{
Amount = vehAmount,
@@ -290,7 +291,7 @@ namespace ReallifeGamemode.Server.Managers
VehicleId = origin[1],
Slot = -1,
};
UserItem uItem = context.UserItems.Where(u => u.UserId == user.Id && u.ItemId == cItem.ItemId).FirstOrDefault();
IItem iItem = GetItemById(cItem.ItemId);
Vehicle veh = VehicleManager.GetVehicleFromId(cItem.VehicleId);
@@ -303,7 +304,7 @@ namespace ReallifeGamemode.Server.Managers
cItem.Amount = i - 1;
break;
}
}
}
@@ -399,7 +400,7 @@ namespace ReallifeGamemode.Server.Managers
[RemoteEvent("saveInventory")]
public void SavePlayerInventory(Client player, string jsonItemID,string jsonItemAmount, string jsonGotFrom, string vehAmount)
public void SavePlayerInventory(Client player, string jsonItemID, string jsonItemAmount, string jsonGotFrom, string vehAmount)
{
var user = player.GetUser();
@@ -407,34 +408,34 @@ namespace ReallifeGamemode.Server.Managers
var itemAmount = JsonConvert.DeserializeObject<int>(jsonItemAmount);
var origin = JsonConvert.DeserializeObject<int[]>(jsonGotFrom);
if (!CheckOriginOfItem(player,jsonItemID, jsonItemAmount,jsonGotFrom, vehAmount))
if (!CheckOriginOfItem(player, jsonItemID, jsonItemAmount, jsonGotFrom, vehAmount))
return;
using (var context = new DatabaseContext())
{
UserItem cItem = new UserItem
{
Amount = itemAmount,
ItemId = itemID,
UserId = user.Id,
Slot = -1,
};
UserItem cItem = new UserItem
{
Amount = itemAmount,
ItemId = itemID,
UserId = user.Id,
Slot = -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.Amount <= 0)
{
context.UserItems.Remove(item);
}
else
{
item.Amount = cItem.Amount;
}
if (item == null)
{
context.UserItems.Add(cItem);
}
else if (cItem.Amount <= 0)
{
context.UserItems.Remove(item);
}
else
{
item.Amount = cItem.Amount;
}
context.SaveChanges();
IItem iItem = GetItemById(item.ItemId);
@@ -511,7 +512,7 @@ namespace ReallifeGamemode.Server.Managers
public static void RemoveAllItemsfromVehicleInventory(Vehicle veh)
{
using(var context = new DatabaseContext())
using (var context = new DatabaseContext())
{
ServerVehicle sVeh = VehicleManager.GetServerVehicleFromVehicle(veh);
List<VehicleItem> allItemsByVehicle = context.VehicleItems.ToList().FindAll(i => i.VehicleId == sVeh.Id);
@@ -614,14 +615,15 @@ namespace ReallifeGamemode.Server.Managers
{
dropPosition.Z -= 0.8f;
grndObject = NAPI.Object.CreateObject(3777723516, dropPosition, new Vector3(0, 0, r.Next(0, 360)), 0);
}
}
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);
if(fItem.Amount > amount)
if (fItem.Amount > amount)
{
fItem.Amount -= amount;
}else if(fItem.Amount == amount)
}
else if (fItem.Amount == amount)
{
context.UserItems.Remove(fItem);
}
@@ -654,7 +656,7 @@ namespace ReallifeGamemode.Server.Managers
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)
{
@@ -665,7 +667,7 @@ namespace ReallifeGamemode.Server.Managers
using (var context = new DatabaseContext())
{
int targetInvWeight = GetUserInventoryWeight(target);
for (int i = 0; i < itemIdArr.Length; i++)
{
int itemId = itemIdArr[i];
@@ -813,7 +815,7 @@ namespace ReallifeGamemode.Server.Managers
return;
}
target.SetData("inTrade", false);
using (var context = new DatabaseContext())
{