Forum

> > CS2D > Scripts > Where is my Mistake? Tile & Menu
Forums overviewCS2D overview Scripts overviewLog in to reply

English Where is my Mistake? Tile & Menu

5 replies
To the start Previous 1 Next To the start

old Where is my Mistake? Tile & Menu

limonata
User Off Offline

Quote
Hi, this script doesnt work, please tell me my mistake thanks.

Script:

1
2
3
4
5
6
7
8
9
addhook("move","mypos")
function mypos(id)
	local px = player(id,"tilex")	
	local py = player(id,"tiley")
	--parse('hudtxt2 ..id.. 10 "©000255000X='..x..' Y='..y..'" 13 430 0')
	if px == 1425 and py == 500 then
		menu(id,"Glow Menu,Red,Blue,Green,Yellow,Cyan,White,Aqua,Black,Next Page >>")
	end
end

old Re: Where is my Mistake? Tile & Menu

Yates
Reviewer Off Offline

Quote
None. This script works fine, your if statement must ask for the wrong x y because nothing produces an error.

I also recommend you use movetile instead. Otherwise the menu will open every pixel you move on the tile you are asking for.

old Re: Where is my Mistake? Tile & Menu

limonata
User Off Offline

Quote
Thanks, there is no error but menu doesnt open. I will change it with 'movetile'

Edit:// Thanks yates it worked with movetile hook.

Problem solved.
edited 1×, last 01.05.14 10:26:26 am

old Re: Where is my Mistake? Tile & Menu

VADemon
User Off Offline

Quote
1) You will never (almost) match the exact position in pixels
2) You must round the position to get an integer (14|20 instead 14.234325043 | 20.2143249032590)
>> math.ceil / math.floor

old Re: Where is my Mistake? Tile & Menu

Dousea
User Off Offline

Quote
@user VADemon:
function math.round (x)
	return math.floor (x + 0.5)
end

@user limonata: px and py returns player's x and y in tiles because:
local px = player(id,"tilex")
local py = player(id,"tiley")
edited 1×, last 01.05.14 04:52:05 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview