Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   GS2 Radio (https://forums.graalonline.com/forums/showthread.php?t=58601)

coreys 04-16-2005 07:03 PM

GS2 Radio
 
Well, my new radio for gs2, for some reason or another, isn't working. I can't really figure out why, can anyone help me?

PHP Code:

//Made by *Admin-Playerworld108
//A.K.A. Vash-Aniki

//Define Functions
function showtitle() {
  
showtext(201,100,0,Arial,b,"Song:"@getstring[serverr.radiotitle]);
  
changeimgvis(201,4);
}
function 
songplay() {
  
play(getstring[serverr.radiosong]);
}
function 
showchat() {
  
showtext(202,100,30,Arial,b,"Chat:"@getstring[serverr.radiochat]);
  
changeimgvis(202,4);
}
function 
onactionserverside() {
  if (
param[0]=="songchange") {
    
serverr.radiosong variable[param[1]];
    for (
i=0;i<allplayerscount;i++) {
      
with (allplayers[i]) {
        if (
client.radiolisten) {
          
songplay();
        }
      }
    }
  }
  if (
param[0]=="titlechange") {
    
serverr.radiotitle variable[param[1]];
    for (
i=0;i<allplayercount;i++) {
      
with (allplayers[i]) {
        if (
client.radiolisten) {
          
showtitle();
        }
      }
    }
  }
  if (
param[0]="chatchange") {
    
serverr.radiochat variable[param[1]];
    for (
i=0;i<allplayerscount;i++) {
      
with (allplayers[i]) {
        if (
client.radiolisten) {
          
showchat();
        }
      }
    }
  }
}

//#CLIENTSIDE
if (player.chat == "/radioon") {
  
set(client.radiolisten);
  
player.chat "Radio On!";
  
songplay();
  
showtitle();
  
showchat();
}
if (
startswith ("/song ",player.chat)) {
  if (
client.radiochanger) {
    
tokenize player.chat;
    
triggeraction(0,0,serverside,Radio,songchange,tokens[1]);
    
player.chat "Song Changed!";
  }
}
if (
startswith ("/title ",player.chat)) {
  if (
client.radiochanger) {
    
tokenize player.chat;
    
triggeraction(0,0,serverside,Radio,titlechange,tokens[1]);
    
player.chat "Title Changed!";
  }
}
if (
startswith ("/chat ",player.chat)) {
  if (
client.radiochanger) {
    
tokenize player.chat;
    
triggeraction(0,0,serverside,Radio,titlechange,tokens[1]);
    
player.chat "Title Changed";
  }
}
if (
player.chat == "/radiooff") {
  unset(
client.radiolisten);
  
stopsound(getstring[serverr.radiosong]);
  
hideimg(201);
  
hideimg(202);



Kaimetsu 04-16-2005 07:10 PM

KSI-GS.

coreys 04-16-2005 10:03 PM

Yeah, I've read that like 3 times

Rick 04-16-2005 11:03 PM

Quote:

Originally Posted by coreys
Yeah, I've read that like 3 times

You have functions in global scope, this is very bad.

Velox Cruentus 04-17-2005 01:15 AM

what rick said + You're calling serverside functions clientside.

You don't need to do getstring[serverr.radiosong]

play command is clientside, I do believe.
showimg => Clientside.

serverside isn't a string. Quote it.
Radio isn't a string, it's an object. Put it in quotes, or put this.name instead.
quote "songchange" and the rest.

Use switch commands?

Don't bother with variable[]

variables do not contain spaces "tok ens[x]"


Umm.... That's just off the top of my head.

Velox Cruentus 04-17-2005 01:31 AM

PHP Code:

// NPC Made by Velox Cruentus
function onactionserverside()
{
  switch (
params[0])
  {
    case 
"title":
    {
      
serverr.radio[0] := params[1];
      break;
    }
    case 
"chat":
    {
       
serverr.radio[1] := params[1];
       break;
    }
    case 
"song":
    {
       
serverr.radio[2] := params[1];
       break;
    }
  }
  for (
pallplayers){
    
with (p)
    {
       
triggeraction(0,0,"clientside","Radio","update");
    }
  }
}
//#CLIENTSIDE
function onplayerchats()
{
  if (
clientr.radioon == true)
  {
    
tok := player.chat.tokenize();
    switch (
tok[0])
    {
       case 
"radiooff":
       {
         
hideimgs(201,202);
         
stopsound();
         
client.radio := false;
         break;
       }
       case 
"chat":
       case 
"title":
       case 
"song":
       {
          
triggeraction(0,0,"serverside",this.name,tok[0],player.chat.substring(tok[0].length(),-1).Trim());
         break;
       }
    }
  } else if (
player.chat == "radioon")
  {
    
client.radio := true;
    
onactionclientside("update");
  }
}

function 
onactionclientside()
{
  if (
params[0] == "update")
  {
    if (
client.radio == true)
    {
      
showtitle(serverr.radio[0]);
      
showchat(serverr.radio[1]);
      
play(serverr.radio[2]);
    }
  }
}
function 
showtitle(text) {
  
showtext(201,100,0,"Arial","b","Song: "text);
  
changeimgvis(201,4);
}
function 
showchat(text) {
  
showtext(202,100,30,"Arial","b","Chat: " text);
  
changeimgvis(202,4);



Kaimetsu 04-17-2005 11:02 AM

Quote:

Originally Posted by coreys
Yeah, I've read that like 3 times

Next, try following it.

Rick 04-18-2005 01:20 AM

Quote:

Originally Posted by Rick
You have functions in global scope, this is very bad.

I meant code, not functions.

(For some reason I can't edit my own posts.)


All times are GMT +2. The time now is 01:27 AM.

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