A little help needed

I’m trying to make a mod, but I can’t seem to get it to add to the drop-down menu (context menu). Beneath is some of my code which seems flawless to me after I compared it to other mods.

 var OriginalContextMenu = UI.showContextMenu;
    	var NewContextMenu = function (b, c, d, h) {
    		c.push({
    			label: "National Stock Exchange...",
    			action: function () {
    				Sound.click();
    				GameManager.resume(true);
    				var div = $("#NatStockEx");
    				div.scrollTop()
    				div.gdDialog({
    					popout: !0,
    					close: !0
    				})
    			}
    			//var shareValue = GameManager.company.cash / 500000000 * 20;
    			var maxValue = math.floor(GameManager.company.cash / (GameManager.company.cash / 500000000 * 20)); // line 107
    			div.find(".SAS").slider({
    				min: 1,
    				max: maxValue,
    				range: "min",
    				value: Math.floor(shareAmount),
    				animate: !1,
    				slide: function (a, b) {
    					var c = b.value;
    					totalShares(c);
    				}
    			});
    		});
    		totalShares(shareAmount);
    		OriginalContextMenu(b, c, d, h);
    	};
    	UI.showContextMenu = NewContextMenu;

I’ve tried debugging it with the webkit devtools and it tells me that on line 107 ‘=’ is an unexpected symbol, which seems odd to me and I can’t figure out what’s wrong. Has anyone got an idea as to what’s wrong?

eh
try Math.floor instead of math.floor

2 Likes

Didn’t do anything unfortunately. It still says the same error

Try this:

var OriginalContextMenu = UI.showContextMenu;
    	var NewContextMenu = function (b, c, d, h) {
    		c.push({
    			label: "National Stock Exchange...",
    			action: function () {
    				Sound.click();
    				GameManager.resume(true);
    				var div = $("#NatStockEx");
    				div.scrollTop()
    				div.gdDialog({
    					popout: !0,
    					close: !0
    				})
    			
    			//var shareValue = GameManager.company.cash / 500000000 * 20;
    			var maxValue = math.floor(GameManager.company.cash / (GameManager.company.cash / 500000000 * 20)); // line 107
    			div.find(".SAS").slider({
    				min: 1,
    				max: maxValue,
    				range: "min",
    				value: Math.floor(shareAmount),
    				animate: !1,
    				slide: function (a, b) {
    					var c = b.value;
    					totalShares(c);
    				}
    			});
				}//change the position inside the action funtion
    		});
    		totalShares(shareAmount);
    		OriginalContextMenu(b, c, d, h);
    	};
    	UI.showContextMenu = NewContextMenu;

Or this:

 var OriginalContextMenu = UI.showContextMenu;
    	var NewContextMenu = function (b, c, d, h) {
    		c.push({
    			label: "National Stock Exchange...",
    			action: function () {
    				Sound.click();
    				GameManager.resume(true);
    				var div = $("#NatStockEx");
    				div.scrollTop()
    				div.gdDialog({
    					popout: !0,
    					close: !0
    				})
    			
    			//var shareValue = GameManager.company.cash / 500000000 * 20;
				}
    		});
			//or everything outside the push function
			var maxValue = math.floor(GameManager.company.cash / (GameManager.company.cash / 500000000 * 20)); // line 107
    			div.find(".SAS").slider({
    				min: 1,
    				max: maxValue,
    				range: "min",
    				value: Math.floor(shareAmount),
    				animate: !1,
    				slide: function (a, b) {
    					var c = b.value;
    					totalShares(c);
    				}
    			});
    		totalShares(shareAmount);
    		OriginalContextMenu(b, c, d, h);
    	};
    	UI.showContextMenu = NewContextMenu;

Well I should be able to help sinds you litterally stole it from cheatmod :smiley: :stuck_out_tongue:

var OriginalContextMenu = UI.showContextMenu;
    var NewContextMenu = function (b, c, d, h) {
    c.push({
        label: "National Stock Exchange...",
        action: function () {
             Sound.click();
             GameManager.resume(true);
             var div = $("#NatStockEx");
             div.scrollTop()
             div.gdDialog({
                 popout: !0,
                 close: !0
             })
        }
    });
 //var shareValue = GameManager.company.cash / 500000000 * 20;
 var maxValue = Math.floor(GameManager.company.cash / (GameManager.company.cash / 500000000 * 20)); // line 107
 div.find(".SAS").slider({
min: 1,
max: maxValue,
 range: "min",
value: Math.floor(shareAmount),
animate: !1,
slide: function (a, b) {
var c = b.value;
totalShares(c);
}
});
totalShares(shareAmount);
     OriginalContextMenu(b, c, d, h);
 };
UI.showContextMenu = NewContextMenu;
2 Likes

Well that definitely did something, because I’m now getting a new error which I’m guessing is related my divs, which I’ll probably be able to sort out. Thanks though! :smile:

And just for the record, I admit to comparing your code to mine to see where I went wrong and tried to adjust things to fix it, but I did not flat-out copy/paste it.

EDIT: Can’t seem to figure out whether the error is related to the divs itself or the attributes :confused: Has anyone experienced this before and know what’s up? I’ve put everything on pastebin so that you can actually provide help.