2020-10-13 01:26:16 +00:00
|
|
|
Scriptname BRMerchChestScript extends ObjectReference
|
|
|
|
|
2020-11-02 06:39:45 +00:00
|
|
|
Keyword property BRLinkMerchShelf auto
|
|
|
|
Keyword property BRLinkMerchChest auto
|
|
|
|
Keyword property BRLinkItemRef auto
|
|
|
|
Keyword property BRLinkActivatorRef auto
|
|
|
|
Keyword property BRLinkMerchToggle auto
|
|
|
|
Keyword property BRLinkMerchNext auto
|
|
|
|
Keyword property BRLinkMerchPrev auto
|
|
|
|
Activator property ActivatorStatic auto
|
2020-10-13 01:26:16 +00:00
|
|
|
Actor Property PlayerRef Auto
|
|
|
|
Quest Property BRQuest Auto
|
|
|
|
|
|
|
|
event OnMenuClose(string menuName)
|
|
|
|
if menuName == "ContainerMenu"
|
2020-10-16 03:42:57 +00:00
|
|
|
Debug.Trace("BRMerchChestScript container menu closed")
|
2020-10-13 01:26:16 +00:00
|
|
|
BRQuestScript BRScript = BRQuest as BRQuestScript
|
2020-10-16 03:42:57 +00:00
|
|
|
bool result = BRMerchandiseList.Create(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ShopId, self)
|
|
|
|
if !result
|
2020-10-19 00:56:10 +00:00
|
|
|
Debug.MessageBox("Failed to save shop merchandise.\n\n" + BRScript.BugReportCopy)
|
2020-10-13 01:26:16 +00:00
|
|
|
endif
|
|
|
|
UnregisterForMenu("ContainerMenu")
|
|
|
|
endif
|
|
|
|
endEvent
|
|
|
|
|
|
|
|
event OnActivate(ObjectReference akActionRef)
|
|
|
|
if akActionRef == PlayerRef
|
2020-10-16 03:42:57 +00:00
|
|
|
Debug.Trace("BRMerchChestScript container was opened")
|
2020-10-13 01:26:16 +00:00
|
|
|
RegisterForMenu("ContainerMenu")
|
|
|
|
endif
|
2020-10-16 03:42:57 +00:00
|
|
|
endEvent
|
|
|
|
|
2020-10-19 00:56:10 +00:00
|
|
|
event OnCreateMerchandiseSuccess(bool created, int id)
|
|
|
|
Debug.Trace("BRMerchChestScript OnCreateMerchandiseSuccess created: " + created + " id: " + id)
|
|
|
|
if created
|
2020-10-16 03:42:57 +00:00
|
|
|
BRQuestScript BRScript = BRQuest as BRQuestScript
|
2020-10-19 00:56:10 +00:00
|
|
|
BRScript.MerchandiseListId = id;
|
2020-10-16 03:42:57 +00:00
|
|
|
Debug.Notification("Saved merchandise successfully")
|
2020-11-02 06:39:45 +00:00
|
|
|
|
|
|
|
ObjectReference merchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
|
|
|
if !BRMerchandiseList.Refresh(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, merchantShelf, ActivatorStatic, BRLinkMerchShelf, BRLinkMerchChest, BRLinkItemRef, BRLinkActivatorRef, BRLinkMerchToggle, BRLinkMerchNext, BRLinkMerchPrev)
|
|
|
|
Debug.MessageBox("Failed refresh merchandise.\n\n" + BRScript.BugReportCopy)
|
|
|
|
endif
|
2020-10-19 00:56:10 +00:00
|
|
|
else
|
|
|
|
Debug.Trace("BRMerchChestScript no container changes to save to the server")
|
2020-10-16 03:42:57 +00:00
|
|
|
endif
|
2020-10-19 00:56:10 +00:00
|
|
|
endEvent
|
|
|
|
|
|
|
|
event OnCreateMerchandiseFail(string error)
|
|
|
|
Debug.Trace("BRMerchChestScript OnCreateMerchandiseFail error: " + error)
|
|
|
|
BRQuestScript BRScript = BRQuest as BRQuestScript
|
|
|
|
Debug.MessageBox("Failed to save shop merchandise.\n\n" + error + "\n\n" + BRScript.BugReportCopy)
|
2020-10-13 01:26:16 +00:00
|
|
|
endEvent
|