English have detected error on my head and showdamage lua

5 replies
Goto Page
To the start Previous 1 Next To the start
Up
haha1955
User
Offline Off
hi guys,
i have detected 2 error on my scripts and need help to fix that.

Code:
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>'


Code:
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>'


Code:
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)


Code:
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
31.12.19 10:55:18 pm
Up
TrialAndError
User
Offline Off
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
01.01.20 05:48:36 am
Up
Man Of Steel
User
Offline Off
Revenge bro
These scripts are working fine.

You can't fix them here, you have to paste full script of show damage and head here.

So don't share any script here
I'll guide you on discord
FRiendly boYy.
01.01.20 10:25:13 am
Up
Hajt
User
Offline Off
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:
Code:
1
2
3
if source == 0 then
     return
end
Yooo. We are playing mix matches 5on5 in evening hours on the server CS2D.TK | Mix/Match, you can join us, server password is match. Statistics, leaderboard can be found under the following link.
01.01.20 01:54:35 pm
Up
haha1955
User
Offline Off
for the showdamage idk if is working, i cant see a error or something

@user TrialAndError: add this so?

Code:
1
2
3
original: player(id, "x")

edited by me: player(id, "0") or player(id, "nil")
01.01.20 03:41:12 pm
Up
TrialAndError
User
Offline Off
I said that the player function returns false when the id is 0, nil or an id that doesn't exist, not the value. Do as Hajt said and make sure the source isn't equal to 0 when you compare
To the start Previous 1 Next To the start