Clear
Junior Member
Posts: 19
Threads: 4
Joined: May 2012
Reputation:
0
|
Script help!
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
|
|
06-10-2012, 10:09 AM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
RE: Script help!
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
void OnStart() { for(int i=0;i<10;i++) SetEntityPlayerInteractCallback("Pig_"+i, "PigSound", false); }
void PigSound(string &in asEntity) { PlaySoundAtEntity("", "NAMEOFSOUND", asEntity, 0, false); //Put other things here if you want }
This is the code pretty much
|
|
06-10-2012, 10:23 AM |
|
Clear
Junior Member
Posts: 19
Threads: 4
Joined: May 2012
Reputation:
0
|
RE: Script help!
(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
void OnStart() { for(int i=0;i<10;i++) SetEntityPlayerInteractCallback("Pig_"+i, "PigSound", false); }
void PigSound(string &in asEntity) { PlaySoundAtEntity("", "NAMEOFSOUND", asEntity, 0, false); //Put other things here if you want }
This is the code pretty much
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!
Thanks again!
|
|
06-10-2012, 10:26 AM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
RE: Script help!
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
Have you ever scripted before?
|
|
06-10-2012, 10:45 AM |
|
Clear
Junior Member
Posts: 19
Threads: 4
Joined: May 2012
Reputation:
0
|
RE: Script help!
(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
Have you ever scripted before? Nope xD
|
|
06-10-2012, 04:01 PM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
|
06-10-2012, 04:13 PM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
RE: Script help!
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.
Trying is the first step to success.
|
|
06-10-2012, 04:22 PM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
RE: Script help!
(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
|
|
06-10-2012, 04:25 PM |
|
Clear
Junior Member
Posts: 19
Threads: 4
Joined: May 2012
Reputation:
0
|
RE: Script help!
(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 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?
Heres the info you need:
Pig's name - Piggeh1
Sound file name - Yeah
I'd love you forever if it works *^*
|
|
06-12-2012, 04:02 PM |
|
CorinthianMerchant
Posting Freak
Posts: 2,876
Threads: 84
Joined: Nov 2011
Reputation:
131
|
RE: Script help!
Please not another pewdiepie map. Why not something more serious and yummy like an atmospheric map, I'm sure that will be more appreciated!
Still hasn't gotten over the loss of wubwub...
|
|
06-12-2012, 04:11 PM |
|
|