Forum

> > CS2D > Scripts > Turn Hook = Off
Forums overviewCS2D overview Scripts overviewLog in to reply

English Turn Hook = Off

7 replies
To the start Previous 1 Next To the start

old Turn Hook = Off

Cons
User Off Offline

Quote
Hi guys, help if you can.

Can you tell me how to disable a hook? Like:

1
2
3
4
5
6
7
8
9
10
11
if buton==1 then
addhook("say","dresacolor")
function dresacolor(id,txt)
    msg("©255098255"..player(id,"name").." »Admiin«: "..txt)
return 1
end
end
elseif buton==2 then
"THIS BUTTON DISABLE OR TURN OFF HOOK: dresacolor"
end
end

Please?

old Re: Turn Hook = Off

Bowlinghead
User Off Offline

Quote
I dont think...

But something like that works maybe:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
enable=0
addhook("serveraction","sa")
function sa(id,b)
	if b==1 then
		menu(id,"Menu,Disable,Enable")
	end
end

addhook("menu","lolol")
function lolol(id,t,b)
 if t=="Menu" then
	if b==1 then
		enable=0
	elseif b==2 then
		enable=1
	end
 end
end


addhook("say","dresacolor") -- HERE IS THE HOOK YOU CAN DISABLE/DISABLE
function dresacolor(id,txt)
	if enable==1 then
		-- Your code when its enabled
	else
		-- Your code when its disabled
	end
end

old Re: Turn Hook = Off

Cons
User Off Offline

Quote
user Bowlinghead has written
I dont think...

But something like that works maybe:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
enable=0
addhook("serveraction","sa")
function sa(id,b)
	if b==1 then
		menu(id,"Menu,Disable,Enable")
	end
end

addhook("menu","lolol")
function lolol(id,t,b)
 if t=="Menu" then
	if b==1 then
		enable=0
	elseif b==2 then
		enable=1
	end
 end
end


addhook("say","dresacolor") -- HERE IS THE HOOK YOU CAN DISABLE/DISABLE
function dresacolor(id,txt)
	if enable==1 then
		-- Your code when its enabled
	else
		-- Your code when its disabled
	end
end


Wtf? Oo

Dont We have something like
1
==False

Or something like that?

old Re: Turn Hook = Off

Bowlinghead
User Off Offline

Quote
You can use true and false if you want.
There is a big difference between 1 and 0 or true and false but in this script its no matter.

EDIT:
Use DCs version. I think its better!

old Re: Turn Hook = Off

Cons
User Off Offline

Quote
user DC has written


I saw, i tryed to learn, i tested it, i executed it... And=== Big Fail...

Can you please give me an Example?

old Re: Turn Hook = Off

EngiN33R
Moderator Off Offline

Quote
The thing about DC's solution is that it disables the say hook completely. Any function attached to that hook will not be executed upon the hook's action. Here's what you could do:

1
2
3
4
5
if button==1 then
	addhook("say","dresacolor")
elseif button==2 then
	freehook("say","dresacolor")
end

@user Bowlinghead: In situations where there's a yes/no variable, it should be a boolean - it's better, more preferable.

old Re: Turn Hook = Off

Cons
User Off Offline

Quote
user EngiN33R has written
The thing about DC's solution is that it disables the say hook completely. Any function attached to that hook will not be executed upon the hook's action. Here's what you could do:

1
2
3
4
5
if button==1 then
	addhook("say","dresacolor")
elseif button==2 then
	freehook("say","dresacolor")
end

@user Bowlinghead: In situations where there's a yes/no variable, it should be a boolean - it's better, more preferable.


Oops, Thanks @user EngiN33R: , Always helping me
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview