Frictional Games Forum (read-only)
Script help! - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Script help! (/thread-16018.html)

Pages: 1 2


Script help! - Clear - 06-10-2012

Hey guys!
I was working on a custom story when i had this idea of adding a sound that is activated Every time you touch a certain object, wich on this case is a Pig.
I have the .ogg sound in the folder and all, i'd appreciate any help! =D


RE: Script help! - SilentStriker - 06-10-2012

Well rename all the pigs with the same name for example pig_1, pig_2 etc then use this script

The bolded 10 is how many pigs you have so if you have 5 change it to 5 if you have 15 then change the 10 to 15 etc Smile
PHP Code:
void OnStart()
{
for(
int i=0;i<10;i++) SetEntityPlayerInteractCallback("Pig_"+i"PigSound"false);
}

void PigSound(string &in asEntity)
{
PlaySoundAtEntity("""NAMEOFSOUND"asEntity0false);
//Put other things here if you want


This is the code pretty much Smile


RE: Script help! - Clear - 06-10-2012

(06-10-2012, 10:23 AM)SilentStriker Wrote: Well rename all the pigs with the same name for example pig_1, pig_2 etc then use this script

The bolded 10 is how many pigs you have so if you have 5 change it to 5 if you have 15 then change the 10 to 15 etc Smile
PHP Code:
void OnStart()
{
for(
int i=0;i<10;i++) SetEntityPlayerInteractCallback("Pig_"+i"PigSound"false);
}

void PigSound(string &in asEntity)
{
PlaySoundAtEntity("""NAMEOFSOUND"asEntity0false);
//Put other things here if you want


This is the code pretty much Smile



Thank you so much for the help! =D
I'm new at all the scripting parts, so just a few more questions,
Where do i put this code?
How come there is "PigSound" and "NAMEOFSOUND" Do i put the same sound ".ogg" in there?
That's it! Big Grin
Thanks again! Smile


RE: Script help! - SilentStriker - 06-10-2012

the PigSound is the name of the function and NAMEOFSOUND is where you put the name of your pig squeal or what ever it's called Smile

Have you ever scripted before?


RE: Script help! - Clear - 06-10-2012

(06-10-2012, 10:45 AM)SilentStriker Wrote: the PigSound is the name of the function and NAMEOFSOUND is where you put the name of your pig squeal or what ever it's called Smile

Have you ever scripted before?
Nope xD


RE: Script help! - SilentStriker - 06-10-2012

Ok... xD So then look around here Smile http://wiki.frictionalgames.com/


RE: Script help! - FlawlessHappiness - 06-10-2012

Instead of renaming it, why not just use the name it has? If you have a lot of pigs, then it's a waste of time. The level editor itself changes the number _1, _2, _3 etc.


RE: Script help! - SilentStriker - 06-10-2012

(06-10-2012, 04:22 PM)beecake Wrote: Instead of renaming it, why not just use the name it has? If you have a lot of pigs, then it's a waste of time. The level editor itself changes the number _1, _2, _3 etc.
True Smile


RE: Script help! - Clear - 06-12-2012

(06-10-2012, 04:25 PM)SilentStriker Wrote:
(06-10-2012, 04:22 PM)beecake Wrote: Instead of renaming it, why not just use the name it has? If you have a lot of pigs, then it's a waste of time. The level editor itself changes the number _1, _2, _3 etc.
True Smile
Hey man, the idea you gave me doesn't work, i've tried many times but nothing happens.
Maybe you could re create the code for me? Big Grin
Heres the info you need:
Pig's name - Piggeh1
Sound file name - Yeah

I'd love you forever if it works *^*


RE: Script help! - CorinthianMerchant - 06-12-2012

Please not another pewdiepie map. Why not something more serious and yummy like an atmospheric map, I'm sure that will be more appreciated! Big Grin