Selection
3 Attachment(s)
PHP Code:
//#CLIENTSIDE
function onMouseDown(key) {
if (!(key in {"left", "right"})) return;
this.("on" @ key @ "Click")();
}
function onLeftClick() {
this.ns = {mousescreenx, mousescreeny};
this.np = {mousex, mousey};
setTimer(0.05);
}
function onRightClick() {
if (this.list == null) return true;
this.list = null;
this.onClearPeople();
}
function onTimeout() {
if (!mousebuttons) {
this.onSearch({mousex, mousey});
return;
}
showpoly(200, {
this.ns[0], this.ns[1],
mousescreenx, this.ns[1],
mousescreenx, mousescreeny,
this.ns[0], mousescreeny
});
changeimgvis(200, 4);
changeimgcolors(200, 0, 0, 0, 0.4);
setTimer(0.05);
}
function onSearch(mp) {
hideimg(200);
temp.c = this.np; //origional mx/my
temp.p = {mp[0] - c[0], mp[1] - c[1]};
if (p[0].starts("-")) {
temp.s = {{mp[0], c[1]}, {c[0], mp[1]}};
if (p[1].starts("-")) {
temp.s = {mp, c};
}
} else {
temp.s = {c, mp};
if (p[1].starts("-")) {
temp.s = {{c[0], mp[1]}, {mp[0], c[1]}};
}
}
temp.pl = findnearestplayers(s[0][0], s[0][1]);
for (temp.p: pl) {
if (!(p.x in |s[0][0], s[1][0]|)) continue;
if (!(p.y in |s[0][1], s[1][1]|)) continue;
temp.list.add(p);
}
if (temp.list == null) return;
this.list = temp.list;
this.onDisplayPeople();
}
function onDisplayPeople() {
this.onClearPeople();
temp.pos = {0, 100};
temp.ext = {150, (32 * this.list.size())};
with (findimg(201)) {
polygon = {pos[0], pos[1],
pos[0] + ext[0], pos[1],
pos[0] + ext[0], pos[1] + ext[1],
pos[0], pos[1] + ext[1]};
layer = 4;
mode = 2;
alpha = 0.5;
}
for (temp.p: this.list) {
temp.ypos = (pos[1] + ((thiso.imgcount - 1) * 32));
//Head
with(findimg(201 + this.imgcount)) {
image = p.headimg;
x = pos[0];
y = ypos;
layer = 5;
partw = 32; parth = 32; partx = 0; party = 64;
}
//Account
with(findimg(206 + this.imgcount)) {
text = p.nick.substring(0, 17);
x = pos[0] + 35;
y = ypos;
zoom = 0.6;
layer = 5;
}
//HP&MP
for (temp.i = 0; temp.i < 2; temp.i++) {
with(findimg((211 + (i + 1) * 6) + + this.imgcount)) {
image = "c_gui-bar" @ i @ ".png";
layer = 5;
x = pos[0] + 35;
y = ypos + 14 + (i * 8);
}
}
this.imgcount++;
if (this.imgcount > 5) break;
}
}
function onClearPeople() {
hideimgs(200, 225 + this.imgcount);
this.imgcount = 1;
}
It's similar to C&C game selection, but it works for players! I was originally going to make a staff system with it, but as an example this one shows the selected players health points on the left hand side. It's quite fun ^^
|