Forum

> > CS2D > Scripts > Why error safezone
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Why error safezone

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Why error safezone

pbeloto
User Off Offline

Zitieren
Hi us

plz why error line

1
if (tilex >= i[1][1] and tilex <= i[2][1]) and (tiley >= i[1][2] and tiley <= i[2][2]) then

error conssole

1
2
LUA ERROR: sys/lua/safezone.lua:24: attempt to compare number with bool
ean


script
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
addhook("hit", "_hit")
addhook("movetile", "_movetile")

function _hit(id,pl)
	if _safezone(id) then
		return 1;
	elseif _safezone(pl) then
		return 1;
	end
end

function _movetile(id,x,y)
	if _safezone(id) then
		parse('hudtxt2 '..id..' 11 "'..t_color["azulm"]..'SAFE ZONE" 320 200 1');
	elseif not _safezone(id) then
		parse('hudtxt2 '..id..' 11 ""');
	end
end

function _safezone(id)
	local tilex = player(id,"tilex");
	local tiley = player(id,"tiley");
	for _, i in pairs(safezones) do
		if (tilex >= i[1][1] and tilex <= i[2][1]) and (tiley >= i[1][2] and tiley <= i[2][2]) then
			return true;
		end
	end
	return false;
end

alt Re: Why error safezone

KimKat
GAME BANNED Off Offline

Zitieren
I'm not all too sure what might be causing this error, someone else might have the answer though. The Lua script seems to compare a number within your multi dimension array (which is not visible in the code snippet) with a boolean value.

A boolean value is basically (true/false or 1/0). That's all I can tell from this Lua script currently.

alt Re: Why error safezone

MikuAuahDark
User Off Offline

Zitieren
make sure that variable i with index 1 or 2(multi) doesn't give a boolean value. you can try to debug your script by put this script
1
print(tostring(i[1][2]))
below
1
for _, i in pairs(safezones) do

Make sure to use all possible index

Also only if you want, you can post the safezones table

alt Re: Why error safezone

mozilla1
User Off Offline

Zitieren
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
safe = {}

for _,e in pairs(entitylist()) do
	if entity(e.x,e.y,"typename") == "Env_Hurt" and entity(e.x,e.y,"int0") == -100 and entity(e.x,e.y,"int1") == 2 then
		local x=e.x
		local y=e.y
		local x2=(e.x-1)+entity(e.x,e.y,"int2")
		local y2=(e.y-1)+entity(e.x,e.y,"int3")
		
		table.insert(safe,{x,x2,y,y2})
	end
end

function init_array(length,mode)
	local array = {}
	for i = 1,length do 
		array[i] = mode	
	end
	return array
end

player_safe = init_array(32,false)

addhook("movetile","movetile")
addhook("hit","hit")

function hit(id,)
	if player_safe[id] then
		return 1
	end
	return 0
end

function movetile(id,x,y)
	for i in ipairs(safe) do
		if x >= safe[i][1] and x <= safe[i][2] and y >= safe[i][3] and y <= safe[i][4] then
			player_safe[id] = true
			break
		else
			player_safe[id] = false
		end
	end	
	update_hud(id)
end

function update_hud(id)
	if player_safe[id] then
		parse("hudtxt2 "..id.." 1 \"SAFE ZONE\" 318 200 1")
	else
		parse("hudtxt2 "..id.." 1 \"\" 300 210 0")
	end
end


Put an "Env_Hurt" entity with -100 and both.
See ya.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht