Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Music not playing (https://forums.graalonline.com/forums/showthread.php?t=134265220)

sssssssssss 12-11-2011 05:29 PM

Music not playing
 
It's really weird, because this just wont work...

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
temp.saljiut = { 
    
"roak_bd03.nw"
  
};
  
  
temp.swampofrumug = { 
    
"roak_bb08.nw""roak_bb09.nw"
  
};
  
  
temp.southwestforest = {
    
"roak_ap06.nw""roak_ap07.nw"
  
};
  
temp.onlinestart "armageddon-onlinestart.nw";
}
function 
onPlayerEnters() {
    if (
player.level.name in temp.saljiut) {  
      
playlooped("roak-abyss.mid");
    }
    else if (
player.level.name in temp.lystra) {  
      
playlooped("roak-towntheme2.mid");  
    }
    else if (
player.level.name == temp.onlinestart){
      
playlooped("armageddon-onlinestart.mid");
    }
    else if (
player.level.name in temp.southwestforest){
      
playlooped("roak1.mid");
    }
    else if (
player.level.name in temp.swampofrumug){
      
playlooped("roak1.mid");
    }  


I've always done music this way. This also used to work before but now it just doesn't play anything.

ffcmike 12-11-2011 05:42 PM

Temp. variables last temporarily until the function process ends, you'd need to store those arrays as this. variables as the temp. vars would only exist within the onCreated function.

It would also be somewhat cleaner to just create one multi-dimensional array to loop through and check the condition as opposed to having multiple if conditions.
A check to prevent the playloop function occurring if the file is already playing when you enter a level is also good to avoid a very slight client pause this can cause.

sssssssssss 12-11-2011 05:53 PM

Can't believe i didnt catch the temp.vars. Appreciate the advise as well, going to implement it soon.


All times are GMT +2. The time now is 12:43 AM.

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