Forum

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

Englisch Drop hook

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Drop hook

_Vava_
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
addhook("drop","ondrop")
function drop(id,iid,type)
if player(id,"team")==2 then
if type==51 then
parse('hudtxt2 '..id..' 0 "" 290 205 0')
end
end
end
Hi all can some one help me in this x) i don't know why it's not working

alt Re: Drop hook

Mami Tomoe
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
addhook("drop","ondrop")
function ondrop(id,iid,type) --You need to name it like you named it on the hook
	if player(id,"team")==2 then
		if type==51 then
			parse('hudtxt2 '..id..' 0 "your text" 290 205 0')
		end
	end
end

You had 2 issues:
• You didn't enter a message in the HUDTXT command
• You didn't name the function properly
• Also consider tabbing your code like I did it only makes it easier
Mehr >
1× editiert, zuletzt 25.08.16 13:40:56

alt Re: Drop hook

GeoB99
Moderator Off Offline

Zitieren
The problem is pretty self-explanatory. The hook name cs2d lua hook drop is reserved thus you're not able to use it as a function identifier. ondrop at contrary is the function name that you should use for your function! I hope this is what you're referring about.

• Edit 1: Got ninja'd.

alt Re: Drop hook

Dousea
User Off Offline

Zitieren
@user GeoB99: There's no cs2d lua hook drop identifier at all. It's not a reserved word so you can use it as the function's name.

@user Mami Tomoe: I believe that you can show an empty HUD text.

I bet you were having
attempt to call a nil value
error. Please remember this when you're making a function for a hook: you need to make sure that the function's name in the
addhook
and declaration of the function are the same.
1
2
3
4
5
addhook("<hook>", "<function>") 

function <function>(...)
	...
end

alt Re: Drop hook

Mami Tomoe
User Off Offline

Zitieren
user Dousea hat geschrieben
@user Mami Tomoe: I believe that you can show an empty HUD text.


Yeah but then he will wonder why he doesn't see anything so that's why I added that note.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht