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 08-20-2010, 10:17 PM
bscharff bscharff is offline
Bloo
bscharff's Avatar
Join Date: Sep 2006
Location: San Antonio, Texas
Posts: 185
bscharff has a little shameless behaviour in the past
Send a message via AIM to bscharff Send a message via MSN to bscharff Send a message via Yahoo to bscharff
Radio + Shoutcast

OK, I tinkered with Rapidwolve's Radio script (see Code Gallery), and tried to add Shoutcast (*.pls) stream support, but it's not working
Everything works EXCEPT the actual music.
Can anyone find the thing I must have overlooked?

PHP Code:
function onActionServerside(action)
{
  switch (
action)
  {
    case 
"updateChannel":
        
findNPC("RadioServer").refresh(params[1]);
      break;
  }
}

public function 
updateChannelVars(djtextsongdjhead){
  
player.triggerClient("gui"name"recRadioParams"djtextsongdjhead);
}

//#CLIENTSIDE
function onCreated()
setVars();


function 
onActionClientside(action){
  switch (
action)
  {
    case 
"recRadioParams":
        
updateChannelVars(params[1], params[2], params[3], params[4]);
      break;
  }
}

function 
onKeyPressed(codekey)
{
  if (
client.radio true)
    if (
key in serverr.radio.validstations)
      
doChangeStation(key);
}

function 
onWeaponFired()
toggleRadio();


function 
setVars(){
  if (
client.radiochannel == null)
    
client.radiochannel 1;
  
updateChannel(client.radiochannel);
  
client.radio false;
  
this.sx screenwidth - (32 9.5);
  
this.sy 35;
  
this.font "Arial";
  
this.fontsize 0.65;
  
this.textstyle "b";
  
stopmidi();
}

public function 
updateChannelVars(djrtextsongdjhead){
  if (
temp.song.pos(".pls") > -1)
  {
    
this.req requestURL(temp.song);
    
catchevent(this.req"onReceiveData""onData1");
    
this.rtype 2;
  }
  else
  {
    
this.song temp.song;
    
this.rtype 1;
  }

  
this.djhead temp.djhead;
  
this.rtext temp.rtext;
  
this.dj temp.dj;
}

function 
onData1(obj)
{
  for (
lineobj.data)
  {
    if (
line.starts("File1="))
    {
      
this.song line.substring(6);
      break;
    }
  }
  
this.req NULL;
}

function 
onMusicDataReceived(datanamedatavalue) {
  if (
dataname == "ATRIST")
    
this.artist datavalue;
  else if (
dataname == "TITLE")
    
this.songname datavalue;

  echo(
"music status: " getMusicStatus());
  echo(
"music info: " getMusicTags());
}

public function 
updateChannel(channel)
{
  
triggerServer("gui"name"updateChannel"channel);
}


public function 
doChangeStation(channel){
  
updateChannel(channel);
  
client.radiochannel channel;
}

public function 
toggleRadio(){
  if (
client.radio == false)
  {
    
client.radio true;
    
drawRadio();
    
setTimer(.05);
  }
  else
  {
    
destroyRadio();
    
setTimer(0);
  }
}

function 
drawRadio(){
  
updateChannel(client.radiochannel);
  
client.radio true;
  
player.addMessage("You turned your radio on.");
  
onTimeout();
}

function 
destroyRadio(){
  
client.radio false;
  
player.addMessage("You turned your radio off.");
  
stopmidi();
  
hideimgs( -11000);
}

function 
onTimeout(){
  
showimg(202this.djheadthis.sxthis.sy 25);
  
changeimgvis(2024);
  
changeimgpart(2023692623);

  
showText(200this.sx 140this.sy 25this.font"ic"serverr.("radio" client.radiochannel "name"SPC "via" SPC (this.rtype == "MP3" "Shoutcast"));
  
changeimgvis(2007);
  
changeimgzoom(200this.fontsize 0.1);

  
showText(201this.sx 140this.sy 10this.font"ic"this.dj);
  
changeimgvis(2017);
  
changeimgzoom(201this.fontsize 0.1);

  if (
this.rtype == 2)
  {
    
showText(211this.sx 70this.sy 25this.font"c""\"" this.songname "\"");
    
changeimgvis(2117);
    
changeimgzoom(211this.fontsize 0.15);

    
showText(210this.sx 70this.sy 35this.font"c""by" SPC this.artist);
    
changeimgvis(2107);
    
changeimgzoom(210this.fontsize 0.15);
  }
  else
  {
    
hideimg(210);
    
hideimg(211);
  }

  
tokens wraptext2(255this.fontsize" "this.font "@" this.fontstyle "@" this.rtext);
  
hideimgs(250300);
  for (
this.0this.tokens.size(); this.i++)
  {
    
showText(250 this.ithis.sxthis.sy + (this.15), this.fontthis.textstyletokens[this.i]);
    
changeimgvis(250 this.i7);
    
changeimgzoom(250 this.ithis.fontsize);
  }

  if (
this.song != NULL)
  {
    if (
this.rtype == 1)
      
playlooped(this.song);
    else if (
this.rtype == 2)
      
play(this.song);
  }
  else
    
stopmidi();
  
setTimer(0.05);

__________________
Trying to be nice now...
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 10:06 PM.


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