[#] Finish Inventory System
This commit is contained in:
@@ -692,6 +692,29 @@ t#tf_nameorid {
|
|||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#tf_acceptTrade {
|
||||||
|
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_acceptTrade:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
#tf_cancle3 {
|
#tf_cancle3 {
|
||||||
background-color: #ff0000;
|
background-color: #ff0000;
|
||||||
border: none;
|
border: none;
|
||||||
|
|||||||
@@ -81,6 +81,7 @@
|
|||||||
|
|
||||||
<div name="anfrageClass" class="something hidden">
|
<div name="anfrageClass" class="something hidden">
|
||||||
<div class="main">
|
<div class="main">
|
||||||
|
<button id='tf_acceptTrade' onclick="">Annehmen</button>
|
||||||
<div class="title"><div class="titlecount"><span id="count4">0</span> Kilogramm</div><div class="titletext">Anfrage</div></div>
|
<div class="title"><div class="titlecount"><span id="count4">0</span> Kilogramm</div><div class="titletext">Anfrage</div></div>
|
||||||
<div class="items">
|
<div class="items">
|
||||||
<ul id="List3"></ul>
|
<ul id="List3"></ul>
|
||||||
@@ -108,6 +109,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$("#tf_acceptTrade").unbind('click').click(function () {
|
||||||
|
if (anfrageInv.length > 0) {
|
||||||
|
mp.trigger("CEF:acceptTrade");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$("#tf_submitTrade").unbind('click').click(function () {
|
$("#tf_submitTrade").unbind('click').click(function () {
|
||||||
if (handelInv.length > 0) {
|
if (handelInv.length > 0) {
|
||||||
var handelItemID = [];
|
var handelItemID = [];
|
||||||
@@ -116,7 +123,7 @@
|
|||||||
handelItemID.push(handelInv[i].ID);
|
handelItemID.push(handelInv[i].ID);
|
||||||
handelItemAmount.push(handelInv[i].Amount);
|
handelItemAmount.push(handelInv[i].Amount);
|
||||||
}
|
}
|
||||||
mp.trigger("CEF:tradeItem", 0, JSON.stringify(String($('#fname').val())), JSON.stringify(handelItemID), JSON.stringify(handelItemAmount))
|
mp.trigger("CEF:tradeItem", 0, JSON.stringify(String($('#tf_nameorid').val())), JSON.stringify(handelItemID), JSON.stringify(handelItemAmount))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$("#tf_cancle4").unbind('click').click(function () {
|
$("#tf_cancle4").unbind('click').click(function () {
|
||||||
@@ -872,7 +879,6 @@
|
|||||||
Litem.setAttribute("name", "List" + item.Category);
|
Litem.setAttribute("name", "List" + item.Category);
|
||||||
Litem.appendChild(document.createTextNode(quantity + "x " + item.Name));
|
Litem.appendChild(document.createTextNode(quantity + "x " + item.Name));
|
||||||
Litem.appendChild(pictureElement);
|
Litem.appendChild(pictureElement);
|
||||||
Litem.appendChild(blueButton);
|
|
||||||
list.appendChild(Litem);
|
list.appendChild(Litem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,16 +45,28 @@ export default function inventory(globalData: GlobalData): void {
|
|||||||
invBrowser = mp.browsers.new("package://assets/html/inventory/inventory.html");
|
invBrowser = mp.browsers.new("package://assets/html/inventory/inventory.html");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
var offer = 0;
|
||||||
|
|
||||||
|
var tradeItemID;
|
||||||
|
var tradeItemAmount;
|
||||||
|
var tradeItemName;
|
||||||
|
var tradeItemWeight;
|
||||||
|
|
||||||
mp.events.addDataHandler("tradeOffer", (entity, value) => {
|
mp.events.addDataHandler("tradeOffer", (entity, value) => {
|
||||||
if (entity.type === "player") {
|
if (entity.type === "player") {
|
||||||
let offer = parseInt(value);
|
offer = parseInt(value);
|
||||||
|
if (invBrowser != null)
|
||||||
invBrowser.execute(`changeTradeStatus('${JSON.stringify(offer)}')`);
|
invBrowser.execute(`changeTradeStatus('${JSON.stringify(offer)}')`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("addTradeItems", (itemId, itemAmount, itemName, weight) => {
|
mp.events.add("addTradeItems", (itemId, itemAmount, itemName, weight) => {
|
||||||
invBrowser.execute(`setAnfrage('${JSON.stringify(itemId)}','${JSON.stringify(itemAmount)}','${JSON.stringify(itemName)}','${JSON.stringify(weight)}');`);
|
tradeItemID = JSON.stringify(itemId);
|
||||||
|
tradeItemAmount = JSON.stringify(itemAmount);
|
||||||
|
tradeItemName = JSON.stringify(itemName);
|
||||||
|
tradeItemWeight = JSON.stringify(weight);
|
||||||
|
if (invBrowser != null)
|
||||||
|
invBrowser.execute(`setAnfrage('${tradeItemID}','${tradeItemAmount}','${tradeItemName}','${tradeItemWeight}');`);
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("CEF:saveVehicleTransfer", (val, jsonOrigin, jsonInvID, jsonInvAmount, jsonVehAmount) => {
|
mp.events.add("CEF:saveVehicleTransfer", (val, jsonOrigin, jsonInvID, jsonInvAmount, jsonVehAmount) => {
|
||||||
@@ -75,6 +87,11 @@ export default function inventory(globalData: GlobalData): void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("CEF:InventoryLoaded", () => {
|
mp.events.add("CEF:InventoryLoaded", () => {
|
||||||
|
if (offer == 1) {
|
||||||
|
invBrowser.execute(`changeTradeStatus('${JSON.stringify(offer)}')`);
|
||||||
|
invBrowser.execute(`setAnfrage('${tradeItemID}','${tradeItemAmount}','${tradeItemName}','${tradeItemWeight}');`);
|
||||||
|
}
|
||||||
|
|
||||||
invBrowser.execute(`setItems('${JSON.stringify(itemNameArr)}','${JSON.stringify(itemIdArr)}','${JSON.stringify(itemAmountArr)}','${JSON.stringify(Players)}');`);
|
invBrowser.execute(`setItems('${JSON.stringify(itemNameArr)}','${JSON.stringify(itemIdArr)}','${JSON.stringify(itemAmountArr)}','${JSON.stringify(Players)}');`);
|
||||||
invBrowser.execute(`setWeight('${JSON.stringify(invWeight)}');`);
|
invBrowser.execute(`setWeight('${JSON.stringify(invWeight)}');`);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
User user = client.GetUser();
|
User user = client.GetUser();
|
||||||
string nameOrId = JsonConvert.DeserializeObject<string>(jsonNameOrId);
|
string nameOrId = JsonConvert.DeserializeObject<string>(jsonNameOrId);
|
||||||
Client target = ClientService.GetClientByNameOrId(nameOrId);
|
Client target = ClientService.GetClientByNameOrId(nameOrId);
|
||||||
if (target == null || !target.IsLoggedIn() || target == client)
|
if (target == null || !target.IsLoggedIn() )
|
||||||
{
|
{
|
||||||
ChatService.PlayerNotFound(client);
|
ChatService.PlayerNotFound(client);
|
||||||
return;
|
return;
|
||||||
@@ -586,12 +586,12 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
client.SetData("inTrade", true);
|
client.SetData("inTrade", true);
|
||||||
sender.SetData("inTrade", true);
|
sender.SetData("inTrade", true);
|
||||||
ChatService.SendMessage(client, $"~b~ Du hast eine Handelsanfrage von {sender.Name} bekommen.");
|
ChatService.SendMessage(client, $"~b~ Du hast eine Handelsanfrage von {sender.Name} bekommen.");
|
||||||
client.SetSharedData("tradeOffer", 1);
|
client.SetSharedData("tradeOffer", JsonConvert.SerializeObject(1));
|
||||||
User user = sender.GetUser();
|
User user = sender.GetUser();
|
||||||
Timer tradeTimer = new Timer(30000);
|
Timer tradeTimer = new Timer(30000);
|
||||||
TradeTimer[user.Id] = tradeTimer;
|
TradeTimer[user.Id] = tradeTimer;
|
||||||
tradeTimer.Start();
|
tradeTimer.Start();
|
||||||
tradeTimer.Elapsed += (s, e) => { SendBackToSender(sender); client.SetData("inTrade", false); sender.SetData("inTrade", false); client.SetSharedData("tradeOffer", 0); };
|
tradeTimer.Elapsed += (s, e) => { SendBackToSender(sender); client.SetData("inTrade", false); sender.SetData("inTrade", false); client.SetSharedData("tradeOffer", JsonConvert.SerializeObject(0)); };
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendBackToSender(Client client)
|
public void SendBackToSender(Client client)
|
||||||
@@ -632,7 +632,7 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
[RemoteEvent("declineTrade")]
|
[RemoteEvent("declineTrade")]
|
||||||
public void ServerEvent_declineTrade(Client client)
|
public void ServerEvent_declineTrade(Client client)
|
||||||
{
|
{
|
||||||
client.SetSharedData("tradeOffer", 0);
|
client.SetSharedData("tradeOffer", JsonConvert.SerializeObject(0));
|
||||||
if (!client.GetData("inTrade"))
|
if (!client.GetData("inTrade"))
|
||||||
{
|
{
|
||||||
ChatService.ErrorMessage(client, "Das Handelsangebot ist abgelaufen.");
|
ChatService.ErrorMessage(client, "Das Handelsangebot ist abgelaufen.");
|
||||||
@@ -670,7 +670,7 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
ChatService.ErrorMessage(client, "Das Handelsangebot ist abgelaufen.");
|
ChatService.ErrorMessage(client, "Das Handelsangebot ist abgelaufen.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client.SetSharedData("tradeOffer", 0);
|
client.SetSharedData("tradeOffer", JsonConvert.SerializeObject(0));
|
||||||
client.SetData("inTrade", false);
|
client.SetData("inTrade", false);
|
||||||
|
|
||||||
User user = client.GetUser();
|
User user = client.GetUser();
|
||||||
|
|||||||
Reference in New Issue
Block a user