English return 1 NOT working

2 replies
Goto Page
To the start Previous 1 Next To the start
16.04.17 07:31:41 pm
Up
Hidder
BANNED
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("say","sayra")
function sayra(id,txt)
if txt == "!rs" then
if (player(id,"score")>0) or (player(id,"deaths")>0) then
parse("setscore "..id.." 0")
parse("setdeaths "..id.." 0")
msg2(id,"\169000255000Score reset successful")
return 1
else
msg2(id,"\169255000000Score is already reset")
return 1
end
end
if txt == "!ras" then
msg2(id,"\169255255255Name:".."\169255255000 ras")
msg2(id,"\169255255255USGN:".."\169255255000 5q235213")
msg2(id,"\169255255255Status:".."\169255255000 Professional")
return 1
end
end


why its not work
16.04.17 07:38:57 pm
Up
DC
Admin
Offline Off
Did you add multiple functions to the say hook?
You can check the console right after starting a server to see if this is the case.

If yes you need to work with priorities or combine the functions to one function.

Read "Hook Priority (Optional)" at cs2d lua cmd addhook
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
16.04.17 07:53:43 pm
Up
GeoB
Moderator
Offline Off
Your code has a needless
return
keyword (8 line), keep in mind
return 1
(which hides the text) should be used when the player is writing a command or any text based on the code and not for
msg2()
.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function sayra(id,txt)
   if txt == "!rs" then
      if (player(id,"score")>0) or (player(id,"deaths")>0) then
         parse("setscore "..id.." 0")
         parse("setdeaths "..id.." 0")
         msg2(id,"\169000255000Score reset successful")
      else
         msg2(id,"\169255000000Score is already reset")
      end
      return 1
   end

   if txt == "!ras" then
      msg2(id,"\169255255255Name:".."\169255255000 ras")
      msg2(id,"\169255255255USGN:".."\169255255000 5q235213")
      msg2(id,"\169255255255Status:".."\169255255000 Professional")
      return 1
   end
end

addhook("say","sayra")

Tip: ALWAYS tab your code, it makes things clear and easily to read it.
To the start Previous 1 Next To the start