try fix Trade html window

This commit is contained in:
Lukas Moungos
2019-07-28 23:07:07 +02:00
parent 32b1e3d9eb
commit 4a98213965
2 changed files with 22 additions and 16 deletions

View File

@@ -3,24 +3,24 @@
export default function inventory(globalData: GlobalData): void {
var invBrowser: BrowserMp = null;
var handelBrowser: BrowserMp = null;
var itemIdArr;
var itemAmountArr;
var money;
mp.events.add("openTradeWindow", (money1, itemIdArr1, itemAmountArr1) => {
if (!globalData.InMenu) {
if (invBrowser !== null) {
if (handelBrowser !== null) {
try {
invBrowser.destroy()
invBrowser = null;
handelBrowser.destroy()
handelBrowser = 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");
handelBrowser = mp.browsers.new("package://assets/html/inventory/handel/handelakzeptieren.html");
itemIdArr = itemIdArr1;
itemAmountArr = itemAmountArr1;
@@ -54,21 +54,26 @@ export default function inventory(globalData: GlobalData): void {
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)}");`);
handelBrowser.execute(`setItems("${JSON.stringify(itemIdArr)}","${JSON.stringify(itemAmountArr)}","${JSON.stringify(money)}");`);
});
mp.events.add("CEF:acceptTrade", () => {
if (handelBrowser !== null) {
mp.events.callRemote('acceptTrade');
invBrowser.destroy()
invBrowser = null;
handelBrowser.destroy()
handelBrowser = null;
mp.gui.cursor.show(false, false);
}
});
mp.events.add("CEF:declineTrade", () => {
if (handelBrowser !== null) {
mp.events.callRemote('declineTrade');
invBrowser.destroy()
invBrowser = null;
handelBrowser.destroy()
handelBrowser = null;
mp.gui.cursor.show(false, false);
}
});
mp.events.add("CEF:UseItemInv", (itemId) => {

View File

@@ -97,6 +97,7 @@ namespace ReallifeGamemode.Server.Managers
TradeItems[user.Id] = (itemIdArr, itemAmountArr);
TradeValue[user.Id] = value;
target.SetData("tradePartner", user.Id);
target.SetData("trade", user.LogUserId);
SendTradeOffer(target,client);
}
@@ -151,8 +152,8 @@ namespace ReallifeGamemode.Server.Managers
[RemoteEvent("declineTrade")]
public void ServerEvent_declineTrade(Client client)
{
int id = client.GetData("tradePartner");
Client target = ClientService.GetClientByNameOrId(id.ToString());
int id = client.GetData("trade");
Client target = ClientService.GetClientByNameOrId(""+id);
if (target == null || !target.IsLoggedIn())
{
ChatService.PlayerNotFound(client);