Page 1 of 1

Calling Timer() problem

PostPosted: Tue Nov 09, 10 11:49 am
by Cozmo
This class is for custom teleporters that handle what goes on in jail. The other stuff outside of this class all works fine, and everything here does too, except the stuff in Timer(), oddly. None of it gets called.

Code: Select all
//=================================
// PoliceJailCell
//=================================
Class PoliceJailCell extends Teleporter;

Var PoliceCrimeMon PCMM;
Var Human Prisoner;
Var ReleasePlace RPLL;

function BeginPlay()
{
   local PoliceCrimeMon PCM;
   local ReleasePlace RPL;

   foreach AllActors(class'PoliceCrimeMon',PCM)
   {
      PCMM = PCM;
   }

   foreach AllActors(Class'ReleasePlace',RPL)
   {
      RPLL = RPL;
   }
}

simulated function bool Accept( actor Incoming, Actor Source )
{
   local int i;
   local int timein;
   local int timein2;
   local DeusExWeapon DEW;

   foreach AllActors(class'DeusExWeapon',DEW)
   {
      if(DEW.Owner == Human(Incoming))
      {
         if(DEW.IsA('CozCreditCard'))
         {
            //Cozmo: Don't destroy this. I think it's "if(!(stuff))" to do it properly but idk.
         }
         else
         {
            DEW.Destroy();
         }
      }
   }

   Super.Accept(Incoming, Source);

   if(Incoming.IsA('Human'))
   {
      for (i=1; i<20; i++)
      {
         if(Human(Incoming) == PCMM.Criminal[i])
         {
            timein = PCMM.CriminalLevel[i]*25;
            timein2 = timein / 60;

            Human(Incoming).Alliance = 'Player';

            Human(Incoming).ClientMessage("|p2When you were captured, you had a criminal level of "$PCMM.CriminalLevel[i]);
            Human(Incoming).ClientMessage("|p2This means your sentance is "$timein$" seconds long. ("$timein2$" minutes long.)");

            Prisoner = Human(Incoming);
            Prisoner.HealPlayer(50, true);

            PCMM.CriminalLevel[i] = 0;
            PCMM.Criminal[i] = None;

            SetTimer(float(timein), false);
         }
      }
   }
}

function Timer()
{
   Prisoner.SetLocation(RPLL.Location);
   Prisoner.ClientMessage("|P2We will be keeping any weapons you had when you were arrested.");
   Prisoner.ClientMessage("|P2You have been released from jail. For now.");

   Prisoner = None;
}

defaultproperties
{
}


Not sure why it's not working. I suspect it's a problem with "SetTimer(float(timein), false)" though. Tried it with the variable still as an int but I get the same result. Am I just doing something silly like converting it to float wrong?

PostPosted: Tue Nov 09, 10 12:16 pm
by ~ô¿ô~Nobody~
If the conversion of the value to float results into zero, then timer is not called.
Also.. I'm not sure if you're doing it but you cannot call a chain of timers.. a new call of setTimer overrides the last call before the actual timer function gets executed.

PostPosted: Tue Nov 09, 10 12:48 pm
by Cozmo
Only calling Timer once for the duration of stay in jail, but good point on 0 value. So I'm probably converting it wrong or can't call it like this?

PostPosted: Tue Nov 09, 10 1:04 pm
by ~ô¿ô~Nobody~
I would add log debug messages in the function accept and the timer function.. to see how far it executes..

If the timer function simply doesn't get called, you should check if it was disabled..
you can enable and disable probe functions like timer with enable('timer') or disable('timer)

PostPosted: Tue Nov 09, 10 1:48 pm
by Cozmo
From log debug, yeah, everything seems to be working except Timer(). Added enable('timer') just before SetTimer() but same results. Gotta go out now but will look at parent classes and stuff when I get back. Might have to do something silly and awkward like use Timer() of an external class. Thanks for the replies. :)

PostPosted: Tue Nov 09, 10 5:50 pm
by Cozmo
I gave up and just made it extend another class and added the SetLocation stuff. It works properly now. :D