Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Making A Gps (https://forums.graalonline.com/forums/showthread.php?t=134264576)

Gunderak 09-17-2011 06:47 AM

Making A Gps
 
Iv made the base script im just wondering how to get the x and y's right and moving here is the base
what im wonding how to do is making the markers x in the centre of the background and the dot centered when the player writes /setgps then when the player moves the dot will move either down up right left or diagonally depending where the player is to where the marker is.
i cant figure out how to make the max dots x and y depending on how big the gmap is and making it only move a tiny bit.
PHP Code:

//#CLIENTSIDE


function onCreated() {
    new 
GuiBitmapCtrl("GPS_Background") {
        
x = 210;
        
y = 10;
        
width = 100;
        
height = 100;
        
bitmap = "GPS_Background.png";
    }
    new 
GuiBitmapCtrl("GPS_Marker") {
        
x = 240;
        
y = 40;
        
width = 10;
        
height = 10;
        
bitmap = "GPS_Marker.png";
    }
    new 
GuiBitmapCtrl("GPS_Dot") {
        
x = 255;
        
y = 55;
        
width = 10;
        
height = 10;
        
bitmap = "GPS_Dot.png";
    }
    new 
GuiTextCtrl("GPS_X") {
        
profile = GuiBlueTextProfile;
        
height = 20;
        
width = 200;
        
x = 315;
        
y = 65;
        
red = 1;
        
green = 1;
        
blue = 1;
    }
    new 
GuiTextCtrl("GPS_Y") {
        
profile = GuiBlueTextProfile;
        
height = 20;
        
width = 200;
        
x = 315;
        
y = 80;
        
red = 1;
        
green = 1;
        
blue = 1;
    }
    
onTimeout();
}

function 
onTimeout() {
    
GPS_X.text = "X:  "@client.gpsx;
    
GPS_Y.text = "Y:  "@client.gpsy;
    
settimer(0.05);
}

function 
onPlayerChats() {
    if (
player.chat == "/setgps") {
        
player.chat = "GPS Marker Set!";
        
client.gpsx = player.x;
        
client.gpsy = player.y;
    }
} 


cbk1994 09-17-2011 06:55 AM

For the nth time, please style your code before posting it in the scripting forums.

If the map is to be 100x100 pixels, and the actual map is 12x12 levels, you can calculate that the map is 768x768 tiles (64 tiles in a row/column per level). http://uploads.graalcenter.org/upload/eqn2004.png is the number of pixels each tile represents on your map horizontally (the same vertically if it's a square).

Then, to figure out where to draw markers,

PHP Code:

function getMarkerPosition(temp.tileX, temp.tileY) {
  return {
    (
100 / 768) * temp.tileX,
    (
100 / 768) * temp.tileY
  
};
} 

All you're doing is multiplying the number of pixels each tile represents, http://uploads.graalcenter.org/upload/eqn2004.png, by the number of tiles.

Gunderak 09-17-2011 06:59 AM

I have to go out on public transport so i finished writing my goal while being on the bus, which i sill am on.
also sorry for not styling it. il try to do so now on my idevice if i can.

jamitsu89 09-19-2011 03:31 AM

Style your code!

*EDIT*
Or I shall become enraged!

Gunderak 09-19-2011 09:48 AM

Quote:

Originally Posted by jamitsu89 (Post 1668576)
Style your code!

*EDIT*
Or I shall become enraged!

lol.


All times are GMT +2. The time now is 04:43 AM.

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