[ques] Some assistance please with problem?

Heres the piece of code it has a problem with


ECM.addEventNetAttack = function(){
var eventId = “NetAttack”;

	var NetAttack = {
		id: eventId,
		isRandom: true,
		maxTriggers: 1,
		trigger: function (company){
			return company.currentLevel == 2 && compamy.fans >= 25000; /* company.cash >= 75000 */
		};
		getNotification: function (company){
			var game = company.currentGame;
			
			var msg= "An Unknown Device is trying to access your network system. {n} You can either Block the Connection or Allow the Connection.".localize().format(game.title);
			return new Notification({
				sourceId: eventId,
				header: "What do you want to do?".localize(),
				text: msg,
				options: ["Block Connection", "Allow Connection"]
			});
		},

Can anyone care to explain what the problem is?

its complaining about the part where it says: getNotification: function (company){

Error = Uncaught SyntaxError: Unexpected token : mods/ECM/source:56

missing comma before getNotification (

trigger: function (company){
		return company.currentLevel == 2 && compamy.fans >= 25000; /* company.cash >= 75000 */
	};   <-------- this one

k thnx I would have never have seen that

is it possible to have a event in a event?

Take a look at the API wiki https://github.com/greenheartgames/gdt-modAPI/wiki/GDT.addEvent

I think you might be able to create a new event inside the “complete” callback:

complete: function (decision) {
        // decision is a number and will correspond to the index of the option that was chosen.
        // 0=option1, 1=option2, 2=option3
        // it's best if every decision has a different outcome

        var company = GameManager.company ;//we fetch the company object for use later.
       
       // Create your new event or whatever here.
      return;

 }

Alphabit this is how mine is set out:


complete: function (dicision){
var company = GameManager.company;

			if (discision === 0){
				var n = new Notification({
					header: "Block Connection".localize(),
					text: ""
				});
				
				company.activeNotification.addRange(n.split());
				return;
			}
			if (discision === 1){
				var n = new Notification({
					header: "Allow Connection".localize(),
					text: "",
					options: ["Turn Off Power", "Phone Bank", "Phone Police"]
				});
			}
			complete: function (discision){
				var company = GameManager.company;
				
				if (discision === 0){
					var n = new notification({
						header: "Turn Off Power".localize(),
						text: ""
					});
				}
				if (discision === 1){
					var n = new Notification({
						header: "Phone Bank".localize(),
						text: ""
					});
				n.adjustCash(-30217, "Cash Stolen");
				}
				if (discision === 2){
					var n = new Notification({
						header: "Phone Police".localize(),
						text: "",
					});
				n.adjustCash(50000);
				} 
			}
		}
	};
	GDT.addEvent(NetAttack);
};

im pretty sure this is the way you described it @alphabit

1 Like

good one

Except that

is not discision

and maybe you should name it “decision”.

And that you might want to add the event IN the complete function, before any decision is taken:

complete: function (decision){
        var company = GameManager.company;

        GDT.addEvent(NetAttack);
        ...

or after a certain decision has been taken

        if (decision=== 1){
            var n = new Notification({
                header: "Phone Bank".localize(),
                text: ""
            });
            n.adjustCash(-30217, "Cash Stolen");

            GDT.addEvent(NetAttack);
        }

Or at the end, if you want to use it when no decision has been taken.

1 Like

thnx again alphabit you are very helpful, if there were a recommendation option for moderator im pretty sure everyone would choose you.

That made me laugh :smile:

1 Like