Forum

> > CS2D > Scripts > Attack hook error
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Attack hook error

6 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Attack hook error

Anders4000
User Off Offline

Zitieren
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

alt Re: Attack hook error

TimeQuesT
User Off Offline

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

and:

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

alt Re: Attack hook error

TimeQuesT
User Off Offline

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

alt Re: Attack hook error

Yasday
User Off Offline

Zitieren
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").
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht