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 09-11-2011, 08:52 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
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));
  }

__________________
Reply With Quote
  #2  
Old 09-11-2011, 09:02 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Trigger all players in the level from the serverside and play it on the clientside for everybody. Won't work otherwise.
Reply With Quote
  #3  
Old 09-11-2011, 09:04 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
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";
  }

__________________

Last edited by Emera; 09-11-2011 at 09:16 PM..
Reply With Quote
  #4  
Old 09-11-2011, 09:16 PM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
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?
Reply With Quote
  #5  
Old 09-11-2011, 09:25 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by Hezzy002 View Post
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
__________________
Reply With Quote
  #6  
Old 09-11-2011, 10:57 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Hezzy002 View Post
Ya?
You forgot a pair of quotation marks on the clientside trigger receiving end.
Reply With Quote
  #7  
Old 09-11-2011, 11:51 PM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
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);

__________________
Reply With Quote
  #8  
Old 09-12-2011, 05:04 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
It isn't just for a particular level though. It was sorted 3 posts down.
__________________
Reply With Quote
  #9  
Old 09-12-2011, 05:16 PM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
Quote:
Originally Posted by Emera View Post
I was wondering how to play music serverside for all the players in a level.
Quote:
Originally Posted by Emera View Post
It isn't just for a particular level though.

Alright then.
__________________
Reply With Quote
  #10  
Old 09-12-2011, 05:24 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by 0PiX0 View Post

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.
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 05:30 AM.


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