Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting an on/off radio
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#11
RE: Scripting an on/off radio

(05-04-2013, 08:36 PM)Mr Credits Wrote: Wouldn't it also be necessary to increment/decrement the Radio variable in the case that the radio sound was to be toggled? Unless I had misinterpreted and this is not what the OP specified.

Yyy, you're right Big Grin
In the case of the code above, it would be:

PHP Code: (Select All)
if(GetLocalVarInt("Radio") == 0)   // 0 means "currently off" - so turn it on
{
    
PlaySoundAtEntity("id.sound.radio""radio.snt""radioarea"0.0false);  // 0.0 - fade in time
    
SetLocalVarInt("Radio"1);   // set it to "currently on"

else  
// local var "Radio" is 1, that is: "currently on" - so turn it off
{
    
StopSound("id.sound.radio"0.5f); //Change 0.5f to how long you want the sound to fade out.
    
SetLocalVarInt("Radio"0);   // set it to "currently off"


Also, the way the code is setup, it should start with:
PHP Code: (Select All)
void OnStart()
{
    
SetLocalVarInt("Radio"0);   // 0 instead of 1
    // etc... 
(This post was last modified: 05-04-2013, 10:13 PM by TheGreatCthulhu.)
05-04-2013, 10:11 PM
Find


Messages In This Thread
Scripting an on/off radio - by Kalidus - 05-03-2013, 05:48 PM
RE: Scripting an on/off radio - by Tomato Cat - 05-03-2013, 06:45 PM
RE: Scripting an on/off radio - by Kalidus - 05-04-2013, 07:13 PM
RE: Scripting an on/off radio - by Daemian - 05-04-2013, 10:44 AM
RE: Scripting an on/off radio - by Daemian - 05-04-2013, 10:56 PM
RE: Scripting an on/off radio - by Tomato Cat - 05-04-2013, 07:20 PM
RE: Scripting an on/off radio - by Tomato Cat - 05-04-2013, 08:36 PM
RE: Scripting an on/off radio - by TheGreatCthulhu - 05-04-2013, 10:11 PM
RE: Scripting an on/off radio - by Kalidus - 05-04-2013, 10:57 PM
RE: Scripting an on/off radio - by Daemian - 05-05-2013, 05:10 AM



Users browsing this thread: 1 Guest(s)