Thread: for allplayers
View Single Post
  #1  
Old 09-24-2011, 07:57 AM
pig132 pig132 is offline
professional troll
Join Date: May 2006
Posts: 260
pig132 will become famous soon enough
for allplayers

Alright, so I have made a little mass message GUI and I have a quick question.

Since it is being sent to everyone, does "for (temp.pl: allplayers)" get all of the players on the server or just local players in the same level?

Also, here is the code im using. How can I improve it?

Thanks

PHP Code:
function onActionServerSide() {
  switch (
params[0]) {
    case 
"send":
      for (
temp.plallplayers) {
        
findplayer(temp.pl).sendPM(client.massmessage);
        
player.chat "Successfully sent a mass message to " temp.pl "!";
      }
    break;
  }
}

//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat.starts("+mass")) {
    
CreateGUI();
  }
}

function 
CreateGUI() {
  new 
GuiWindowCtrl("mass_window") {
    
profile GuiBlueWindowProfile;
    
    
screenwidth 2.5;
    
screenheight 2.5;
    
width 200;
    
height 200;
    
text "Mass Message";
    
    
destroyonhide true;
    
canminimize canresize canmaximize false;
  
  new 
GuiScrollCtrl("mass_scroller") {
    
profile GuiBlueScrollProfile;
    
    
10;
    
30;
    
width 180;
    
height 130;
    
hscrollbar "alwaysOff";
    
vscrollbar "alwaysOff";
    
  new 
GuiMLTextEditCtrl("mass_text") {
    
profile GuiBlueMLTextEditProfile;
    
    
0;
    
0;
    
width 180;
    
height 130;
  }
  }
  
  new 
GuiButtonCtrl("mass_send") {
    
profile GuiBlueButtonProfile;
    
    
75;
    
165;
    
    
width 50;
    
height 25;
    
text "Send";
  }
  }
// main
}

function 
mass_send.onAction() {
  
client.massmessage mass_text.text;
  
triggerserver("gui"this.name"send");
  
mass_text.text "";


Edit:

Also, in this part of the code:
PHP Code:
findplayer(temp.pl).sendPM(client.massmessage); 
How can I add a line break between a specific sting of text and then the actual message?

Thank you

Last edited by pig132; 09-24-2011 at 08:07 AM..
Reply With Quote