Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-14-2007, 02:35 AM
Cherrykao Cherrykao is offline
Banned
Join Date: Apr 2007
Posts: 37
Cherrykao is on a distinguished road
music instrument

I scripted a music instrument and when i play it, i can hear it, but other people in the level can't hear it. so my question is how can I make it so that others can hear the sounds from the music instrument too?

here's a part of my script:
NPC Code:

// flute1 is idle gani and flute2 is the animation gani when player plays the flute

//#CLIENTSIDE
function onWeaponFired() {
this.mode = 1;
this.count = 10;
disabledefmovement();
setani flute1,;
setTimer(0.05);
}

function onTimeout() {
if (this.mode == 1) {
// Quit
if (keydown(6)) {
setani idle,;
enabledefmovement();
this.mode = 0;
}
if (keydown(1)) {
setani flute2,;
if (keydown(4)) {
play("flute9.wav");
}
else if (keydown(5)) {
play("flute5.wav");
} else {
play("flute1.wav");
}

// some more codes here...

setTimer(0.05);
}
}

Reply With Quote
  #2  
Old 07-14-2007, 02:38 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
The play() command only plays the sounds for the current player. In order for other players to hear sounds, they have to be in a gani.

And please, use [ PHP][ /PHP] tags instead of code ones.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #3  
Old 07-14-2007, 02:48 AM
Cherrykao Cherrykao is offline
Banned
Join Date: Apr 2007
Posts: 37
Cherrykao is on a distinguished road
yes indeed, i was speculating that. what i want to do is simply pass an integer from 1 - 16 to the gani and then the gani will play a specific wave file based on the number it was passed. so to do this i would do:

// In the instrument weapon code
PHP Code:
setani("flute2"1); 
but then, how would the code look inside the gani (when i open the gani up in a text editor to read what variable was passed to it)??

// In the gani:
PHP Code:
SCRIPT 
  
if (params[0] == 1) {
    
play("flute1.wav");
  }
  else (
params[0] == 2) {
    
play("flute2.wav");
  }
SCRIPTEND 
is that how it would look inside the gani file?
Reply With Quote
  #4  
Old 07-14-2007, 02:53 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
I haven't tried this, but this -should- work (gani script):


PHP Code:
function onCreated()
{
  
play(params[0]);

If that doesn't work, try this in the wNPC:

PHP Code:
player.attr[20] = "songtoplay.mid";
setani("flute2"); 
And then this in the gani:

PHP Code:
function onPlayerEnters()
{
  
play(player.attr[20]);

__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #5  
Old 07-14-2007, 06:36 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
No, you can't use onCreated() in a GANI script.

onCreated() will overwrite params, and onCreated() will be given no params. So I would do something like this:

PHP Code:
SCRIPT
if (created)
{
  
playparams[0] );
}
SCRIPTEND 
and then do
setAni( "flute_play", "sound1.wav" );

For more advanced gani scripts, you can do
PHP Code:
if ( created )
{
  
this.args params;
  
startScript();
}
function 
startScript()
{
  
// Now params is in this.args
  
doSomething();

__________________

Last edited by cbk1994; 07-14-2007 at 06:37 PM.. Reason: typo
Reply With Quote
  #6  
Old 07-14-2007, 06:46 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Simple.

setani("flutegani","flutesound_"this.sound);

and in the gani, put a sound and use PARAM1
Reply With Quote
  #7  
Old 07-14-2007, 06:57 PM
HolySheepy HolySheepy is offline
Registered User
Join Date: Apr 2007
Posts: 68
HolySheepy is on a distinguished road
setani("flutegani","flutesound_" @ this.sound);

corrected :P
Reply With Quote
  #8  
Old 07-14-2007, 08:48 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Hmm, I put @ this.sound must of got removed somehow.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:04 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.