Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   music script dosent work suddenly (https://forums.graalonline.com/forums/showthread.php?t=64317)

Prozac 02-24-2006 03:29 AM

music script dosent work suddenly
 
Script worked fine for weeks.
Then one day it didn't.
It dosent work today either after full pc reboot.
what happened to graal to make this not work?
mp3's load in urls/

PHP Code:

//#CLIENTSIDE
function onCreated()
{
this.url="http://my.url.here/folder/";  //actual url unimportant
this.playlist={"song1.mp3","song2.mp3"};
}

function 
onPlayerchats()
  {
   if (
player.chat=="/playlist")
    {
     
player.chat="Playlist has "this.playlist.size() @ " songs in it.";
    }
    
   if (
player.chat=="/playmusic")
    {
      for (
this.i=0this.i<this.playlist.size(); this.i++) 
      {
        
this.song=this.url@this.playlist[this.i];
        
play(this.song);
        
this.songlength=int(musiclen/1000);
        
player.chat="Now playing: "@this.playlist[this.i]@" : "@this.songlength;
        
sleep(this.songlength);
      }
    }
    
   if (
player.chat=="/playrandom")
    {
      for (
this.j=0this.j<this.playlist.size(); this.j++) //for as many songs in list
      
{
      
this.i=int(random(0,this.playlist.size()));  // choose a random song
      
this.song=this.url@this.playlist[this.i];
      
play(this.song);
      
this.songlength=int(musiclen/1000);
      
player.chat="Now playing: "@this.playlist[this.i]@" : "@this.songlength@" seconds";
      
sleep(this.songlength);
      }    
    }

   if (
player.chat=="/stopmusic")
    {
     
stopmidi;
     
player.chat="music stopped";
    }
    
 } 

no sound for random play
no sound for playlist play
display says 0 seconds in the song length.
what changed in gs2 or game client?!?!?!?!?!

ZeLpH_MyStiK 02-24-2006 06:28 AM

Maybe it's the file host. =O

Prozac 02-24-2006 06:46 AM

nope. as stated above :rolleyes: files are hosted correctly and the URL string is formed correctly in the script. Paste the url into a webbrowser, i get music. Nothing changed in the file host or npc. Graal had an update then it stopped working.

ApothiX 02-24-2006 02:56 PM

Try using a timeout to check whether the end of the song has been reached instead of using sleep() with the length of the song.

Admins 02-26-2006 02:10 PM

It is possible that the music is not directly started and it first needs to contact the web server. With the new update the game is not freezing/waiting anymore until the music stream is started, so musiclen might be zero if you call it directly after starting the stream.

Prozac 02-26-2006 08:10 PM

Thank you Stefan!
Placing a delay between the play command and the check for musiclen fixed it.

ApothiX 02-27-2006 03:23 PM

I still think you should use a timeout to check for that instead of sleep.


All times are GMT +2. The time now is 11:22 PM.

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