Author Topic: Elevator script not working with delay, please assist.  (Read 357 times)

Legacy_GIANTSWORD

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Elevator script not working with delay, please assist.
« on: September 01, 2014, 07:50:09 am »


               

Hey guys,


 


Having a hell of a time getting a script to work..  I can get the delays for the speak line and sound files to work right but when it comes to delaying the teleport to the top of the elevator it NEVER works when I try to delay it.  I've tried using jump to object and teleport and neither work with a delay.  It will always teleport if I have no delay but then I miss out on the sound file and text appearing.


 


Here is what I'm working with.  


 


 

//Put this script OnUsed

void main()

{

 

object oPC = GetLastUsedBy();

 

if (!GetIsPC(oPC)) return;

 

object oTarget;

oTarget = GetObjectByTag("me_sound_elevator");

 

DelayCommand(1.0, SoundObjectPlay(oTarget));

 

DelayCommand(1.0, SendMessageToPC(oPC, "**The rusty gears scream in protest as the elevator ascends.**"));

 

location lTarget;

oTarget = GetWaypointByTag("me_wp_elevatorup001");

 

lTarget = GetLocation(oTarget);

 

//only do the jump if the location is valid.

//though not flawless, we just check if it is in a valid area.

//the script will stop if the location isn't valid - meaning that

//nothing put after the teleport will fire either.

//the current location won't be stored, either

 

if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;

 

DelayCommand(4.0, AssignCommand(oPC, ClearAllActions()));

 

DelayCommand(4.0, AssignCommand(oPC, ActionJumpToLocation(lTarget)));

 

}


               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
Elevator script not working with delay, please assist.
« Reply #1 on: September 01, 2014, 02:52:24 pm »


               Some things I would try,
I rarely check to see if PC is oPC, if there is no chance for another to use the object.
If I have not assigned any previous commands to the PC, I don't clear his actions.
I try not to give 2 objects the same identifier (oTarget) I would try changing one of those (oSound).

I still consider myself a noob, so if any of this helps, your welcome. If not, I'll fut the shuck up.

Ed
               
               

               
            

Legacy_GIANTSWORD

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Elevator script not working with delay, please assist.
« Reply #2 on: September 01, 2014, 05:44:35 pm »


               

I ended up getting it to work with a wait and jump to object instead of delay and teleport.  go figure..


 


Now i'm having issues hearing the soundfile I put in place.  It's extremely faint even though I have it turned up all the way.  Maybe headphone settings or something?  


 


Thanks for the input Ed!



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Elevator script not working with delay, please assist.
« Reply #3 on: September 01, 2014, 11:39:05 pm »


               With DelayCommand, if you have multiple commands at the same time, it does them in reverse order. So, at 4.0 seconds, it queues the elevator action, then clears all actions, so nothing happens.


Try using a unique delay, so that commands happen in the right order, e.g. 4.0, 4.0001 or whatever.


Although ActionWait is probably a better solution, as you discovered.


With the sound, assuming your game settings are OK, it's probably a matter of tweaking the sound object properties e.g. play everywhere in area / increase radius (or moving the sound closer to the PC).
               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Elevator script not working with delay, please assist.
« Reply #4 on: September 02, 2014, 12:54:27 am »


               

I usually just choose the PC themselves to play most sounds to ensure they are heard.



               
               

               
            

Legacy_GIANTSWORD

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Elevator script not working with delay, please assist.
« Reply #5 on: September 02, 2014, 10:48:59 pm »


               

Thanks for all the help guys



               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Elevator script not working with delay, please assist.
« Reply #6 on: September 03, 2014, 01:02:16 am »


               

If you assign the sound to play on the PC themselves, it helps to clear their action que just beforehand. Even then, players that -click- alot or use their keyboard walk commands to -fidget- can override the new action at times.