Timers don't work?

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
Galbuu
UOX3 Neophyte
Posts: 45
Joined: Mon Jul 05, 2004 9:20 am
Location: Orlando, FL
Has thanked: 0
Been thanked: 0
Contact:

Timers don't work?

Post by Galbuu »

Code: Select all

function onUse(pUser, iUsed)
{
	if(pUser.GetTag("roids") == null)
	{
	pUser.SetTag("roids", 0);
	}

	if(pUser.GetTag("roids") == 0)
	{
	pUser.SetTag("roids", 1);
	pUser.SysMessage("You are now under the effects of dwarf grass.");
	pUser.strength += 20;
	pUser.StartTimer(600, 0, true);
	}

	if(pUser.GetTag("roids") == 1)
	{
	pUser.SysMessage("You are already under the effects of dwarf grass.");
	}
}

function onTimer(pUser,timerID)
{
	if(timerID == 0)
	{
	pUser.SysMessage("The dwarf grass's bad effects kick in.");
	pUser.strength -= 40;
	pUser.StartTimer(600, 1, true);
	}

	if(timerID == 1)
	{
	pUser.SysMessage("The dwarf grass's effects wear off.");
	pUser.strength += 20;
	pUser.SetTag("roids", 0);
	}
}
This is just one of the scripts I've written that the timers don't work in. Are timers bugged or something? Am I setting them up wrong?
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Won't make the timers work any better, but... instead of it this:

Code: Select all

   if(pUser.GetTag("roids") == null) 
   { 
   pUser.SetTag("roids", 0); 
   } 

   if(pUser.GetTag("roids") == 0) 
   {
...try this...

Code: Select all

   if(pUser.GetTag("roids") == null || pUser.GetTag("roids") == 0) 
   {
That saves you one IF and one SETTAG. :P
-= Ho Eyo He Hum =-
Eolirin
Has thanked: 0
Been thanked: 0

Post by Eolirin »

Timers don't seem to be working for me either.
Post Reply