Forum

> > CS2D > Scripts > Turn Hook = Off
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Turn Hook = Off

7 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Turn Hook = Off

Cons
User Off Offline

Zitieren
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?

alt Re: Turn Hook = Off

Bowlinghead
User Off Offline

Zitieren
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

alt Re: Turn Hook = Off

Cons
User Off Offline

Zitieren
user Bowlinghead hat geschrieben
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?

alt Re: Turn Hook = Off

Bowlinghead
User Off Offline

Zitieren
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!

alt Re: Turn Hook = Off

Cons
User Off Offline

Zitieren
user DC hat geschrieben


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

Can you please give me an Example?

alt Re: Turn Hook = Off

EngiN33R
Moderator Off Offline

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

alt Re: Turn Hook = Off

Cons
User Off Offline

Zitieren
user EngiN33R hat geschrieben
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
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht