Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Mini map (https://forums.graalonline.com/forums/showthread.php?t=75995)

DustyPorViva 07-31-2007 08:15 PM

Mini map
 
1 Attachment(s)
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.
PHP Code:

function onActionserverside() {
  if (
params[0]=="indoor") {
    for (
plallplayerspl.triggerclient("gui",name,"indoor",params[1]);
  }
  if (
params[0]=="removehead") {
    for (
plallplayerspl.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:screenheight)-(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!=nullshowhead(player.account,player.headimg,player.x,player.y,player.dir);
  for (
plallplayers) {
    if (
pl.gmap!=nullshowhead(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:
PHP Code:

function onPlayerLogout() {
  for (
plallplayerspl.triggerclient("gui","-minimap","removehead",params[0]);


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

theHAWKER 07-31-2007 10:34 PM

:O nice job :D


All times are GMT +2. The time now is 07:11 PM.

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