English forgot something in scripting

11 replies
Goto Page
To the start Previous 1 Next To the start
18.10.16 11:04:12 pm
Up
LeaderOfSkills
BANNED
Offline Off
well i know its not big problem but i get some errors and i forgot how to fix it

IMG:https://lh3.googleusercontent.com/0fJpjgcVQWhRwC4KLj1XX_KX4XhVeMU6SD2xBar-yLorTD8jowRJDW6WONqsjrGCvHMo=s170


if i type !rs in chat box
i won't !rs show in chat box
how ?
plz fast help

cuz i am noob in scripting i need to fix this

sry for my bad english hope u get the idea
18.10.16 11:08:32 pm
Up
Yates
Reviewer
Offline Off
IMG:https://cdn.meme.am/instances/500x/54539449.jpg


In the cs2d lua hook say hook
return 1
to disable your chat message being shown in chat, take a look at the documentation.
18.10.16 11:15:47 pm
Up
LeaderOfSkills
BANNED
Offline Off
@user Yates:
didn't work i tried it before i don't know why
18.10.16 11:25:26 pm
Up
Yates
Reviewer
Offline Off
Post code. I don't like shooting in the dark.
18.10.16 11:27:05 pm
Up
Rainoth
Moderator
Offline Off
You got multiple 'return 1' code lines.
18.10.16 11:28:08 pm
Up
Mami Tomoe
User
Offline Off
user LeaderOfSkills has written:
@user Yates:
didn't work i tried it before i don't know why


If you are running more than one script at once combine all of the say hooks, if not make sure the return 1 is at the bottom of the say hook (before end)
It's hard being the best girl in the whole entire world
19.10.16 12:41:21 am
Up
LeaderOfSkills
BANNED
Offline Off
ok lets test this

Code:
1
2
3
4
5
6
7
addhook("say" , "saycommand3")
function saycommand3(id,txt)
   if(txt=="!test") then
   parse("kill "..id.."")
  return 1
end
end


or this

Code:
1
2
3
4
5
6
7
8
9
10
11
testlist = {usgnhere}

addhook("say","testsay")
function testsay(id,txt)
for _, usgn in ipairs(testlist) do
if player(id,'usgn') == usgn then
       msg("©000255000"..player(id,"name").."©255128000 [test]:©000255000 "..txt)
return 1
end
end
end


still not working
19.10.16 12:48:48 am
Up
ExT
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
addhook("say","rs_say")
function rs_say(id,txt)
     if txt == "!rs" then
          parse("setscore "..id.." 0")
          parse("setdeaths "..id.." 0")
          msg2(id,"©255255255Score reset.")
          return 1
     end
end


If not work remove all script you used and use this script
edited 2×, last 19.10.16 01:06:11 am
19.10.16 03:14:32 pm
Up
GeoB99
Moderator
Offline Off
One thing I'll never understand here is people ask for help with a problem on their script(s) BUT don't post the code for troubleshoot. Showing the code saves lots of time everyone of us. At this time I can only go through guessing.

Did you by any chance write two or more times the addhook cs2d lua hook say parameters with the same name? Doing this could also trigger the problem besides of what people mentioned here. Check your code twice carefully. Regarding the two chunk of code you've posted they both work as expected.
19.10.16 04:53:05 pm
Up
LeaderOfSkills
BANNED
Offline Off
this is the code i am using and its not working
Code:
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
29
30
31
32
33
34
35
36
37
38
39
40
41
addhook("say" , "sayhook1")
function sayhook1(id,txt)
   if(txt=="!help") then
     msg2(id,"©000255000!rs")
     msg2(id,"©000255000!kill")
     msg2(id,"©000255000!hats")
     msg2(id,"©000255000!mypos")
     msg2(id,"©000255000!angry")
     msg2(id,"©000255000!kickme")
     msg2(id,"©000255000!armors")
     msg2(id,"©000255000!powers")
     msg2(id,"©000255000!weapons")
   end
   if(txt=="!rs") then
        parse ("setscore "..id.." 0")
        parse ("setdeaths "..id.." 0")
     msg2(id,"©255000000[SERVER]:".."©000255000 Score reseted successful.")
   end
   if(txt=="!kill") then
        parse ("kill "..id.."")
   end
   if(txt=="!kickme") then
        parse ("kick "..id.."")
   end
   if(txt=="!weapons") then
     menu(id,"Weapons Menu 1 / 2,M3|1000$,M4A1|2600$,M249|5000$,,Flamerthrower|16000$,Rocket Launcher|3 Score,RPG Launcher|4 Score,,Next|>>")
   end
   if(txt=="!armors") then
     menu(id,"Armors Menu,Light Armor|3000$,Medium Armor|15000$,Medic Armor|5 Score,Heavy Armor|10 Score,Super Armor|45 Score,,,,Stealth Suit|3000$")
   end
   if(txt=="!powers") then
     menu(id,"Powers Menu,5x Speed|10 Score,Full Healthy|12 Score,,Teleport CT|10 Score,Teleport T|10 Score,,Restart|35 Score,Kill All|40 Score,+1 Score|16000$")
   end
   if(txt=="!hats") then
     menu(id,"Hats Menu 1 / 2,Armor,Gandalf,Marine,Priate,Angel,Devil,Graduation,Party,Next|>>")
   end
   if(txt=="!angry") then
        parse("shake "..id.." 100")
return 1
   end
end


then i changed the return 1 place

Code:
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
29
30
31
32
33
34
35
36
37
38
39
40
41
addhook("say" , "sayhook1")
function sayhook1(id,txt)
   if(txt=="!help") then
     msg2(id,"©000255000!rs")
     msg2(id,"©000255000!kill")
     msg2(id,"©000255000!hats")
     msg2(id,"©000255000!mypos")
     msg2(id,"©000255000!angry")
     msg2(id,"©000255000!kickme")
     msg2(id,"©000255000!armors")
     msg2(id,"©000255000!powers")
     msg2(id,"©000255000!weapons")
   end
   if(txt=="!rs") then
        parse ("setscore "..id.." 0")
        parse ("setdeaths "..id.." 0")
     msg2(id,"©255000000[SERVER]:".."©000255000 Score reseted successful.")
   end
   if(txt=="!kill") then
        parse ("kill "..id.."")
   end
   if(txt=="!kickme") then
        parse ("kick "..id.."")
   end
   if(txt=="!weapons") then
     menu(id,"Weapons Menu 1 / 2,M3|1000$,M4A1|2600$,M249|5000$,,Flamerthrower|16000$,Rocket Launcher|3 Score,RPG Launcher|4 Score,,Next|>>")
   end
   if(txt=="!armors") then
     menu(id,"Armors Menu,Light Armor|3000$,Medium Armor|15000$,Medic Armor|5 Score,Heavy Armor|10 Score,Super Armor|45 Score,,,,Stealth Suit|3000$")
   end
   if(txt=="!powers") then
     menu(id,"Powers Menu,5x Speed|10 Score,Full Healthy|12 Score,,Teleport CT|10 Score,Teleport T|10 Score,,Restart|35 Score,Kill All|40 Score,+1 Score|16000$")
   end
   if(txt=="!hats") then
     menu(id,"Hats Menu 1 / 2,Armor,Gandalf,Marine,Priate,Angel,Devil,Graduation,Party,Next|>>")
   end
   if(txt=="!angry") then
        parse("shake "..id.." 100")
   end
return 1
end


now its working but if you pressed "Z" you can't post anything in chat cuz no thing is showing
hope someone hlep me
19.10.16 05:11:06 pm
Up
GeoB99
Moderator
Offline Off
In 40 line in the second chunk of code you literally tell Lua to not output any say chat - that's why. Remember that
return 1
is independent by other IF conditions and their conditional body. To make it clear, let's say you want !menu text-say-command to not be displayed thus you need to add return 1 at the end of the condition. However note that other commands such as !admin for instance will be displayed.

By your request I had only put
return 1
inside the second IF condition as you don't want !rs to be displayed within the chat.
The Code >
edited 1×, last 19.10.16 05:21:07 pm
19.10.16 05:21:44 pm
Up
LeaderOfSkills
BANNED
Offline Off
@user GeoB99:
helpful
To the start Previous 1 Next To the start