12-25-2014, 02:25 AM
12-25-2014, 02:57 AM
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
SOUND PLAYS AT AN OBJECT
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:
void OnStart()
{
SetEntityCallbackFunc("ItemName", "PlaySound");
}
void PlaySound(string &in asEntity, string &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:
void OnStart()
{
SetEntityCallbackFunc("ItemName", "PlaySound");
}
void PlaySound(string &in asEntity, string &in type)
{
PlaySoundAtEntity("SoundObject", "SoundFile.snt", "EntityWhereTheSoundWillBeFrom", 0.1f, false);
}
12-25-2014, 03:51 AM
So there's no code for collecting the item or adding it to your inventory?
12-25-2014, 04:41 AM
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.
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.
12-25-2014, 01:33 PM
This thread belongs in development support, moved!