Author Topic: Map gui  (Read 1425 times)

Is it possible to make an item in the inventory open up a gui when its used?
If so would it be possible to make the gui show your current position?

1. Yes
2. You'd just get the player's position relative to the mission area (if the gui's map was in a perfect ratio to the mission area)


function itemNameImage::onFire(%this,%obj,%slot)
{
   if(%obj.getClassName() $= "Player") //Bots can't use it.
   {
      %pos = %obj.position;
      %x = getWord(%pos,0);
      %y = getWord(%pos,1);
      %z = getWord(%pos,2);
      commandToClient(%obj.client,'MessageBoxOK',"Position","You are at X:" SPC %x SPC "Y:" SPC %y SPC "Z:" SPC %z);
   }
}

-code snip-
no i meant open up a gui with a map(image) on it

Code: [Select]
//--- OBJECT WRITE BEGIN ---
$deposy = "PlayerYPos";
$deposx = "PlayerXPoS"
new GuiControl(Map) {
   profile = "GuiDefaultProfile";
   horizSizing = "right";
   vertSizing = "bottom";
   position = "0 0";
   extent = "1024 768";
   minExtent = "8 2";

   visible = "1";

   new GuiWindowCtrl() {
      profile = "GuiWindowProfile";
      horizSizing = "right";
      vertSizing = "bottom";
      position = "583 3";
      extent = "438 438";
      minExtent = "8 2";
      visible = "1";
      maxLength = "255";
      resizeWidth = "1";
      resizeHeight = "1";
      canMove = "1";
      canClose = "1";
      canMinimize = "1";
      canMaximize = "1";
      minSize = "50 50";

      new GuiBitmapCtrl(mapPic) {
         profile = "GuiDefaultProfile";
         horizSizing = "right";
         vertSizing = "bottom";
         position = "-335 -550";
         extent = "1039 938";
         minExtent = "8 2";
         visible = "1";
         bitmap = "./map.png";
         wrap = "0";
      };
      new GuiBitmapCtrl(You) {
         profile = "GuiDefaultProfile";
         horizSizing = "right";
         vertSizing = "bottom";
         position = "215 170";
         extent = "7 7";
         minExtent = "7 2";
         visible = "1";
         bitmap = "./PictureToShowPlayerPosition.png";
         wrap = "0";
      };
//--- OBJECT WRITE END ---
function refresh()
{
%camera = serverConnection.getControlObject();
%pos = %camera.getPosition();
%x = XPos(%pos); 
%y = YPos(%pos);
mapPic.position = %x SPC %y; 
        schedule(200,0,'refresh2');
}

function refresh2()
{
%camera = serverConnection.getControlObject();
%pos = %camera.getPosition();
%x = XPos(%pos); 
%y = YPos(%pos);
mapPic.position = %finposx SPC %finposy; 
        schedule(500,0,'refresh2');
}

function XPos(%pos)
{
%posx = getWord(%pos,0); // Using local instead of global...
%posx2 = (%posx / 2.7) - (%posx / 2.7) - (%posx / 2.7); // Longer but it makes more sense to me.
%finposx = %posx2 + $deposx;
return %finposx;
}

function YPos(%pos)
{
%posy = getWord(%pos,1);
%posy2 = (%posy / 2.7) - (%posy / 2.7) - (%posy / 2.7);
%finposy = %posy2 + %deposy;
return %finposy;
}
Try something off of this.


The client has to download that.
Not a bad thing, but keep it in mind.

Jimmg, your missing two closing brackets with semi-colons  write above the "//--- OBJECT WRITE END ---".

Jimmg, your missing two closing brackets with semi-colons  write above the "//--- OBJECT WRITE END ---".
I didnt say I would give it to him working fully did I ?

I didnt say I would give it to him working fully did I ?
Oh, I see what you did there. Well, even if he managed to add the brackets, I doubt he could figure out how to open it up, toggle the schedule, add his own images and what not.

It doesnt work fully anyhow never could figure out how to get the y to work.

It doesnt work fully anyhow never could figure out how to get the y to work.
Is that why your name is Jimmg?