Forum

> > CS2D > Scripts > very easy lua
Forums overviewCS2D overview Scripts overviewLog in to reply

English very easy lua

9 replies
To the start Previous 1 Next To the start

old very easy lua

karnash_btt OP
User Off Offline

Quote
Look at this:
1
2
3
4
5
6
7
addhook("attack" , "attackshake")
function attackshake(id)
parse("shake "..id.." 3")
if (player(id,"health")<=30) then
parse("shake "..id.." 5")
end
end

Please help me, im learning lua from scratch:
this script shakes the player when attacking (very simple) but i dont know how to make the player not shaking when walking (with left shift) thanx
edited 1×, last 16.09.11 01:46:25 am

old Re: very easy lua

Apache uwu
User Off Offline

Quote
Here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook("move","_move")
addhook("attack","_attack")

t_walk={}

function _move(id,x,y,walk)
	t_walk[id]=walk
end

function _attack(id)
	if t_walk[id]=="0" then --not walking
	parse("shake "..id.." 3")
		if (player(id,"health")<=30) then
			parse("shake "..id.." 5")
		end
	end
end

old Re: very easy lua

Starkkz
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function Millisecs()
	return os.clock() * 1000
end

LastMovement = {}

addhook("move","moves")
function moves(id,x,y,slow)
	if slow == 1 then
		LastMovement[id] = Millisecs()
	end
end

addhook("attack","attackHook")
function attackHook(id)
	if not LastMovement[id] or Millisecs() - LastMovement[id] <= 99 then
		if player(id,"health") <= 30 then
			parse("shake "..id.." 5")
		end
	end
end

old Re: very easy lua

karnash_btt OP
User Off Offline

Quote
Thanks this is very useful but doesnt shake when standing. Is it possible to make it shake when standing?

also can you help me doing a stun script(slow player for 3 seconds) when hit?

old Re: very easy lua

MikuAuahDark
User Off Offline

Quote
just test this script:
Spoiler >

is possible to make player shake while standing, but i don't know how to make it
bdw here the stun script:
Spoiler >

i hope there no errors

old Re: very easy lua

karnash_btt OP
User Off Offline

Quote
yes there are.
LUA ERROR: sys/lua/advancedshake.lua:13: attempt to index global 'slowplayer' (a nil value)
LUA ERROR: sys/lua/advancedshake.lua:26: attempt to index global 'slowplayer' (a nil value)

old Re: very easy lua

MikuAuahDark
User Off Offline

Quote
wow i forgot something, here the fixed code:
Spoiler >

old Re: very easy lua

karnash_btt OP
User Off Offline

Quote
thx a lot its working
*edit*
but i cant change speedmod
edited 1×, last 02.10.11 11:58:19 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview