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
Just Scripting
ThePhrygian Offline
Junior Member

Posts: 13
Threads: 3
Joined: Nov 2014
Reputation: 0
#1
Just Scripting

How do I trigger a sound to play when I collect an item?
12-25-2014, 02:25 AM
Find Reply
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: Just Scripting

Okay...

But I am a bit confused. Where do you want the sound to be played? At an object or at the player?
Screw it, I'll give you both.

SOUND PLAYS AT PLAYER
Spoiler below!

PHP Code: (Select All)
void OnStart()
{
SetEntityCallbackFunc("ItemName""PlaySound");
}

void PlaySound(string &in asEntitystring &in type)
{
PlayGuiSound("SoundFile.snt"1); //1 is the volume. Change it to whatever volume you want



SOUND PLAYS AT AN OBJECT
Spoiler below!

PHP Code: (Select All)
void OnStart()
{
SetEntityCallbackFunc("ItemName""PlaySound");
}

void PlaySound(string &in asEntitystring &in type)
{
PlaySoundAtEntity("SoundObject""SoundFile.snt""EntityWhereTheSoundWillBeFrom"0.1ffalse);



"Veni, vidi, vici."
"I came, I saw, I conquered."
12-25-2014, 02:57 AM
Find Reply
ThePhrygian Offline
Junior Member

Posts: 13
Threads: 3
Joined: Nov 2014
Reputation: 0
#3
RE: Just Scripting

So there's no code for collecting the item or adding it to your inventory?
12-25-2014, 03:51 AM
Find Reply
Mudbill Offline
Muderator

Posts: 3,877
Threads: 59
Joined: Apr 2013
Reputation: 178
#4
RE: Just Scripting

You trigger the sound with the SetEntityCallbackFunc. If the entity can be picked up, the type of this callback will be PickUp. It then runs the PlaySound function which runs the PlaySoundAtEntity function. Basically, the sound plays when you pick up the desired item.

If you wish to play the sound at the player itself, I prefer using PlayGuiSound. Look it up at the engine scripts page. https://wiki.frictionalgames.com/doku.ph..._functions

Edit: Also, what are you trying to pick up? If it's an item, you can just click it. If it's a custom one, you'll need to do more work. There is a script called GiveItem that can give you an inventory item.

(This post was last modified: 12-25-2014, 04:42 AM by Mudbill.)
12-25-2014, 04:41 AM
Find Reply
Traggey Offline
is mildly amused

Posts: 3,256
Threads: 73
Joined: Feb 2012
Reputation: 185
#5
RE: Just Scripting

This thread belongs in development support, moved!
12-25-2014, 01:33 PM
Find Reply




Users browsing this thread: 1 Guest(s)