A ringing phone script that JUST WILL NOT WORK

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)

A ringing phone script that JUST WILL NOT WORK

Postby AshHouswares » Mon Jun 13, 2022 11:48 am

I've spent far too long on this nonsense now. I've wasted days of my life with this and the wiki has proven no help whatsoever.

The attached picture is of a script I wrote up to make a telephone ring when the player walks across a Linedef. No matter what I do it just WILL NOT WORK. It us supposed to loop until the player goes over to activate it which a privates another script to play the phone call.

The phone doesn't ring. AT ALL. I've messed with the code changed thing hundreds of times. It just isnt working. What the hell is wrong with this stupid thing???
You do not have the required permissions to view the files attached to this post.
User avatar
AshHouswares
Online Requirements can Go To Hell
 
Joined: 03 Jun 2022
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Not Listed

Re: A ringing phone script that JUST WILL NOT WORK

Postby Dan_The_Noob » Mon Jun 13, 2022 12:16 pm

firstly, you can copy and paste the code between [ code] [ /code] markers (minus the spaces) to make it so people can see your full code in the right format.
also, not sure if you can use "/" in sound names or not, but that seems like it would look for the sound elsewhere rather than playing that sound? unless that has worked for you elsewhere.
--EDIT--
oh sorry ignore that other bit, i jus checked my files and that is how it works.
User avatar
Dan_The_Noob
 
Joined: 07 May 2019
Twitch ID: Dan_The_Noob
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support

Re: A ringing phone script that JUST WILL NOT WORK

Postby Jarewill » Mon Jun 13, 2022 12:52 pm

The only potential issue I can see is that you set the last argument of PlaySound (local) to true:
Wiki wrote:local: If true, the sound is played if the player is either looking out the eyes of the actor from which the sound is coming, or said actor is the player and the player is looking out the eyes of a non-monster actor. Also, the sound is played with ATTN_NONE. Default is false.

Try changing it to false, but if that doesn't help then you might need to upload an example here so we can take a look at it.
Jarewill
 
Joined: 21 Jul 2019

Re: A ringing phone script that JUST WILL NOT WORK

Postby AshHouswares » Mon Jun 13, 2022 1:19 pm

That actually fixed it. The sound plays sound. Thank you man much appreciated. Only issue I have now though is that the phone doesnt stop ringing when the player goes over to it to a private its next script. Is there a line of code I could throw in to tell it stop ringing when the player answers the call ? Also maybe a code to make it stop ringing after a couple minutes (meaning the player can potentially miss the phone call).?
User avatar
AshHouswares
Online Requirements can Go To Hell
 
Joined: 03 Jun 2022
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Not Listed

Re: A ringing phone script that JUST WILL NOT WORK

Postby Jarewill » Mon Jun 13, 2022 1:32 pm

There's StopSound you can use to stop the ringing.
As for making it stop after a couple of minutes, you would have to set up a timer using Delay in your script.
Jarewill
 
Joined: 21 Jul 2019

Re: A ringing phone script that JUST WILL NOT WORK

Postby AshHouswares » Mon Jun 13, 2022 7:18 pm

Jarewill wrote:There's StopSound you can use to stop the ringing.
As for making it stop after a couple of minutes, you would have to set up a timer using Delay in your script.


So in this following code:
Code: Select allExpand view
{
PlaySound (207,  "phone/ring", CHAN_BODY, 1.0, true, ATTN_NORM, FALSE);
}


What would you reccomend I change. Something like

Code: Select allExpand view
{
PlaySound (207,  "phone/ring", CHAN_BODY, 1.0, true, ATTN_NORM, FALSE);
Delay (1000);
StopSound (207, "phone/ring");
}



Wouldnt this keep the script running though? Can I not make the phone ring stop AND make the script stop too so the player 'missed' the call? Otherwise what would prevent them from picking up and receiving the call when the phone has stopped ringing?
User avatar
AshHouswares
Online Requirements can Go To Hell
 
Joined: 03 Jun 2022
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Not Listed

Re: A ringing phone script that JUST WILL NOT WORK

Postby Jarewill » Tue Jun 14, 2022 9:05 am

StopSound takes a channel, not a sound, so you would have to use it like this:
Code: Select allExpand view
StopSound (207, CHAN_BODY); 

And yes, Delay will keep the script running as long as specified, but once it's done then the script executes the remaining functions and ends.
Frankly I have no idea how you even work the scripts, so I can't tell if putting Delay there would break it or not.
Posting an example file would be helpful to see.

Also Delay works in tics, so putting '1000' into it will result in the delay lasting about half a minute.
You can use math functions to multiply seconds by tics to get the desired result:
Code: Select allExpand view
Delay (30 * 35); //This will result in 30 seconds of delaying.   
Jarewill
 
Joined: 21 Jul 2019

Re: A ringing phone script that JUST WILL NOT WORK

Postby AshHouswares » Sat Jun 18, 2022 2:55 pm

Code: Select allExpand view

//TELEPHONE rings.
script 117 (void)
{
      PlaySound (225, "phone/ring", CHAN_BODY, 1.0, true, ATTN_NORM, FALSE);
      delay (30 * 35); //30 SECONDS until the phone stops ringing.
      StopSound (255, CHAN_BODY); // why is this sound not stopping!?!?
      
}

//Telephone with one time message.
bool phonescript3 = false;
script 118 (void)
{
  if (!phonescript3)  {
      SetPlayerProperty (0, 1, PROP_TOTALLYFROZEN);
      StopSound (225, CHAN_BODY);
      delay (20);
       AmbientSound("Voice/Telephone03", 300);
      delay (700);
      AmbientSound("Phone/Dead", 150);
      delay(10);
      SetPlayerProperty (0, 0, PROP_TOTALLYFROZEN);

            phonescript3 = true;
   } else
       ambientsound ("Phone/Dead", 150);
      SetHudSize(600,400,TRUE);
       HudMessageBold(s:"The phone-line is dead."; HUDMSG_FADEOUT, 500, CR_GOLD, 300.0, 100.0, 8.0, 0.3);
      delay (100);
}

//Need to fix this script. The message can still be received by activating the message script linedef (script activate when player presses use 118) before the phone even begins to ring. Also, script 177 (linedef script activate when player walks over) does not stop ringing. Biggest issue here is we need to make the phone stop ringing (117), PLUS take away the ability to recieve the phone message in the following script (118). Currently, even if the phone WAS to stop ringing, the player could still activate the phone on script 118 and receive the call.


Ok heres a copy paste from my ipk3. The issue is I need to make the script to answer the call become null and void if the player 1. Misses the call and 2. Does not allow the answer call script to activate if the phone has tried to answer the call before the previous script to make the phone ring has been activated. Does this make sense?
User avatar
AshHouswares
Online Requirements can Go To Hell
 
Joined: 03 Jun 2022
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Not Listed

Re: A ringing phone script that JUST WILL NOT WORK

Postby Jarewill » Sun Jun 19, 2022 9:32 am

Untested code, but you could try this:
Spoiler:

If this doesn't work, then please upload an example map so I can actually test the scripts inside it.
As for the sound not stopping, frankly I've got no idea, I'd have to check inside the map.
Jarewill
 
Joined: 21 Jul 2019

Re: A ringing phone script that JUST WILL NOT WORK

Postby AshHouswares » Tue Jun 28, 2022 7:10 pm

Jarewill wrote:Untested code, but you could try this:
Spoiler:

If this doesn't work, then please upload an example map so I can actually test the scripts inside it.
As for the sound not stopping, frankly I've got no idea, I'd have to check inside the map.

I'll be trying this out tomorrow and I'll let you know how it goes. Looks like a good piece of work, here's hoping fingers crossed this does the trick. Thank you.
User avatar
AshHouswares
Online Requirements can Go To Hell
 
Joined: 03 Jun 2022
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Not Listed


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests