(05-28-2012, 04:24 AM)TheIcyPickle Wrote: ok so, I receive an error upon making your corrections in the hps file. I want a sound to be made when a player walks past a script box thing, called "popout1" but it only plays once the player has a key called "scarykey_1" Also, if possible , add at the same time, that naked penis figure flys in. (that part may be a pain, so if you can't explain it, its fine.)
here is my entire script.
////////////////////////////
// Run first time starting map
void OnStart()
{
GiveItemFromFile("lantern", "lantern.ent");
for(int i=0;i< 10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
AddUseItemCallback("", "scarykey_1", "door_1", "KeyOnDoor", true);
AddEntityCollideCallback("popout1", string& "Player", "PlaySoundAtEntity", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
RemoveItem("scarykey_1");
}
void PlaySoundAtEntity(string &in asplayer, string &in aspopout1, bool HasItem("scarykey_1")
{
PlaySoundAtEntity1("", "21_screams", "popout1", 0, false);
}
thanks for the help
No flying naked man. Absolutely not. Get that crap out of your custom story, and never implement it. Or get laughed at. Your choice.
Anywho.
void PlaySoundAtEntity(string &in asplayer, string &in aspopout1, bool HasItem("scarykey_1"){
PlaySoundAtEntity1("", "21_screams", "popout1", 0, false);}
What is this? Can you please brush up on how functions work... In fact, just remove this stuff, it's worthless.
You want to play a sound when passing an entity? Use an AddEntityCollideCallback
So:
//place in OnStart
AddEntityCollideCallback("Player', "scriptareathingy", "PlaySound", false, 0);
void PlaySound(string &in asParent, string &in asChild, int alState)
{
if(HasItem("keyname") == false) return;
PlaySoundAtEntity("sound", "soundname.snt", "soundarea", 0, false);
}
That is the code basics. Replace wherever I wrote obvious placeholders with the names of your objects.
And never implement a flying naked body. Get out with that stuff. It's sickening.