Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 217 18 19338 339 Next To the start

old Re: Lua Scripts/Questions/Help

wups
User Off Offline

Quote
What is wrong with this code?
I got nil when i want to check if the hook works.

1
2
3
4
5
addhook("spray","test")
function test(p)
msg(p) -- Got nil?

end

old Re: Lua Scripts/Questions/Help

Kaka024
User Off Offline

Quote
Guys. I want make a simple 3 warns badWord system but i need some info
-If i make warn system for 1 player, will it work for all players?
I mean. I make:
BadWord>warns+1
Warns==3>kick

and will it work for every player or for everyone?
Will it warn all or only player who said that?

-If for all, how to set var of diff player?
-If i use hook "second", will it be blocked to use for other scripts or not?
-If i use var "p" (like in script with nick), must i use other letter in another script?

@up
1
2
3
4
5
addhook("spray","test")
function test(p)
msg(p) -- Got nil?

end

i think u should make:
1
2
3
4
5
addhook("spray","test")
function test(p)
parse("msg "..p")

end

dunno if i've made good with ""

old Re: Lua Scripts/Questions/Help

MR_Rinde
User Off Offline

Quote
hi
i will make a medic (char)
I need a script to heal the medic 10 HP by second.
I have this now.
----------
     -- Medic
     if (sample.classes.class[id]==9) then
          parse ("setmaxhealth "..id.." 150")
          parse ("setarmor "..id.." 0")
          parse ("speedmod "..id.." 0")
          return "24,50,21,52,";
     end
end
----------

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Kaka024 has written
leggao. It isn't actual. I noticed that so i changed the script for this:
1
2
3
4
5
6
7
8
9
10
11
addhook("join","nickjoin")
addhook("spawn","pspawn")

function nickjoin(p)
function pspawn(p)
n = player(p,"name")
if n=="Player" then
parse("setname "..p.." [ByKaka] Guest")
end
end
end

It works for now


1
2
3
4
5
6
addhook("join", "nameact")
addhook("spawn", "nameact")

function nameact(p)
	if (player(p, "name")=="Player") then parse("setname "..p.." [ByKaka] Guest") end
end

Here's an uncluttered version of your code, and here's a unit test to run it with

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--Simple Assertion--
function error(t)
	msg("Error:"..t)
end

function assert(o, _o, op)
	if op == "=" then
		if not (o == _o) then error("AssertionException: Equality failed.") end
	end
	if op == "!=" then
		if (o == _o) then error("AssertionException: Inequality failed.") end
	end
	return true
end

function namesec()
	for n=1, 32 do
		if player(n, "exists") then assert(player(n, "name"), "Player", "!=") end
	end
end

addhook("second", "namesec")

The frequency of you getting the exception equals the frequency of your code miscapturing the names.

old Re: Lua Scripts/Questions/Help

Kaka024
User Off Offline

Quote
i just sux in lua. Anyway - how to make that 3 warnings anti-badword system?

Btw.
I've noticed that if i use "spawn" hook, then my classes on 1 map will not work. Any ideas for that?

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
I have question.
I cant find function anywhere like:
If your team wins round , something hapends only for winers.
I cant find value for that
That's possible?
edited 1×, last 17.01.10 12:32:09 am

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
these days im just posting unlimited stuff. here is cool one

Unlimited Laser Mines WTF!!! lol

EDIT: awww, only 3 uploads per day
edited 1×, last 29.06.09 01:34:33 am

old Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Quote
How can I create a HEV suit recharger like it's used in Half-Life but for CS2D. I want to add multiple HEV suit rechargers on my map. They must add 10+ armor every time it's used. It must be active 1 second, then it must go inactive every time you use it when you use the HEV suit recharger. I need addhook I guess?

Send me PM's if you wish.

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
KimKat has written
How can I create a HEV suit recharger like it's used in Half-Life but for CS2D. I want to add multiple HEV suit rechargers on my map. They must add 10+ armor every time it's used. It must be active 1 second, then it must go inactive every time you use it when you use the HEV suit recharger. I need addhook I guess?

Send me PM's if you wish.

You should use triger buton. Its shouldnt be hard.
If I will have time I will show ya.

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
MR_Rinde has written
hi
i will make a medic (char)
I need a script to heal the medic 10 HP by second.
I have this now.
----------
     -- Medic
     if (sample.classes.class[id]==9) then
          parse ("setmaxhealth "..id.." 150")
          parse ("setarmor "..id.." 0")
          parse ("speedmod "..id.." 0")
          return "24,50,21,52,";
     end
end
----------


for regeneration? or healing weapon

old Re: Lua Scripts/Questions/Help

Night Till Death
User Off Offline

Quote
KimKat has written
How can I create a HEV suit recharger like it's used in Half-Life but for CS2D. I want to add multiple HEV suit rechargers on my map. They must add 10+ armor every time it's used. It must be active 1 second, then it must go inactive every time you use it when you use the HEV suit recharger. I need addhook I guess?

Send me PM's if you wish.


HEV Recharg? i know! i use this in an easy way without lua! i just make the sound suitcharge and use button with kevlar!

old Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Quote
NTD has written
KimKat has written
How can I create a HEV suit recharger like it's used in Half-Life but for CS2D. I want to add multiple HEV suit rechargers on my map. They must add 10+ armor every time it's used. It must be active 1 second, then it must go inactive every time you use it when you use the HEV suit recharger. I need addhook I guess?

Send me PM's if you wish.


HEV Recharg? i know! i use this in an easy way without lua! i just make the sound suitcharge and use button with kevlar!
That loses the whole point with HEV suit rechargers... it's only supposed to add HEV like each second or such, just like it works with health when it adds per second when you use the "medihealer" or whatever it is called.

Also spawning a item kevlar+helm infront of a HEV suit recharger feels pretty lame. However that's actually what I was using in first place.

Still it should work to like add +10 armor every second to a player if you use a trigger. Somehow, someway.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Kaka024 has written
i just sux in lua. Anyway - how to make that 3 warnings anti-badword system?

Btw.
I've noticed that if i use "spawn" hook, then my classes on 1 map will not work. Any ideas for that?


DL: http://6.dot.ch/filter.zip

I've written the filter, you can write the rest of the hooking and stuff. Note also that you'll need to pass the text in as all-lower-case for maximum flexibility on my part. The syntax is:

filter(Text) - returns true if bad words are found, false if it's all clear.

Example:

1
if filter("this is normal speech") then print("error") end

The collection of badwords are contained in badwords.txt, you can add new filters by adding a comma (,) followed by the word to filter.

If you just type the word in by itself, it'll only filter it if it's a standalone word. If you type in *word, then it'll only return true if there's a xxxxxword word in, and if you use word*, then the script will only return true if there's a wordxxxxx word in the text. If you use *word* then the function will return true if the string is detected anywhere within the text

IE:

if you use boo as the filter word then

"boo, I hate you" would return true
"oboo, I hate you" would return false

if you use *boo as the filter word then

"boo, I hate you" would return true
"oboo, I hate you" would also return true

if you use boo* as the filter word then

"oboo, I hate you" would return false
"boooooo, I hate you" would return true

if you use *boo* as the filter word then
"boo, I hate you" and "boobs!!!" would both return true.

old Re: Lua Scripts/Questions/Help

Kaka024
User Off Offline

Quote
it says that cant find table.lua. I'm not stupid, i've placed everything in one folder and executed filter.lua by server.lua.
everything seems to be ok. What's wrong then?

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
place string.lua, table.lua, and badwords.txt in the cs2d folder (not in a subdirectory like cs2d/sys/lua)

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Kaka024 has written
Lua error: sys/lua/samples/filter.lua:29: attempt to call method 'inside' <a nil value>

Either get rid of the empty spaces in badwords.txt or add the following in filter.lua before line 29

1
2
if not (type(first) == "string") then return t end
	if not (type(last) == "string") then return t end
To the start Previous 1 217 18 19338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview