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
Script Help Assist me while I learn to script
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#10
RE: Assist me while I learn to script

Final product:
A sound (GUI, that means it's not in 3D) plays Every 30 seconds or so... until the Player collides with an area.

What you will need:
  • Level Editor
    • Area in the map (remember the name! For this tutorial, it's "stopSoundArea")
    • A sound to play (for this tutorial, it's in .ogg format, keep it at that. "rickroll.ogg". Keep it in the "sounds" folder of your custom story)
  • Script events
    • void AddTimer(string& asName, float afTime, string& asFunction); //Adding and working with timers
    • void PlayGuiSound(string& asSoundFile, float afVolume); //Play a sound, not using
      3D

    • void AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates); //Calls a function when two entities collide
    • int RandInt(int alMin, int alMax); //Selects a random integer between Min and Max value.

The actual script:
PHP Code: (Select All)
void OnStart()
{
    
AddEntityCollideCallback("Player""stopSoundArea""stopSoundFunction"true1); //Calls the "stopSoundFunction" when Player hits "stopSoundArea".

    
AddTimer("loop"RandInt(2535), "PlayLoopSound"); //Adds the timer to play the Loop sound.
}

void PlayLoopSound(string &in asTimer//The timer function.
{
    
PlayGuiSound("rickroll.ogg"1.0f); //Plays the file one time and ends.
    
AddTimer("loop"RandInt(2535), "PlayLoopSound"); //Waits 25 to 35 seconds and repeats the function.
}

void stopSoundFunction(string &in asParentstring &in asChildint alState)
{
    
RemoveTimer("loop"); //Removes the timer and breaks the loop.

01-29-2016, 10:45 PM
Find


Messages In This Thread
Assist me while I learn to script - by Toggle - 01-26-2016, 10:59 PM
RE: Level Editor Crash - by Mudbill - 01-27-2016, 01:38 AM
RE: Level Editor Crash - by Toggle - 01-27-2016, 03:01 AM
RE: No Matching Signatures - by Toggle - 01-29-2016, 02:56 AM
RE: No Matching Signatures - by Mudbill - 01-29-2016, 08:25 AM
RE: No Matching Signatures - by Spelos - 01-29-2016, 07:12 PM
RE: No Matching Signatures - by Toggle - 01-29-2016, 07:15 PM
RE: Assist me while I learn to script - by Toggle - 01-29-2016, 08:29 PM
RE: Assist me while I learn to script - by Spelos - 01-29-2016, 10:45 PM



Users browsing this thread: 1 Guest(s)