Author Topic: Count Down, in Sec, Floating Text Count Down PC Head  (Read 320 times)

Legacy_NullthraB

  • Jr. Member
  • **
  • Posts: 66
  • Karma: +0/-0
Count Down, in Sec, Floating Text Count Down PC Head
« on: July 24, 2011, 02:25:35 pm »


               Hello,
I've got an idea that requires a count down script that displays the number count above the pc's head every second.  Then when the count down is finished the script checks for a local variable int +1 (name_int) and if the pc has it success would add an addtional local variable, if not they would fail the area puzzle and a floating text string would say "you fail to meet the requirements in time". I'd like the count down to start at 120 seconds and do its check when the count down reaches 0. 

Still in the idea stage on this one but am interested in knowing if a script like this could be fasioned. I'd be using a genaric trigger to begin the script as the OnAreaEvent will be used for something else.

Any suggestions to get me starting on this?

thank you,
NB
               
               

               
            

Legacy__six

  • Hero Member
  • *****
  • Posts: 1436
  • Karma: +0/-0
Count Down, in Sec, Floating Text Count Down PC Head
« Reply #1 on: July 24, 2011, 02:49:18 pm »


               Basic structure for you (hastily written in notepad, so I may have made a typo or two along the way).

void CountDown(float fTime, object oPC)
{
    FloatingTextStringOnCreature(FloatToString(fTime), oPC);

    // Is countdown complete?
    if(fTime <= 0.0f)
    {
        if( /* puzzle completed */ )
        {    // do something
        }
        else
        {    // do something else
        }   
    }

    // Otherwise continue countdown
    else
    {    fTime -= 1.0f;
         DelayCommand(1.0f, CountDown(fTime, oPC));   
    }
   }


void main()
{   
    object oPC = GetEnteringObject();
    if(!GetIsPC(oPC)) return;

    CountDown(120.0f, oPC);
}
               
               

               


                     Modifié par _six, 24 juillet 2011 - 01:52 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Count Down, in Sec, Floating Text Count Down PC Head
« Reply #2 on: July 24, 2011, 04:12:17 pm »


               Celowin - Part II: Local Variables  tutorial is centered around making a NPC count.