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