Forum

> > CS2D > Scripts > forgot something in scripting
Forums overviewCS2D overview Scripts overviewLog in to reply

English forgot something in scripting

11 replies
To the start Previous 1 Next To the start

old forgot something in scripting

LeaderOfSkills
BANNED Off Offline

Quote
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

old Re: forgot something in scripting

LeaderOfSkills
BANNED Off Offline

Quote
ok lets test this

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

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

old Re: forgot something in scripting

ExT
User Off Offline

Quote
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

old Re: forgot something in scripting

GeoB99
Moderator Off Offline

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

old Re: forgot something in scripting

LeaderOfSkills
BANNED Off Offline

Quote
this is the code i am using and its not working
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

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

old Re: forgot something in scripting

GeoB99
Moderator Off Offline

Quote
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
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview