NoTrade Removable Fix

This commit is contained in:
RezecNoble
2024-08-29 19:55:13 -04:00
parent a1b412e08f
commit 6a67803887
2 changed files with 10 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ public class no_trade_removable extends script.base_script {
public static final string_id SID_ITEM_MADE_TRADABLE = new string_id("system_msg", "item_made_tradable");
public static final String SCRIPT_NAME = "item.special.no_trade_removable";
public static final String NO_TRADE_SCRIPT_NAME = "item.special.nomove";
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException {
if ((getOwner(self) == player || isGod(player)) && hasObjVar(self, "noTrade")
@@ -48,6 +49,9 @@ public class no_trade_removable extends script.base_script {
if (hasObjVar(self, "noTrade")) {
removeObjVar(self, "noTrade");
if (hasScript(self, NO_TRADE_SCRIPT_NAME)) {
detachScript(self, NO_TRADE_SCRIPT_NAME);
}
sendSystemMessage(player, SID_ITEM_MADE_TRADABLE);
CustomerServiceLog("noTrade", getPlayerName(player) + " (" + player + ") removed the noTrade ObjVar from object " + getTemplateName(self) + " (" + self + ")");
detachScript(self, SCRIPT_NAME);

View File

@@ -152,6 +152,12 @@ public class static_item extends script.base_script
}
}
attachScript(object, "item.static_item_base");
// attaching the no_trade_removable script.
// Doing this here instead of the above because this runs on Init for all existing static_items instead of only at creation time
String[] no_trade_removable_items = dataTableGetStringColumn(ITEM_NO_TRADE_REMOVABLE_TABLE, 0);
if(no_trade_removable_items != null && Arrays.asList(no_trade_removable_items).contains(itemName)) {
attachScript(object, "item.special.no_trade_removable");
}
if (!jedi.isCrystalTuned(object))
{
setName(object, "");