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 213 14 15338 339 Next To the start

old Re: Lua Scripts/Questions/Help

RedPillow
User Off Offline

Quote
Uhm, I`d like to make a "Knife-only" server for cs2d, but the knifes must be one-hit-kill..

So, could someone make me a script which makes knifes 1-hit-kill?

Also, if someone has speedmod-script for all-players, psot it to me here

old Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Quote
1
2
3
4
5
6
7
8
addhook("spawn", "speedmodatspawn")
function speedmodatspawn(id)
	parse("speedmod "..id.." 100")
end
addhook("startround", "onehit")
function onehit()
	parse("mp_wpndmg Knife 99999")
end

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Heavy has written
Impossible...

Possible I think. Possible to make menus using servecrations.
But I don't know if possible to make text menu...
edited 1×, last 17.01.10 12:25:46 am

old Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Quote
Jonzku777 has written
Also, if someone has speedmod-script for all-players, psot it to me here


1
2
3
4
5
6
7
8
9
10
if sample==nil then sample={} end
sample.fast={}

--------------------------------------
-- MAKE FAST                        --
--------------------------------------
addhook("spawn","sample.fast.spawn")
function sample.fast.spawn(p)
	parse("speedmod "..p.." 15")
end

15 is fast, but you can also do 30 or 45 ,whatever you like.

old Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Quote
Skipper and Jonzku777 I have a config file that can do that from up to 10 players. You can find it in misc/stuff at files.
edited 1×, last 12.06.09 05:11:33 pm

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
Uhh, I don't know whats wrong with my script. I wanted script to heal a player 10 HP by second, and when reaches 90, it stops.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("say","player_say")
function player_say(id,txt)
	if(txt=="!heal") then
		addhook("second","hplayer_second")
		function hplayer_second
			if(player(id,"health")>30) then
				return 1
			elseif(player(id,"health")<30) then
				parse("sethealth "..id.." "..(player(id,"health")+10)) 
			elseif(player(id,"health") == 90) then
				freehook("second","hplayer_second")
			end
		end
	end
end

LUA ERROR: sys/lua/test.lua:6: '(' expected near 'if'

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
you can't put the declaration of a function into another function.
cut the whole code for function hplayer_second and paste it at the very end of your code.

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
Oh, YEA!!! can you all believe I actually did it? I made my lua script that can heal people 10 hp at second, and if someone has 100 or higher than 100 (to reduce lag) it just fees the hook.
DC, what you think. Is this OK?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("say","player_say")
function player_say(id,txt)
	if(txt=="!heal") then
		addhook("second","hplayer_second")
		function hplayer_second()
			parse ("sethealth "..id.." "..(player(id,"health")+10))
			if (player(id,"health")==90) then
				freehook("second","hplayer_second")
			elseif (player(id,"health")==100) then
				freehook("second","hplayer_second")
			elseif (player(id,"health")>100) then
				freehook("second","hplayer_second")
			end
		end
	end
end

I've found the glitch: If you say !heal, and another player says !heal, script "favorites" last player that called the hook, and first player doesnt got heal. I know how this could be abused:

If a player says !heal, enemy can say !heal, and you know what happens.

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
NTD has written
only 1 thing to wonder why dosent someone explane properly how to USE lua scripts all those things in the help thing is usless!


Well dude, I've learnt what I know through the help files provided by DC + His samples.
But if you want to do something more serious I'd suggest checking Lua's user manual.

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
@LinuxGuy:
I feel like you did not even read (or understand) what I just wrote. Does your script work?

declaring a function in a function is very bad style. you shouldn't do that.

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
DC has written
@LinuxGuy:
I feel like you did not even read (or understand) what I just wrote. Does your script work?

declaring a function in a function is very bad style. you shouldn't do that.

Well, yes it works, but I didn't know any other way to make this. I'm still beginner in lua.

I don't know how to make this work without putting function under function.

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
LinuxGuy has written
DC has written
@LinuxGuy:
I feel like you did not even read (or understand) what I just wrote. Does your script work?

declaring a function in a function is very bad style. you shouldn't do that.

Well, yes it works, but I didn't know any other way to make this. I'm still beginner in lua.

I don't know how to make this work without putting function under function.

Im making "super hero" mod.
There is my wolverine example. ( you need to have wolverine power to get this healing)
1
2
3
4
5
6
7
8
9
10
11
-- Wolverine
addhook("second","server.hero.sec")
function server.hero.sec(p)
for p=1,32 do
	if (player(p,"exists")) then
		if server.hero.lvlheal[p]>=1 then
			parse ("sethealth "..p.." "..(player(p,"health")+3*server.hero.lvlheal[p]))
		end
	end
end
end
Its realy working

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
@Blazzingxx: I'm trying to activate healing with say command that heals 10 hp second, and when it reaches 100 the script stops (cause there would be lag). But the way i did it, as DC said is bad to make (function in a function)

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Yes . He is right, Couse you use say function and without period you just start using second hook... But I dont think there is more ways.
And btw I think your script function will slow down server more than sec hook always
If you want instatly heal , use this :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-- say
if server==nil then server={} end
server.sayfuncs={}
addhook("say","server.sayfuncs.say")
function server.sayfuncs.say(p,txt)
	if (txt=="!heal") then
		if (player(p,"exists")) then
		hp=player(p,"health")
			if (hp>0) then
				msg ("©000255000"..player(p,"name").." was HP: "..hp.." Healing")
				parse("equip "..p.." 64")
			end
		end
	end
end
Then you say !heal, You will be healed instantly. My old script example.

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
lol, equips player a Medikit

But I prefer this:
1
2
3
4
5
6
addhook("say","player_say")
function player_say(id,txt)
	if (txt=="!heal") then
		parse("sethealth "..id.." 100")
	end
end
its small :D. No mess

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
If you will be dead and you will say that .. You will be risen,
First think...
Look again into my scrip.. And btw thats old. I can make it smaller.
edited 1×, last 17.01.10 12:28:36 am

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
addhook("say","player_say")
function player_say(id,txt)
	if (txt=="!heal") then
		if (player(id,"health")==0) then
			return 1
		else parse("sethealth "..id.." 100")
		end
	end
end
DOH
To the start Previous 1 213 14 15338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview