[*] Fixed Vehicle Invetory

This commit is contained in:
Lukas Moungos
2019-09-14 16:10:52 +02:00
parent a91b72d2b8
commit 8185948575
3 changed files with 25 additions and 12 deletions

View File

@@ -219,9 +219,10 @@
for (i = 0; i < vehicle.ivehName.length; i++) { for (i = 0; i < vehicle.ivehName.length; i++) {
var newItem = { Name: vehicle.ivehName[i], ID: vehicle.ivehId[i], Amount: vehicle.ivehAmount[i], Category: 1 }; var newItem = { Name: vehicle.ivehName[i], ID: vehicle.ivehId[i], Amount: vehicle.ivehAmount[i], Category: 1 };
vehInv.push(newItem); vehInv.push(newItem);
}
Origin.push(0); Origin.push(0);
Origin.push(vehicle.ID); Origin.push(vehicle.ID);
}
var jsonVehInv = JSON.stringify(vehInv); var jsonVehInv = JSON.stringify(vehInv);
$('#count2').html(vehInvItem[0].currentWeight / 1000); $('#count2').html(vehInvItem[0].currentWeight / 1000);
RecieveVehicleInfo(jsonVehInv); RecieveVehicleInfo(jsonVehInv);
@@ -397,7 +398,7 @@
rucksackInv[i].Amount -= $('#tf_zahl').val(); rucksackInv[i].Amount -= $('#tf_zahl').val();
mp.trigger("CEF:throwItem", JSON.stringify("drop"), JSON.stringify($('#tf_zahl').val()), JSON.stringify(rucksackInv[i].ID)) mp.trigger("CEF:throwItem", JSON.stringify("drop"), JSON.stringify($('#tf_zahl').val()), JSON.stringify(rucksackInv[i].ID))
} else if ($('#tf_zahl').val() >= ammount) { } else if ($('#tf_zahl').val() >= ammount) {
mp.trigger("CEF:throwItem", JSON.stringify("drop"), JSON.stringify(0), JSON.stringify(rucksackInv[i].ID)) mp.trigger("CEF:throwItem", JSON.stringify("drop"), JSON.stringify(ammount), JSON.stringify(rucksackInv[i].ID))
rucksackInv.splice(i, 1); rucksackInv.splice(i, 1);
} }
@@ -457,6 +458,15 @@
event.stopPropagation() event.stopPropagation()
}); });
$("#tf_submitZahlToVehicle").unbind('click').click(function () { $("#tf_submitZahlToVehicle").unbind('click').click(function () {
if (Origin.length < 2) {
$(".Betrag2").hide();
drawVehicle();
drawRucksack();
event.preventDefault()
event.stopPropagation()
return;
}
var y = parseInt($('#tf_zahl2').val(), 10); var y = parseInt($('#tf_zahl2').val(), 10);
if ($('#tf_zahl2').val() < ammount && ammount > 0) { if ($('#tf_zahl2').val() < ammount && ammount > 0) {

View File

@@ -30,9 +30,8 @@ namespace ReallifeGamemode.Server.Events
List<int> iAmount = new List<int>(); List<int> iAmount = new List<int>();
List<int> iId = new List<int>(); List<int> iId = new List<int>();
inventoryWeight = 0; inventoryWeight = 0;
int vehID = 0;
if (veh.Position.DistanceTo(client.Position) < 2) if (veh.Position.DistanceTo(client.Position) < 2.5f)
{ {
if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen) if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen)
{ {
@@ -47,11 +46,11 @@ namespace ReallifeGamemode.Server.Events
iName.Add(iItem.Name); iName.Add(iItem.Name);
iAmount.Add(vehItem.Amount); iAmount.Add(vehItem.Amount);
iId.Add(iItem.Id); iId.Add(iItem.Id);
vehID = vehItem.VehicleId;
} }
var vehInv = new VehicleInventory var vehInv = new VehicleInventory
{ {
ID = vehID, ID = serverVehicle.Id,
currentWeight = inventoryWeight, currentWeight = inventoryWeight,
totalWeight = 250, totalWeight = 250,
ivehName = iName.ToArray(), ivehName = iName.ToArray(),
@@ -60,10 +59,11 @@ namespace ReallifeGamemode.Server.Events
}; };
vehicleInventory.Add(vehInv); vehicleInventory.Add(vehInv);
} }
client.TriggerEvent("setVehiclesInventory", vehicleInventory.ToArray());
return;
} }
} }
} }
client.TriggerEvent("setVehiclesInventory", vehicleInventory.ToArray());
} }
} }
} }

View File

@@ -174,7 +174,6 @@ namespace ReallifeGamemode.Server.Managers
public bool CheckOriginOfItem(Client client, string jsonItemID, string jsonItemAmount, string jsonOrigin, string jsonVehAmount) public bool CheckOriginOfItem(Client client, string jsonItemID, string jsonItemAmount, string jsonOrigin, string jsonVehAmount)
{ {
NAPI.Util.ConsoleOutput("HIER LENNART ->>>>, " + jsonOrigin);
var origin = JsonConvert.DeserializeObject<int[]>(jsonOrigin); var origin = JsonConvert.DeserializeObject<int[]>(jsonOrigin);
var itemID = JsonConvert.DeserializeObject<int>(jsonItemID); var itemID = JsonConvert.DeserializeObject<int>(jsonItemID);
var itemAmount = JsonConvert.DeserializeObject<int>(jsonItemAmount); var itemAmount = JsonConvert.DeserializeObject<int>(jsonItemAmount);
@@ -182,11 +181,15 @@ namespace ReallifeGamemode.Server.Managers
var user = client.GetUser(); var user = client.GetUser();
using (var context = new DatabaseContext()) using (var context = new DatabaseContext())
{ {
if (origin.Length < 1)
return false;
if (origin[0] == 1) if (origin[0] == 1)
{ {
foreach (Vehicle veh in NAPI.Pools.GetAllVehicles()) foreach (Vehicle veh in NAPI.Pools.GetAllVehicles())
{ {
if (veh.Position.DistanceTo(client.Position) < 2) if (veh.Position.DistanceTo(client.Position) < 2.5f)
{ {
if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen) if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen)
{ {
@@ -429,7 +432,7 @@ namespace ReallifeGamemode.Server.Managers
} }
[RemoteEvent("itemInteract")] [RemoteEvent("itemInteract")]
public void ItemInteract(Client player, string jsonType, string jsonItemId, string jsonAmount) public void ItemInteract(Client player, string jsonType, string jsonAmount, string jsonItemId)
{ {
int amount = JsonConvert.DeserializeObject<int>(jsonAmount); int amount = JsonConvert.DeserializeObject<int>(jsonAmount);
int itemId = JsonConvert.DeserializeObject<int>(jsonItemId); int itemId = JsonConvert.DeserializeObject<int>(jsonItemId);