Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   a few different Questions... (https://forums.graalonline.com/forums/showthread.php?t=78386)

Knightmare1 01-18-2008 08:30 PM

a few different Questions...
 
Well, first and foremost, i have always wonderd how to do this, play uploaded songs. would you do
PHP Code:

playmidi( levels/music/<filename>.mp3); 

i am making a radio with different Stations for all the Administrators, it changes from channel 1-9. im using the one that Rapidwolve made, but it isnt working. the script for item Radio:
PHP Code:

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

public function 
updateChannelVars(dj, text, song, djhead){ 
  
player.triggerClient("gui", name, "recRadioParams", dj, text, song, djhead); 
} 
//#CLIENTSIDE 

function onCreated() 
  
setVars(); 


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

function 
onKeyPressed(code, key){ 
  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 = "Tahoma"; 
    
this.fontsize = .65; 
    
this.textstyle = "b"; 
    
stopmidi(); 
} 

public function 
updateChannelVars(dj, rtext, song, djhead){ 
  
this.djhead = temp.djhead; 
  
this.rtext = temp.rtext; 
  
this.dj = temp.dj; 
  
this.song = temp.song; 
} 

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;  
  
onTimeout(); 
} 

function 
destroyRadio(){ 
  
client.radio = false; 
  
stopmidi(); 
  
hideimgs(-1,1000); 
} 

function 
onTimeout(){ 
  
showimg(202, this.djhead, this.sx, this.sy - 25); 
  
changeimgvis(202,4); 
  
changeimgpart(202,3,69,26,23); 

  
showText(200, this.sx + 140, this.sy - 25, "Tahoma", "ic", serverr.("radio" @ client.radiochannel @ "name")); 
  
changeimgvis(200, 7); 
  
changeimgzoom(200, this.fontsize - .1); 
  
showText(201, this.sx + 140, this.sy - 10, "Tahoma", "ic", this.dj); 
  
changeimgvis(201, 7); 
  
changeimgzoom(201, this.fontsize - .1); 

  
tokens = wraptext2(255, this.fontsize, " ", this.font @ "@" @ this.fontstyle @ "@" @ this.rtext); 
  
hideimgs(250,300); 
    for (
this.i = 0; this.i < tokens.size(); this.i++){ 
      
showText(250 + this.i, this.sx, this.sy + (this.i * 15), this.font, this.textstyle, tokens[this.i]); 
      
changeimgvis(250 + this.i, 7); 
      
changeimgzoom(250 + this.i, this.fontsize); 
  } 
    if (
this.song != null) 
      
playlooped(this.song); 
       else 
      
stopmidi(); 
      
setTimer(.05); 
} 

and the script for NPC Radio:
PHP Code:

public function doUpdateStation(stationid, dj, text, song, head){ 
  
this.radio.("station_" @ stationid) = {dj, text, song, head}; 
  
refresh(stationid); 
} 

public function 
doUpdateSong(stationid, song, dj, djhead){ 
  
temp.text = this.radio.("station_" @ stationid)[1]; 
  
this.radio.("station_" @ stationid) = new [4]; 
  
this.radio.("station_" @ stationid)[1] = temp.text; 
  
this.radio.("station_" @ stationid)[2] = song; 
  
this.radio.("station_" @ stationid)[0] = dj; 
  
this.radio.("station_" @ stationid)[3] = djhead; 
  
refresh(stationid); 
} 

public function 
doUpdateText(stationid, text, dj, djhead){ 
  
temp.song = this.radio.("station_" @ stationid)[2]; 
  
this.radio.("station_" @ stationid) = new [4]; 
  
this.radio.("station_" @ stationid)[2] = temp.song; 
  
this.radio.("station_" @ stationid)[1] = text; 
  
this.radio.("station_" @ stationid)[0] = dj; 
  
this.radio.("station_" @ stationid)[3] = djhead; 
  
refresh(stationid); 
} 

public function 
refresh(stationid){ 
  for (
p: allplayers){ 
    
with (p){ 
      if (
client.radiochannel == stationid){ 
      
temp.newdj = this.radio.("station_" @ stationid)[0]; 
      
temp.newtext = this.radio.("station_" @ stationid)[1]; 
      
temp.newsong = this.radio.("station_" @ stationid)[2]; 
      
temp.newhead = this.radio.("station_" @ stationid)[3]; 
      
p.findWeapon("Radio").updateChannelVars(temp.newdj, temp.newtext, temp.newsong, temp.newhead); 
      } 
    } 
   } 
} 

and for the class radiostation-control:

PHP Code:

function onPlayerChats(){ 
if (
player.chat.starts(":song")) findNPC("Radio").doUpdateSong(this.stationid, player.chat.substring(6), player.account, player.head); 
if (
player.chat.starts(":text")) findNPC("Radio").doUpdateText(this.stationid, player.chat.substring(6), player.account, player.head); 
} 

and the script for the item NPC in the level you wish to change stuff is:
PHP Code:

  join("radiostation-control");
  
this.stationid = 1; 

and he tells you to put this in your serverflags:
PHP Code:

serverr.radio.validstations=1 

and something else, but i dont know, this is what he says:
Quote:

Originally Posted by Rapidwolve (Post 1297465)
To give the radio station a name create another server flag 'serverr.radio#name' and its value should be the desired name.


Knightmare1 01-18-2008 08:35 PM

and sorry for the double post, but here is the other question:
How do you rotate gani's? i can do rotation on images, but i cant seem to find out how to rotate gani's. here is the car script that needs to rotate a gani:
PHP Code:

//#CLIENTSIDE
function onPlayerChats()
{
  if ( 
player.chat == ":car" )
  {
    
this.car = 1 - this.car;
    if ( 
this.car )
    {
      
client.frozen = true;
      
setTimer( 0.05 );
    }
    else
    {
      
player.attr[6] = "";
      
client.frozen = false;
      
setTimer( 0 );
    }
  }
}
function 
onTimeOut()
{
  
client.frozen = true;    player.x = getMoveX( this.accel );
    
player.y = getMoveY( this.accel );
  if ( 
keydown( 1 ) )
  {
    
this.carAngle += .2;  
  }
  if ( 
keydown( 3 ) )
  {
    
this.carAngle -= .2;
  }
  
  
temp.dx = getMoveX( 1 );
  
temp.dy = getMoveY( 1 );
  
player.dir = getdir( temp.dx - player.x, temp.dy - player.y );
  if ( 
keydown( 0 ) )
  {
    
this.accel = this.accel + .1 > 1 ? 1 : this.accel + .1;
  }
  else
  {
    
this.accel = this.accel - .1 < 0 ? this.accel = 0 : this.accel - .1;
  }
    
player.x = getMoveX( this.accel );
    
player.y = getMoveY( this.accel );
  
client.car_angle = this.carAngle;
  
player.attr[5] = this.carAngle;
  
  
setAni( "sit", "" );
  
player.attr[6] = "ut_car.gani";

  
setTimer( 0.05 );
}
function 
getMoveX( speed )
{
  return 
player.x - sin( this.carAngle ) * speed;
}
function 
getMoveY( speed )
{
  return 
player.y - cos( this.carAngle ) * speed;
} 


Inverness 01-18-2008 09:41 PM

play("filename.mp3");
playlooped("filename.mp3");


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

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