include library.utils; include library.sui; include library.money; include library.space_utils; const string SPACE_MINING = "space_mining"; int getPricePerUnit(obj_id station, string resourceClassName) { string priceList = getStringObjVar(station, "space_mining.priceList"); string datatable = ""; if (priceList != "") { datatable = "datatables/space_mining/station_price_list/"+priceList+"_price_list.iff"; } else { return 0; } return dataTableGetInt(datatable, resourceClassName, "price_per_unit"); } trigger OnSpaceMiningSellResource(obj_id player, obj_id ship, obj_id station, obj_id resourceId, int amount) { if (getOwner(ship) != player) return SCRIPT_CONTINUE; if (getShipCargoHoldContent(ship, resourceId) >= amount && amount > 0) { string resourceClassName = getResourceClass(resourceId); int pricePerUnit = getPricePerUnit(self, resourceClassName); if (pricePerUnit > 0) { modifyShipCargoHoldContent(ship, resourceId, -amount); int cashForPlayer = pricePerUnit * amount; money.bankTo("space_resource_sale", player, cashForPlayer); space_utils.sendSystemMessageShip(ship, new string_id("space_mining", "sold"), true, true, true, true); } return SCRIPT_CONTINUE; } else { return SCRIPT_CONTINUE; } }