PDA

View Full Version : Message System


02-18-2009, 09:27 PM
//#CLIENTSIDE
function onCreated() {
this.onAddMessage("Welcome to [Dunno...]" SPC player.nick @ "!", "bu", "red");
this.onAddMessage("Message System Test" SPC player.nick @ "!", "bi", "pink");
}

function onActionClientside(m) {
this.onAddMessage(m[0], m[1], m[2]);
}

function onAddMessage(msg, style, color) {
this.msgs.insert(0, {msg, style, color, timevar2 + 5});
this.onDisplayMessages();
}

function onDisplayMessages() {
hideimgs(200, 230);
for (temp.i: this.msgs) {
temp.p = {screenwidth / 2, screenheight - 45 - (temp.c * 18)};
temp.n = showtext(200 + temp.c, p[0], p[1], "", i[1] @ "c", i[0]);
temp.n.layer = 4;
temp.n.zoom = 0.6;
temp.c++;
}

setTimer(1);
}

function onTimeout() {
if (this.msgs == null) return;

temp.list = this.msgs;
this.msgs = null;
for (temp.i: temp.list) {
if (timevar2 > i[3]) continue;
this.msgs.add(i);
}
this.onDisplayMessages();
setTimer(0.5);
}

I didn't finish the color part, but here's the basic. It'll display the message in the middle of the screen (at the bottom). ^^