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 01-18-2008, 08:30 PM
Knightmare1 Knightmare1 is offline
Billy Allan
Knightmare1's Avatar
Join Date: Apr 2007
Posts: 804
Knightmare1 can only hope to improve
a few different Questions...

Well, first and foremost, i have always wonderd how to do this, play uploaded songs. would you do
PHP Code:
playmidilevels/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(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 == nullclient.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(djrtextsongdjhead){ 
  
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(202this.djheadthis.sxthis.sy 25); 
  
changeimgvis(202,4); 
  
changeimgpart(202,3,69,26,23); 

  
showText(200this.sx 140this.sy 25"Tahoma""ic"serverr.("radio" client.radiochannel "name")); 
  
changeimgvis(2007); 
  
changeimgzoom(200this.fontsize .1); 
  
showText(201this.sx 140this.sy 10"Tahoma""ic"this.dj); 
  
changeimgvis(2017); 
  
changeimgzoom(201this.fontsize .1); 

  
tokens wraptext2(255this.fontsize" "this.font "@" this.fontstyle "@" this.rtext); 
  
hideimgs(250,300); 
    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
      
playlooped(this.song); 
       else 
      
stopmidi(); 
      
setTimer(.05); 

and the script for NPC Radio:
PHP Code:
public function doUpdateStation(stationiddjtextsonghead){ 
  
this.radio.("station_" stationid) = {djtextsonghead}; 
  
refresh(stationid); 


public function 
doUpdateSong(stationidsongdjdjhead){ 
  
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(stationidtextdjdjhead){ 
  
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 (
pallplayers){ 
    
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.newdjtemp.newtexttemp.newsongtemp.newhead); 
      } 
    } 
   } 

and for the class radiostation-control:

PHP Code:
function onPlayerChats(){ 
if (
player.chat.starts(":song")) findNPC("Radio").doUpdateSong(this.stationidplayer.chat.substring(6), player.accountplayer.head); 
if (
player.chat.starts(":text")) findNPC("Radio").doUpdateText(this.stationidplayer.chat.substring(6), player.accountplayer.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=
and something else, but i dont know, this is what he says:
Quote:
Originally Posted by Rapidwolve View Post
To give the radio station a name create another server flag 'serverr.radio#name' and its value should be the desired name.
__________________
I am the devil, I am here to do to devils work.
Reply With Quote
  #2  
Old 01-18-2008, 08:35 PM
Knightmare1 Knightmare1 is offline
Billy Allan
Knightmare1's Avatar
Join Date: Apr 2007
Posts: 804
Knightmare1 can only hope to improve
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 this.car;
    if ( 
this.car )
    {
      
client.frozen true;
      
setTimer0.05 );
    }
    else
    {
      
player.attr[6] = "";
      
client.frozen false;
      
setTimer);
    }
  }
}
function 
onTimeOut()
{
  
client.frozen true;    player.getMoveXthis.accel );
    
player.getMoveYthis.accel );
  if ( 
keydown) )
  {
    
this.carAngle += .2;  
  }
  if ( 
keydown) )
  {
    
this.carAngle -= .2;
  }
  
  
temp.dx getMoveX);
  
temp.dy getMoveY);
  
player.dir getdirtemp.dx player.xtemp.dy player.);
  if ( 
keydown) )
  {
    
this.accel this.accel .1 this.accel .1;
  }
  else
  {
    
this.accel this.accel .1 this.accel this.accel .1;
  }
    
player.getMoveXthis.accel );
    
player.getMoveYthis.accel );
  
client.car_angle this.carAngle;
  
player.attr[5] = this.carAngle;
  
  
setAni"sit""" );
  
player.attr[6] = "ut_car.gani";

  
setTimer0.05 );
}
function 
getMoveXspeed )
{
  return 
player.sinthis.carAngle ) * speed;
}
function 
getMoveYspeed )
{
  return 
player.costhis.carAngle ) * speed;

__________________
I am the devil, I am here to do to devils work.
Reply With Quote
  #3  
Old 01-18-2008, 09:41 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
play("filename.mp3");
playlooped("filename.mp3");
__________________
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 09:47 AM.


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