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 08-10-2011, 09:53 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Staff Song Player

Basically what it does is plays songs for everyone.
Only staff can use it, note if you want to thief this you need clientr.isStaff added to the players who can use it.
if there is any feedback or ideas for improvement please feel free to comment
i am also planning to make it into a gui which will be much nicer.

PHP Code:
function onActionServerSide(){
  if ( 
params[0] == "Setsong" ) {
  
serverr.song player.chat.substring(5);
  }
  if ( 
params[0] == "PlaySong" ) {
  for( 
pl allplayers ) {
  
pl.triggerclient("weapon"this.name"Play");
}
}
  if ( 
params[0] == "StopSong" ) {
  for( 
pl allplayers ) {
  
pl.triggerclient("weapon"this.name"Stop");
}
}
}
//#CLIENTSIDE
function onPlayerchats(){
if(
clientr.isStaff){
if(
player.chat == "/play"){
triggerserver("gui",this.name,"PlaySong");
}
if(
player.chat == "/stop"){
triggerserver("gui",this.name,"StopSong");
}
if(
player.chat.starts("/set")){
triggerserver("gui",this.name,"Setsong");
}
function 
onActionClientSide(){
if ( 
params[0] == "Play" ) {
play(serverr.song);
}
if ( 
params[0] == "Stop" ) {
play("none.mid");
}
}
}

__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #2  
Old 08-10-2011, 10:22 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
If you are setting serverr.song, i don't see why you need to trigger all players. Clientside could simply check if serverr.song has changed.
Reply With Quote
  #3  
Old 08-10-2011, 10:31 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
I'm setting serverr.song to a song then when the player writes /play itl play it, if i didn't make a trigger for all players it'd only play it clientside? this is to play it for the whole server. i am confused on what your saying. can you explain further?
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #4  
Old 08-10-2011, 10:33 AM
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 Gunderak View Post
I'm setting serverr.song to a song then when the player writes /play itl play it, if i didn't make a trigger for all players it'd only play it clientside? this is to play it for the whole server. i am confused on what your saying. can you explain further?
You can just run a loop on the clientside to check if serverr.song has changed (since serverr.vars can be read on the clientside without the use of triggers). This way, you don't have to send triggers to all clients.
Reply With Quote
  #5  
Old 08-10-2011, 11:21 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Ahhh ok i see where your going.
but over all is the script okish?
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #6  
Old 08-10-2011, 04:23 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Gunderak View Post
Ahhh ok i see where your going.
but over all is the script okish?
No.

You have onActionClientSide() defined in onCreated(). See Emera's post.

If you indented/styled your code properly from the beginning you would have noticed this.
__________________
Quote:
Reply With Quote
  #7  
Old 08-10-2011, 11:24 AM
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
Restyled it with fowplays new beautiful beautifier. Just thought I would post it. Think I just used it as a reason to use fowlplays beautifier.
PHP Code:
function onActionServerSide() {
  if (
params[0] == "Setsong") {
    
serverr.song player.chat.substring(5);
  }
  if (
params[0] == "PlaySong") {
    for (
plallplayers) {
      
pl.triggerclient("weapon"this.name"Play");
    }
  }
  if (
params[0] == "StopSong") {
    for (
plallplayers) {
      
pl.triggerclient("weapon"this.name"Stop");
    }
  }
}

//#CLIENTSIDE
function onPlayerchats() {
  if (
clientr.isStaff) {
    if (
player.chat == "/play") {
      
triggerserver("gui"this.name"PlaySong");
    }
    if (
player.chat == "/stop") {
      
triggerserver("gui"this.name"StopSong");
    }
    if (
player.chat.starts("/set")) {
      
triggerserver("gui"this.name"Setsong");
    }

    function 
onActionClientSide() {
      if (
params[0] == "Play") {
        
play(serverr.song);
      }
      if (
params[0] == "Stop") {
        
play("none.mid");
      }
    }
  }

__________________
Reply With Quote
  #8  
Old 08-10-2011, 12:18 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
As I've told you in every other one of your posts, you need to style your code as you write it.
__________________
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 12:29 AM.


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