Forum

> > CS2D > Scripts > attack hook
Forums overviewCS2D overview Scripts overviewLog in to reply

English attack hook

19 replies
To the start Previous 1 Next To the start

old attack hook

kalis
User Off Offline

Quote
hey why this lua not work ?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("attack","rp_attack")
function rp_attack(id)
	local wpn = player(id,"weapontype")
	for i = 1,32 do
		if player(i,"exists") and i ~= id then
			local x = player(i,"x")
			local y = player(i,"y")
			local x_c = player(id,"x")
			local x_c = player(id,"y")
			if (x < x_c + 64 and x > x_c - 64) and (y < y_c + 64 and y > y_c - 64)	then
					parse("shake "..i.." 50")
			end
		end
	end	
end

old Re: attack hook

Alistaire
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("attack","rp_attack")
function rp_attack(id)
	local wpn = player(id,"weapontype")
	for i = 1,32 do
		if player(i,"exists") and i ~= id then
			local x = player(i,"x")
			local y = player(i,"y")
			local x_c = player(id,"x")
			local y_c = player(id,"y")
			if (x < x_c + 64 and x > x_c - 64) and (y < y_c + 64 and y > y_c - 64)	then
					parse("shake "..i.." 50")
			end
		end
	end	
end

You didn't make an y_c parameter thing. Just two x_c's.

old Re: attack hook

kalis
User Off Offline

Quote
it not error. but dont work
@alistaire
why dont use y_c @ @?
you understand ? my lua do what?

old Re: attack hook

Alistaire
User Off Offline

Quote
You didn't say what the script has to do at the if(x < x_c (...)) part.

old Re: attack hook

kalis
User Off Offline

Quote
1
if (x < x_c + 64 and x > x_c - 64) and (y < y_c + 64 and y > y_c - 64)     then
i have x_c and y_c @ @

old Re: attack hook

DannyDeth
User Off Offline

Quote
1
2
local x_c = player(id,"x")
local x_c = player(id,"y")
You wrote this in your script.

old Re: attack hook

Alistaire
User Off Offline

Quote
user Alistaire has written
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("attack","rp_attack")
function rp_attack(id)
	local wpn = player(id,"weapontype")
	for i = 1,32 do
		if player(i,"exists") and i ~= id then
			local x = player(i,"x")
			local y = player(i,"y")
			local x_c = player(id,"x")
			local y_c = player(id,"y")
			if (x < x_c + 64 and x > x_c - 64) and (y < y_c + 64 and y > y_c - 64)	then
					parse("shake "..i.." 50")
			end
		end
	end	
end


This one works smartass. At least it has to.

old Re: attack hook

DannyDeth
User Off Offline

Quote
You did not define c_y, you did c_x twice instead of c_x and c_y, capeesh?

old Re: attack hook

kalis
User Off Offline

Quote
1
(x < x_c + 64 and x > x_c - 64)
this is area -xsize (source near id will be shake)

1
(y < y_c + 64 and y> y_c + 64)
this is area -y size

old Re: attack hook

DannyDeth
User Off Offline

Quote
READ YOUR CODE:
ORIGINAL CODE >

See this part:
1
2
3
4
local x = player(i,"x")
local y = player(i,"y")
local x_c = player(id,"x")
local x_c = player(id,"y")
Where is c_y in there? You did not define it. It does not exist.

@user Alistaire:
No, I shall never give up, talking to brick-walls like this guy is way too much fun.

old Re: attack hook

kalis
User Off Offline

Quote
OMG
big problem @ @
i think i dont have eyes @ @
sorry all
ok thank all

old Re: attack hook

DannyDeth
User Off Offline

Quote
The impossible has been accomplished!! w00t w00t!

Took a while, hmph.

old Re: attack hook

kalis
User Off Offline

Quote
why i dont see it ?
it very very small problem
ok
i go to test lua

old Re: attack hook

Black Wolf
User Off Offline

Quote
Please check what console say. Any errors? is this full script of your lua or just part? If you need help you should put more information about your script.

old Re: attack hook

Alistaire
User Off Offline

Quote
user Black Wolf has written
Please check what console say. Any errors? is this full script of your lua or just part? If you need help you should put more information about your script.


Bro the problem's already solved.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview