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


Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Picking up an item gets a sound played
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#4
RE: Picking up an item gets a sound played

Well, PlaySoundAtEntity does just that: Plays a sound at an entity, making it ideal for "3D" sound effects (i.e. having sounds play behind or to the left/right of the player). It can also play a sound at the player himself, but in my opinion, that really over complicates it. PlayGuiSound is a much better "lightweight" alternative, and takes less time to write out.

I use PlayGuiSound in scenarios where the sound makes sense to come from the player (i.e. voice acting), or the entity that makes the sound is in such close proximity that the player couldn't tell the difference anyways (i.e. unlocking a door).

First, the syntax is incorrect, it doesn't match the callback you used
(which I now changed to simplicity's sake). The callback syntax are the words inside the "()", which come after "void function". Use this page to make sure syntax match the callback used:

http://wiki.frictionalgames.com/hpl2/amn..._functions


Next, for the PlaySoundAtEntity function, you didn't really write any of it correctly. Basically, strings are names of things, and are declared (meaning inside of quotation marks i.e. "string" is declared). Bool stands for Boolean value, which is true/false, and float/int are number values; floats being decimals, and int being integers (non decimals).

Aqui esta una revision:


////////////////////////////
// Run when the map starts
void OnStart()
{
AddUseItemCallback("", "llave1", "puerta1", "unlock", true);
AddEntityCollideCallback("Player", "paso1", "ActivarArea", true, 1);
AddEntityCollideCallback("Player", "paso2", "Explotar", true, 1);
SetEntityPlayerInteractCallback("linterna", "OnPickup", true);
}

void ActivarArea(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("paso2", true);
}

void unlock(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}

void Explotar(string &in asParent, string &in asChild, int alState)
{
SetPropHealth("explosive", 0.0f);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare", "Player", 0, false);
PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);
GiveSanityDamage(5.0f, true);
}

void OnPickup(string &in asEntity)
{
SetEntityActive("agrippa", true);
PlaySoundAtEntity("", "girl_scream", "agrippa", 0.5f, false);
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

I rate it 3 memes.
(This post was last modified: 07-29-2012, 07:19 AM by Adny.)
07-29-2012, 06:29 AM
Find


Messages In This Thread
RE: Picking up an item gets a sound played - by Adny - 07-29-2012, 06:29 AM



Users browsing this thread: 1 Guest(s)