Forum

> > CS2D > Scripts > coordinate X Y error
Forums overviewCS2D overview Scripts overviewLog in to reply

English coordinate X Y error

5 replies
To the start Previous 1 Next To the start

old coordinate X Y error

LifeIsCat27
User Off Offline

Quote
Hi i want to make a script with say request.

But error when you say:
!as 10 5
the msg2 says:
Confirmed
Air Support At X:10 Y:10
The Y always The X coordinate
Whats wrong?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
addhook("say","ASRequest")
function ASRequest(id,txt,x,y)
	local str = string.len("!as")
	if string.sub(txt,1,str)=="!as" then
		if AS[id] >= 1 then
			ASX[id] = tonumber(string.sub(txt,str+1,str+3))
			ASY[id] = tonumber(string.sub(txt,str+2,str+3))
			if ASX[id]>0 and ASY[id]>0 and ASX[id]<map([[xsize]])*32 and ASY[id]<map([[ysize]])*32 then
				msg2(id,"©000255000Confirmed")
				msg2(id,"©000255000Air Support At X:"..ASX[id].." Y:"..ASY[id].."")
			else
				msg2(id,"©255000000Error: Coordinate Is Out Of Map!")
			end
		else 
			msg2(id,©255000000"Error: You Didnt have Air Support!")
		end
	end
end

old Re: coordinate X Y error

Cure Pikachu
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function totable(t,match) -- Will be needing this function
	local cmd = {}
	if not match then
		match = "[^%s]+"
	else
		match = "[^"..match.."]+"
	end
	for word in string.gmatch(t,match) do
		table.insert(cmd,word)
	end
	return cmd
end

addhook("say","ASRequest")
function ASRequest(id,txt)
	local s = totable(txt)
	local t1 = string.lower(tostring(s[1]))
	if t1 == "!as" then
		if AS[id] >= 1 then
			ASX[id] = tonumber(s[2])
			ASY[id] = tonumber(s[3])
			if ASX[id]>0 and ASY[id]>0 and ASX[id]<map("xsize")*32 and ASY[id]<map("ysize")*32 then
				msg2(id,"©000255000Confirmed")
				msg2(id,"©000255000Air Support At X:"..ASX[id].." Y:"..ASY[id].."")
			else
				msg2(id,"©255000000Error: Coordinate Is Out Of Map!")
			end
		else 
			msg2(id,©255000000"Error: You don't have Air Support!")
		end
	end
end
(Updated: I missed out something.)
edited 2×, last 22.04.12 07:45:23 am

old Re: coordinate X Y error

LifeIsCat27
User Off Offline

Quote
Pikachu your script errors
1
LUA ERROR: sys/lua/airsupport.lua:20: bad argument #1 to 'gmatch' (string expected, got nil)
edited 1×, last 22.04.12 06:35:28 am

old Re: coordinate X Y error

EP
User Off Offline

Quote
ahh.. i made a script like that 3 months ago, i will give you it :
Spoiler >
that wasn't what you needed, it's what you need
Spoiler >
. you must change the AS state (true-false) to able the player to get air support
edited 1×, last 22.04.12 03:41:26 pm

old Re: coordinate X Y error

LifeIsCat27
User Off Offline

Quote
Now i got different problem
1
LUA ERROR: sys/lua/BattleSupport.lua:79: attempt to concatenate field '?' (a nil value)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
addhook("say","ASRequest")
function ASRequest(id,txt,x,y)
	local s = totable(txt)
	local cmd = (s[1])
	if cmd == "!sd" then
		if SD[id] == true then
			ASX[id] = tonumber(s[2])
			ASY[id] = tonumber(s[3])
			PACK[id] = tonumber(s[4])
			if ASX[id]>0 and ASY[id]>0 and ASX[id] < map"xsize" and ASY[id] < map"ysize" then
				if PACK[id] == 1 then
					msg2(id,"©000255000Confirmed")
					msg2(id,"©000255000Supply Drop At X:"..ASX[id].." Y:"..ASY[id].." Package:"..PACK[id].." ")
					timer(5000,"supplydrop",id)
					SD[id] = false
				else
					msg2(id,"©255000000Denied, Pack Id Doesnt Exist!")
				end
			else
				msg2(id,"©255000000Denied, Coordinate is out of map!")
			end
		else
			msg2(id,"©255000000Denied, You don't have Supply Drop!")
		end
	return 1
	end
end

function supplydrop(id)
	if PACK[id] == 1 then
		parse("spawnitem 32 "..ASX[id].." "..ASY[id]) -- Line 79
	end
end

What does it means?
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview