Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Instrument trouble... (https://forums.graalonline.com/forums/showthread.php?t=63625)

RavenofEarth 01-22-2006 12:56 AM

Instrument trouble...
 
Now, this has to be the easiest script, and I seem to be having a minor issue with it. The sounds don't seem to be playing when I press the corresponding keys, the sounds all work, I am unsure if I am overlooking something, or what.

NPC Code:
//#CLIENTSIDE
if (weaponfired) {
setani anzell_flute,anzell-flute.png;
disabledefmovement;
}
if (strequals(#m,anzell_flute)) {
if (keydown(6)) enabledefmovement;
if (keydown(5)) {
if (keydown(0)) play fire2.wav;
elseif (keydown(1)) play flute2.wav;
elseif (keydown(2)) play flute3.wav;
elseif (keydown(3)) play flute4.wav;
} else {
if (keydown(0)) play flute5.wav;
elseif (keydown(1)) play flute6.wav;
elseif (keydown(2)) play flute7.wav;
elseif (keydown(3)) play flute8.wav;
}
}



If anyone has any suggestions on a better script, notify me...XD

Lance 01-22-2006 12:58 AM

Please read this thread and stop putting code outside of event blocks.

RavenofEarth 01-22-2006 01:03 AM

O_o Uhh, I still don't see what that's supposed to be telling me about the event block O_o

Lance 01-22-2006 01:04 AM

Quote:

Originally Posted by RavenofEarth
O_o Uhh, I still don't see what that's supposed to be telling me about the event block O_o

You didn't read the thread. Please try again.

Pay special attention to the definitions of "code block", "event block", and Kai's Rule One.

RavenofEarth 01-22-2006 01:09 AM

Uh, I read the thread...Yet, I am still confuzzled about what it's trying to convey.

Lance 01-22-2006 01:14 AM

Quote:

Originally Posted by RavenofEarth
Uh, I read the thread...Yet, I am still confuzzled about what it's trying to convey.

What part of those I referenced do you not understand?

CheeToS2 01-22-2006 01:43 AM

Quote:

Originally Posted by RavenofEarth
O_o Uhh, I still don't see what that's supposed to be telling me about the event block O_o

The problem is that everything after the 'weaponfired' block in your script is not in an event block, so Graal is not sure when it is supposed to check if your gani is set to anzell_flute or if a certain key is being pressed; maybe it should check when it detects that any key has been pressed, or maybe it should check when you type some words in the chat box. Perhaps you want it to check if the 'up' key is pressed when the United States decides to adopt Graal's Terms of Service as its new constitution; nobody knows when it should check, because you have not specified any event that tells it when.

Events are things that can happen, like the weapon being fired (weaponfired), the npc being touched (playertouchsme), or a timeout occuring (you could set timeout = .05, and .05 seconds later the "timeout" event occurs); there are many others. In your case, you probably want to use the 'timeout' or 'keypressed' events (keypressed might only work in v4 for what you want it to do, I don't think v2 will call keypressed for the arrow keys).

Yen 01-22-2006 02:18 AM

Style your scripts. :(
You should use a gani that plays the sound, instead of the 'play' command.
The 'play' command only plays the sound to you, not other players.
Using a gani will play the sound for everyone.

PHP Code:

if (event) {
  
command;
  
command;
  if (
condition) {
    
command;
    
command;
  }




All times are GMT +2. The time now is 09:56 PM.

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