Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Playing Music Serverside (https://forums.graalonline.com/forums/showthread.php?t=134264533)

Emera 09-11-2011 08:52 PM

Playing Music Serverside
 
I was wondering how to play music serverside for all the players in a level. This is what I have:
PHP Code:

//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat.starts("/play ")) {
    
play(@player.chat.substring(6));
  }


Would this work?
PHP Code:

function onActionServerside() {
 if (
params[0] == "play") {
   
play(params[1]);
 }
}
//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat.starts("/play ")) {
    
setani("sit",NULL);
    
play(player.chat.substring(6));
    
triggerserver("gui",this.name,"play",player.chat.substring(6));
  }



Crow 09-11-2011 09:02 PM

Trigger all players in the level from the serverside and play it on the clientside for everybody. Won't work otherwise.

Emera 09-11-2011 09:04 PM

MHM?
PHP Code:

function onActionServerside() {
 if (
params[0] == "play") {
   for (
temp.pl allplayers) {
     
pl.triggerclient("gui",this.name,"playing");
     
serverr.playing params[1];
   }
 }
}
//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat.starts("/play ")) {
    
setani("boom",NULL);
    
triggerserver("gui",this.name,"play",player.chat.substring(6));
  }
  if (
player.chat == "/stop") {
    
stopmusic();
  }
  if (
player.chat.starts("/ani ")) {
    
setani(@player.chat.substring(5), NULL);
  }
}
function 
onActionClientside() {
  if (
params[0] == "playing") {
    
play(serverr.playing);
    
player.chat "Works";
  }



Hezzy002 09-11-2011 09:16 PM

PHP Code:

function onActionServerside(action) {
  if (
action == "play") {
    
song params[1];
    for (
pl players) {
      
pl.triggerClient("gui"name"play"song);
    }
  }
}
//#CLIENTSIDE
function onPlayerChats() {
  
temp.toks player.chat.tokenize();
  if (
temp.toks[0] == "/playsong") {
    
triggerserver("gui"nametemp.toks[1]);
  }
}

function 
onActionClientside(action) {
  if (
action == play) {
    
song params[1];
    
play(song);
  }


Ya?

Emera 09-11-2011 09:25 PM

Quote:

Originally Posted by Hezzy002 (Post 1667857)
PHP Code:

function onActionServerside(action) {
  if (
action == "play") {
    
song params[1];
    for (
pl players) {
      
pl.triggerClient("gui"name"play"song);
    }
  }
}
//#CLIENTSIDE
function onPlayerChats() {
  
temp.toks player.chat.tokenize();
  if (
temp.toks[0] == "/playsong") {
    
triggerserver("gui"nametemp.toks[1]);
  }
}

function 
onActionClientside(action) {
  if (
action == play) {
    
song params[1];
    
play(song);
  }


Ya?

Yours seems shorter and more efficient. :3

Crow 09-11-2011 10:57 PM

Quote:

Originally Posted by Hezzy002 (Post 1667857)
Ya?

You forgot a pair of quotation marks on the clientside trigger receiving end.

0PiX0 09-11-2011 11:51 PM

If it's for playing music in a level for all players, why are all of you writing gui/weapon scripts? Level npc scripting approach seems simpler and more appropriate for the situation to me:
PHP Code:

function onCreated() {
  
setshape(13232);
  
setSong("defaultsongplaying.mp3");
}

function 
onPlayerChats() {
  
temp.tokens player.chat.tokenize();
  if (
tokens[0] == "playsong") {
    if (
fileexists(tokens[1])) {
      if (
tokens[1] != this.attr[10]) {
        
setSong(tokens[1]);
      }
    }
  }
}

function 
setSong(temp.filename) {
  
this.attr[10] = filename;
  
triggeraction(this.1this.1"SongChanged"filename);
}

//#CLIENTSIDE
function onCreated() {
  
setshape(13232);
}

function 
onPlayerEnters() {
  
setSong(this.attr[10]);
}

function 
onActionSongChanged(temp.filename) {
  
setSong(filename);
}

function 
setSong(temp.filename) {
  
stopmusic();
  
playlooped(filename);



Emera 09-12-2011 05:04 PM

It isn't just for a particular level though. It was sorted 3 posts down.

0PiX0 09-12-2011 05:16 PM

Quote:

Originally Posted by Emera (Post 1667854)
I was wondering how to play music serverside for all the players in a level.

Quote:

Originally Posted by Emera (Post 1667925)
It isn't just for a particular level though.

:confused:
Alright then.

Crow 09-12-2011 05:24 PM

Quote:

Originally Posted by 0PiX0 (Post 1667929)
:confused:
Alright then.

It could be several levels, not just a single one on the whole server. "A level" doesn't have to be a unique level, it could also be the level the script is executed in.


All times are GMT +2. The time now is 09:19 AM.

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