Forum

> > CS2D > Scripts > Attack hook error
Forums overviewCS2D overview Scripts overviewLog in to reply

English Attack hook error

6 replies
To the start Previous 1 Next To the start

old Attack hook error

Anders4000
User Off Offline

Quote
I get this error when firing in a game when i use the code in the end of this post:
LUA ERROR: sys/lua/AKD_One in the Champer.lua:47: bad argument #2 to 'player' (string expected, got nil)


1
2
3
4
5
6
7
8
9
10
11
addhook("attack","OnAttack")
function OnAttack(id)
	if(player(id,weapontype)==3) then		--iid 3 = deagle
		Bullets[id] = Bullets[id] - 1
		if Bullets[id] < 1 then
			parse('strip '..id..' 3')
			parse('setweapon '..id..' 50')
		end
	end
	parse('hudtxt2 '..id..' 4 "©000255000Bullets: '..Bullets[id]..'" '..BulletsPos)
end

Any1 knows what's wrong?
- Anders4000

Ps. DC fix those spaces soon. I need to tab trhough it all when i post something

old Re: Attack hook error

TimeQuesT
User Off Offline

Quote
you forgott the "
right :
1
player(id,"weapontype")

and:

there is a specific thread for lua questions/debug i think...

old Re: Attack hook error

J4x
User Off Offline

Quote
replace this
1
if(player(id,weapontype)==3) then
with
1
if wpn == 3

old Re: Attack hook error

TimeQuesT
User Off Offline

Quote
if you do this you need to change the function parameters:
1
OnAttack(id)
to
1
OnAttack(id,source,iid,wpn,whatever)

old Re: Attack hook error

Yasday
User Off Offline

Quote
You can't change the function parameters...
It's attack(id) and nothing more, because it's the attack hook. Then you have to use player(id,"weapontype").
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview