Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Staff Song Player (https://forums.graalonline.com/forums/showthread.php?t=134264166)

Gunderak 08-10-2011 09:53 AM

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");
}
}
}



Twinny 08-10-2011 10:22 AM

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.

Gunderak 08-10-2011 10:31 AM

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?

Crow 08-10-2011 10:33 AM

Quote:

Originally Posted by Gunderak (Post 1662843)
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.

Gunderak 08-10-2011 11:21 AM

Ahhh ok i see where your going.
but over all is the script okish?

Emera 08-10-2011 11:24 AM

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");
      }
    }
  }



cbk1994 08-10-2011 12:18 PM

As I've told you in every other one of your posts, you need to style your code as you write it.

fowlplay4 08-10-2011 04:23 PM

Quote:

Originally Posted by Gunderak (Post 1662850)
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.


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

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