Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Warping while standing at a specific location (https://forums.graalonline.com/forums/showthread.php?t=134266364)

garglius1 05-03-2012 08:44 PM

Warping while standing at a specific location
 
Hi. I have recently taken to making my graal kingdoms house levels, and after reading the guides online, it has been going fairly well. I've come to a point where I can't find the info I need to do exactly what I want to do, so I've come here to ask.

Essentially I have an NPC that looks like this:
PHP Code:

function onPlayerChats() {
  if (
player.chat == "I want out") {
    
player.setlevel2("insidedustari_mainfloor.nw",30.5,4.5);
  }



which works perfectly in warping me from the level it's in to the other level. What I am looking to do though is to make it work only when the player is standing in a specific area (a carpet on my floor) rather than working in the whole room. The coordinates for my carpet are:

top left corner : x= 28.5 y=48.5
top right corner: x=32.5 y=48.5
bottom left corner: x=28.5 y=52
Bottom right corner: x= 32.5 y=52

Essentially I would like it to be so that my warp command only works when standing within these coordinates. Any help and comments appreciated :)

Emera 05-03-2012 09:01 PM

Checking if a player is between the top left and bottom right corner should work.

PHP Code:

if (player.x in 28.548.5 | && player.y in 32.552 |) {
  
//warp player



garglius1 05-03-2012 09:58 PM

I have it looking like this now

PHP Code:

function onPlayerChats() {
if (
player.x in 28.548.5 | && player.y in 32.552 |) {


  if (
player.chat == "I want out") {
    
player.setlevel2("insidedustari_mainfloor.nw",30.5,4.5);
  }
}


and it still warps me wherever I am in the level.

Emera 05-03-2012 10:18 PM

I find it hard to work simple maths problems out, so I'll explain how to do it. Work out the distance from top left corner to top right and then the bottom left to the top left. I think that'll give me the numbers I need.

cbk1994 05-03-2012 10:21 PM

Quote:

Originally Posted by Emera (Post 1693617)
I find it hard to work simple maths problems out, so I'll explain how to do it. Work out the distance from top left corner to top right and then the bottom left to the top left. I think that'll give me the numbers I need.

Why do you need distance? The solution you posted already will work just fine. If it's not working for garglius, then something else is going on.

edit: you entered the wrong coordinates

PHP Code:

player.x in |28.532.5| && player.y in |48.552


garglius1 05-03-2012 10:26 PM

1 Attachment(s)
I've put a picture of the grey 'carpet' I want to be able to warp on with the measures around it. Top left to top right is 4, top left to bottom left is 3.5

Emera 05-03-2012 10:58 PM

Quote:

Originally Posted by cbk1994 (Post 1693618)
Why do you need distance? The solution you posted already will work just fine. If it's not working for garglius, then something else is going on.

edit: you entered the wrong coordinates

PHP Code:

player.x in |28.532.5| && player.y in |48.552


I had a suspicion that I entered the wrong coordinates, but when I sat down to try and work it out my brain refused to cooperate lol. Thanks for posting the correct coords.


All times are GMT +2. The time now is 04:39 PM.

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