PDA

View Full Version : Mini map


DustyPorViva
07-31-2007, 09:15 PM
Here's a little minimap I made. The options are in the onCreated() function.
Just for note, by bottom-right-most level, I mean the .nw filename of the level in the bottomright corner of the map. This helps determine the maps maxsize. This only works if the levels are loaded in a gmap.
function onActionserverside() {
if (params[0]=="indoor") {
for (pl: allplayers) pl.triggerclient("gui",name,"indoor",params[1]);
}
if (params[0]=="removehead") {
for (pl: allplayers) pl.triggerclient("gui",name,"removehead",params[1]);
}
}

//#CLIENTSIDE

function onCreated() {
this.mapimg="vs_map.png"; // FULL SIZE map image name(same image used for big maps, NOT mini-maps)
this.BRlevel="vs_world-c3.nw"; // Filename of the bottom-right-most level
this.mapsize=120; // Desired size of the mini-map to be shown(NOT the size of the mini-map image)

new GuiScrollCtrl("Mapback") {
profile=GuiBlueScrollProfile;
width=height=thiso.mapsize;
x=20;
y=screenheight-(Mapback.height+40);
hScrollBar=vScrollBar="alwaysOff";
useOwnProfile=true;
profile.transparency=0;
profile.border=1;
profile.borderthickness=1;

new GuiShowImgCtrl("Mapimg") {
image=thiso.mapimg;
mode=1;
red=blue=green=.95;
alpha=.85;
x=0;
y=0;
width=getimgwidth(this.image);
height=getimgheight(this.image);
}
}
onTimeout();
}

function onPlayerenters() {
if (player.gmap==null) {
Mapimg.clearcontrols();
triggerserver("gui",name,"indoor",player.account);
Mapimg.hide();
} else Mapimg.show();
Mapback.active=false;
onTimeout();
}

function onTimeout() {
//Mapback.y=(ChatBar.visible==1?ChatBar.y:screenheig ht)-(Mapback.height+20);
temp.scroll={int((player.x/((getmapx(this.BRlevel)+1)*64))*(Mapimg.width-Mapback.width+2)),int((player.y/((getmapy(this.BRlevel)+1)*64))*(Mapimg.height-Mapback.height+2))};
Mapback.scrollto(temp.scroll[0],temp.scroll[1]);

if (player.gmap!=null) showhead(player.account,player.headimg,player.x,pl ayer.y,player.dir);
for (pl: allplayers) {
if (pl.gmap!=null) showhead(pl.account,pl.headimg,pl.x,pl.y,pl.dir);
}
("Head_" @ player.account).bringtofront();

setTimer(0.05);
}

function showhead(mapaccount,head,onmapx,onmapy,headdir) {
temp.headloc={int((onmapx/((getmapx(this.BRlevel)+1)*64))*Mapimg.width),int( (onmapy/((getmapy(this.BRlevel)+1)*64))*Mapimg.height)};
with("Mapimg") {
new GuiShowImgCtrl("Head_" @ mapaccount) {
image=head;
x=temp.headloc[0]-12;
y=temp.headloc[1]-12;
party=headdir*32;
parth=partw=32;
zoom=.5;
mode=1;
alpha=mapaccount==player.account?1:.65;
width=height=32;
layer=4;
}
}
}

function onActionclientside() {
if (params[0]=="indoor") {
if (params[1]!=player.account) ("Head_" @ params[1]).zoom=.25;
}
if (params[0]=="removehead") {
if (params[1]!=null && params[1]!=player.account) ("Head_" @ params[1]).destroy();
}
}


And this bit needs to be in the Control-NPC:

function onPlayerLogout() {
for (pl: allplayers) pl.triggerclient("gui","-minimap","removehead",params[0]);
}


And a screencap(may be faint, but you can see someone else on there)

theHAWKER
07-31-2007, 11:34 PM
:O nice job :D