Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Message System (https://forums.graalonline.com/forums/showthread.php?t=76034)

killerogue 08-02-2007 06:37 AM

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.accountplayer.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.stdmsgtimetemp.msg});
            
msgupdate true;
          }
        }
      }
    break;
  }
}

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

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

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



Inverness 08-02-2007 08:01 AM

You need to send messages to other players through the serverside, doing it clientside is only getting their player object as its shown to you.

killerogue 08-02-2007 08:57 AM

Ah, thank you Inverness. Worked perfectly. =D


All times are GMT +2. The time now is 10:52 AM.

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