Hide text after command
11 replies



26.05.18 07:21:54 pm
Hi, i don't know why text - !help reveals itself with !help cmd
I need a answer how to hide text !help after i enter this
because return is not working
Code:
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
addhook("say","say_help")
function say_help(id,txt)
if(txt=="!help") then
msg2(id,"Commands:")
msg2(id,"©100255100!asdasd - allasdas")
msg2(id,"©100255100!asdas - asdasd")
msg2(id,"©100255100!asdasd - sasd")
msg2(id,"©100255100!asdasd - asdasdasdasd")
msg2(id,"©100255100!iasdasdasd - casda")
return 1
end
end
function say_help(id,txt)
if(txt=="!help") then
msg2(id,"Commands:")
msg2(id,"©100255100!asdasd - allasdas")
msg2(id,"©100255100!asdas - asdasd")
msg2(id,"©100255100!asdasd - sasd")
msg2(id,"©100255100!asdasd - asdasdasdasd")
msg2(id,"©100255100!iasdasdasd - casda")
return 1
end
end
I need a answer how to hide text !help after i enter this
because return is not working
it works, must be some other part of your script interfering.
Best match: https://www.youtube.com/watch?v=je2Q2XR2Zys
Code:
Try this. 1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
addhook("say","say_help", 1)
function say_help(id,txt)
if(txt=="!help") then
msg2(id,"Commands:")
msg2(id,"©100255100!asdasd - allasdas")
msg2(id,"©100255100!asdas - asdasd")
msg2(id,"©100255100!asdasd - sasd")
msg2(id,"©100255100!asdasd - asdasdasdasd")
msg2(id,"©100255100!iasdasdasd - casda")
return 1
end
end
function say_help(id,txt)
if(txt=="!help") then
msg2(id,"Commands:")
msg2(id,"©100255100!asdasd - allasdas")
msg2(id,"©100255100!asdas - asdasd")
msg2(id,"©100255100!asdasd - sasd")
msg2(id,"©100255100!asdasd - asdasdasdasd")
msg2(id,"©100255100!iasdasdasd - casda")
return 1
end
end
edited 1×, last 26.05.18 10:39:24 pm
Shit your pants:
Outlast II Mod (29) | Create your UI faster: CS2D UI Framework


yea, its work, but for only one say command
other cmds can be seen
other cmds can be seen
edited 1×, last 27.05.18 08:37:09 pm
You mean "!help" is not the only command and there are more than that?
Well, let me guess, you probably created
say hooks for each command and this is what causes this situation.
Reduce the
say hooks to single and try to gather all the commands in it. This way we also will keep the spaciousness and intelligibility.
That'd be something like this:
Besides, we'll not need to use priority for hooks (not a big deal).
Well, let me guess, you probably created

Reduce the

That'd be something like this:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("say","say_help")
function say_help(id,txt)
if txt:sub(1,1) == "!" then
local cmd = txt:sub(2)
if cmd == "help" then
elseif cmd == "admin" then
elseif cmd == "kill" then
end
return 1
end
end
function say_help(id,txt)
if txt:sub(1,1) == "!" then
local cmd = txt:sub(2)
if cmd == "help" then
elseif cmd == "admin" then
elseif cmd == "kill" then
end
return 1
end
end
Besides, we'll not need to use priority for hooks (not a big deal).
Shit your pants:
Outlast II Mod (29) | Create your UI faster: CS2D UI Framework


Try this
Code:
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
addhook("say","say0")
function say0(id,txt)
if txt == "!help" then
msg2(id,"Commands:")
msg2(id,"\169100255100!test")
return 1
end
end
function say0(id,txt)
if txt == "!help" then
msg2(id,"Commands:")
msg2(id,"\169100255100!test")
return 1
end
end
JENKO
Quote:
But i wonder why its bug when there is more then one say hook
[u=http://www.cs2d.com/help.php?luacmd=addhook]Priority[/u]
sys/lua/info.txt has written:
Priority is only important if there is more than one function attached to the same hook!
Default is 0, higher numbers = higher priority, lower numbers (also negative) = lower priority.
The attached function with the HIGHEST priority is the LAST function which will be executed.
Moreover CS2D will take the return value of this function (if there is any)!
In most cases you will just omit the priority parameter (yes, it is [optional])!
Default is 0, higher numbers = higher priority, lower numbers (also negative) = lower priority.
The attached function with the HIGHEST priority is the LAST function which will be executed.
Moreover CS2D will take the return value of this function (if there is any)!
In most cases you will just omit the priority parameter (yes, it is [optional])!
Not a bug as much as it is a limitation of CS2D's Lua engine.


Yes, it's not a bug. It's like that by design. Just think about it: If there are multiple say hooks CS2D simply does not know which return value it should use. There might be hooks which return 1 but also others with other return values. Which is the value which should change the behavior in the end? CS2D just can't decide automatically here.
You can tell CS2D which value to use by using the priority system.
But like
Masea said the easiest approach is to put everything into one single hook.
There are also other approaches to tackle this problem. E.g.
add a say hook with priority -1 which sets a global variable
add a say hook with priority 1 which just returns that global variable:
now in ALL other say hooks you do NOT specify a priority at all. This way they are executed after your -1 hook but before your 1 priority hook. Also you do not use return 1 but instead you set
Result: You can now add as many say hooks as you want and as soon as ANY of these hooks "returns 1" (sets sayReturn to 1), CS2D will not show the original say text anymore.
CS2D just provides a basic API to interact with the game. Sometimes it makes sense to build something on top of that to make your life easier
You can tell CS2D which value to use by using the priority system.
But like

There are also other approaches to tackle this problem. E.g.

sayReturn = 0
(you can call the variable whatever you like this is just an example)
return sayReturn

sayReturn = 1

CS2D just provides a basic API to interact with the game. Sometimes it makes sense to build something on top of that to make your life easier




