Aller au contenu

Photo

Elevator script not working with delay, please assist.


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
GIANTSWORD

GIANTSWORD
  • Members
  • 88 messages

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)));
 
}


#2
Ed Venture

Ed Venture
  • Members
  • 102 messages
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
  • Shadooow aime ceci

#3
GIANTSWORD

GIANTSWORD
  • Members
  • 88 messages

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!



#4
Proleric

Proleric
  • Members
  • 2 361 messages
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).

#5
kalbaern

kalbaern
  • Members
  • 824 messages

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


  • Proleric aime ceci

#6
GIANTSWORD

GIANTSWORD
  • Members
  • 88 messages

Thanks for all the help guys



#7
kalbaern

kalbaern
  • Members
  • 824 messages

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.