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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

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