Forum

> > CS2D > Scripts > open menu if x,y = "true"
Forums overviewCS2D overview Scripts overviewLog in to reply

English open menu if x,y = "true"

2 replies
To the start Previous 1 Next To the start

old open menu if x,y = "true"

Powermonger
User Off Offline

Quote
Hello scripters,

Sorry that I bother you with such an easy problem.
I just can't figure out how this works.
... dam.

Here's the script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
addhook("use","PMu")
PMPCs = {84,186,83,190}

function PMu(id)
local x = math.floor(player(id,"x")/32)
local y = math.floor(player(id,"y")/32)
if PMpos(id,x,y) == "true" then
	PMPCPmain(id)
end
end

function PMpos(id,x,y)
for k,v in ipairs(PMPCs) do
if x == v and y == PMPCs[v+1] then
	return "true"
end
end
end
Thing is that I want to check if players position pairs with positions on table PMPCs.

Like this:
1
2
3
if (player(id,"x") == 84 and player(id,"x") == 186) or (player(id,"x") == 83 and player(id,"x") == 190) then
	PMPCPmain(id)
end

How can you do that, I am a beginner in scripting so I don't know

old Re: open menu if x,y = "true"

Flacko
User Off Offline

Quote
1
2
3
4
5
6
7
function PMpos(id,x,y)
	for i=1,#PMPCs,2 do
		if x == PMPCs[i] and y == PMPCs[i+1] then
			return true
		end
	end
end
Then replace
1
if PMpos(id,x,y) == "true" then
with
1
if PMpos(id,x,y) then
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview