Thread: Message System
View Single Post
  #1  
Old 08-02-2007, 06:37 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Message System

My first time ever really making a message system. And I have a simple problem. Players can't see other players chat. They can see their own chat. But not OTHER player's chats.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
this.stdmsgtime = 5;
  
this.msglimit = 6;
  
player.msgs.clear();

  
onTimeout();
}

function 
onPlayerChats() {
  if (
player.chat != "") {
    if (!
player.chat.starts("/global") && !player.chat.starts("/whisper")) {
      
addMsg({"local", player.account, player.chat});
    }
  }
}

public function 
addMsg(msginfo) {
  switch (
msginfo[0]) {
    case 
"local":
      for (
pl : players) {
        if (
pl.level != null || pl.account == player.account) {
          
temp.msg = "(Local) " @ msginfo[1] @ " says: " @ msginfo[2];
          
with (findplayer(pl.account)) {
            
msgs.add({thiso.stdmsgtime, temp.msg});
            
msgupdate = true;
          }
        }
      }
    break;
  }
}

function 
onTimeout() {
  
updateTime();
  if (
player.msgupdate == true) {
    
updateText();
  }
  
setTimer(1);
}

function 
updateTime() {
  if (
player.msgs != null) {
    for (
i = 0; i < player.msgs.size(); i++) {
      if (
player.msgs[i][0] > 0) {
        
player.msgs[i][0]--;
      }
      else if (
player.msgs[i][0] != -1 && player.msgs[i][0] < 1) {
        
player.msgs.delete(i);
        
player.msgupdate = true;
      }
    }
  }
}

function 
updateText() {
  
hideimgs(200, 207);
  if (
player.msgs != null) {
    if (
player.msgs.size() >  this.msglimit) {
      
player.msgs = null;
      
player.msgupdate = true;
    }
    else {
      for (
i = 0; i < player.msgs.size(); i++) {
        if (
player.msgs[i] != null) {
          
showtext(200 + i, 5, (GraalControl.height - 25) - (18 * i), "Arial", "", player.msgs[i][1]);
          
changeimgvis(200 + i, 5);
          
changeimgzoom(200 + i, 0.5);
        }
      }
    }
  }
} 
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote