Jump to content
  • 0
Sign in to follow this  
evilpuncker

addtimer issues

Question

I tried creating a command that will execute different actions on different intervals, and using the command will turn them ON/OFF, but it is just not working, what am I doing wrong?

 

-	script	test	FAKE_NPC,{
OnInit:
	bindatcmd("test", strnpcinfo(NPC_NAME)+"::OnAtcommand", 0, 99);
	end;

OnAtcommand:
	atcommand("@test"); // executes the "test" command ON/OFF
	if (.@on == 1) {
		.@on = 0;
		deltimer(strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent1");
		deltimer(strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent2");
		deltimer(strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent3");
		end;
	} else {
		.@on = 1;
		// 1000 = 1 second | 60000 = 1 min | 3600000 = 1 hour
		addtimer(10000, strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent1");
		addtimer(5000, strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent2");
		addtimer(300, strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent3");
		end;
	}
	end;

OnEvent1:
	if (.@on == 0) {
		deltimer(strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent1");
		end;
	}
	// do something X
	addtimer(10000, strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent1");
	end;

OnEvent2:
	if (.@on == 0) {
		deltimer(strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent2");
		end;
	}
	// do something Y
	addtimer(5000, strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent2");
	end;

OnEvent3:
	if (.@on == 0) {
		deltimer(strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent3");
		end;
	}
	// do something Z
	addtimer(300, strnpcinfo(NPC_NAME_UNIQUE)+"::OnEvent3");
	end;
}

 

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.