Forum

> > CS2D > Scripts > Drop hook
Forums overviewCS2D overview Scripts overviewLog in to reply

English Drop hook

5 replies
To the start Previous 1 Next To the start

old Drop hook

_Vava_
User Off Offline

Quote
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

old Re: Drop hook

Mami Tomoe
User Off Offline

Quote
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
More >
edited 1×, last 25.08.16 01:40:56 pm

old Re: Drop hook

GeoB99
Moderator Off Offline

Quote
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.

old Re: Drop hook

Dousea
User Off Offline

Quote
@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

old Re: Drop hook

Mami Tomoe
User Off Offline

Quote
user Dousea has written
@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.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview