Forum

> > CS2D > Scripts > have detected error on my head and showdamage lua
Forums overviewCS2D overview Scripts overviewLog in to reply

English have detected error on my head and showdamage lua

5 replies
To the start Previous 1 Next To the start

old have detected error on my head and showdamage lua

haha1955
User Off Offline

Quote
hi guys,
i have detected 2 error on my scripts and need help to fix that.

1
2
3
LUA ERROR: sys/lua/hc/core/showdamage.lua:22: attempt to perform arithmetic on field '?' (a nil value)
 -> sys/lua/hc/core/showdamage.lua:22: in function <sys/lua/hc/core/showdamage.lua:20>
 -> in Lua hook 'hit', params: '©255000000 -> sys/lua/hc/core/showdamage.lua:22: in function <sys/lua/hc/core/showdamage.lua:20>'

1
2
3
LUA ERROR: sys/lua/awp/head.lua:28: attempt to perform arithmetic on a boolean value
 -> sys/lua/awp/head.lua:28: in function <sys/lua/awp/head.lua:25>
 -> in Lua hook 'hit', params: '©255000000 -> sys/lua/awp/head.lua:28: in function <sys/lua/awp/head.lua:25>'

1
2
3
4
5
6
7
8
my head lua:

function onhit(id,source,weapon,hpdmg,apdmg)
	local accuracy1 = 0
	local accuracy2 = 0
	local difx = player(id,"x") - player(source,"x")
	local dify = player(id,"y") - player(source,"y")
	local goang = math.atan2(dify,difx)

1
2
3
4
5
6
7
8
9
my showdamage lua:

function hitshake(id,src,wpn,hp)
	if hp > 0 then
		sd.damage[src] = sd.damage[src] + hp
		sd.show(src)
		sd.showtimer[src] = 10
	end
	end

old Re: have detected error on my head and showdamage lua

TrialAndError
User Off Offline

Quote
I believe
player(id, "x")
returns false if it doesn't find a user with that id. So I am assuming either id or source is probably
0
or
nil
.

Same thing with
sd.damage[src]
. If there is no data at position "src" in the sd.damage, it will return nil. So you cant perform any addition on a nil value

old Re: have detected error on my head and showdamage lua

Hajt
User Off Offline

Quote
When bomb explodes it triggers hit hook with source parameter 0 so script want to storage something in sd.damage[0] that's why this error happens. Use it after function line:
1
2
3
if source == 0 then
	return
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview