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
Random sound at random time script help
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: Random sound at random time script help

You have Addtimer in a lot of places where AddTimer should be.

Here's a more efficient way of doing what you want, though (code not tested):

PHP Code: (Select All)
const string[] sounds_to_play = {
    
"walkandgrunt.snt",
    
"walkandgrunt.snt",
    
"walkandgrunt.snt",
    
"walkandgrunt.snt",
    
"walkandgrunt.snt"
};

void OnStart()
{
    
DoorCheck("GlobalCheck");
    
Addtimer("RandomSound"1.0f"SoundTime");
}

void SoundTime(string &in asTimer)
{
    
int Time RandInt(0sounds_to_play.length()-1);
    
PlaySoundAtEntity(""sounds_to_play[Time], "Player" 0false);
    
    
// Make sure the minimum range is greater than 0
    //    However, it may be more practical to have a number greater than 10
    
AddTimer(asTimerRandFloat(1,60), "SoundTime");
}

void DoorCheck(string &in asTimer)
{
    if(
GetGlobalVarInt("Globalvar1") == 1)
    {
        
SetSwingDoorLocked("elevator_door_1"falsefalse);
        return;
    }

    
// Never use 0 for time
    
AddTimer(asTimer0.02f"DoorCheck");


Tutorials: From Noob to Pro
(This post was last modified: 12-06-2011, 10:03 AM by Your Computer.)
12-06-2011, 08:27 AM
Website Find


Messages In This Thread
RE: Random sound at random time script help - by Your Computer - 12-06-2011, 08:27 AM



Users browsing this thread: 3 Guest(s)