Forum

> > CS2D > Scripts > Flashlight can kill enemies
Forums overviewCS2D overview Scripts overviewLog in to reply

English Flashlight can kill enemies

25 replies
Page
To the start Previous 1 2 Next To the start

old Flashlight can kill enemies

Eternal
User Off Offline

Quote
Hello guys i want the script that is Flashlight can kill eneies
Example
when i toggle to open flashlight to kill my nearby enemies

please make me one or give example flashlight can kill enemies to me

THANK YOU EVERY ANSWER

old Re: Flashlight can kill enemies

EngiN33R
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
range = 100 -- range within which the torch will kill enemies

addhook("flashlight","killtorch")
function killtorch(id,state)
	if state==1 then
		for _,iid in pairs(player(0,"tableliving")) do --check all players that are alive
			if iid~=id then --if the player being checked isn't the torch activator
				local ix=player(id,"x")
				local iy=player(id,"y")
				local iix=player(iid,"x")
				local iiy=player(iid,"y")	
				if ((ix-iix)*(ix-iix)+(iy-iiy)*(iy-iiy))<=range then --mathematical formula for checking distancethen kill player
					parse("customkill "..id.." Torch "..iid)
				end
			end
		end
	end
end

old Re: Flashlight can kill enemies

Suprise
BANNED Off Offline

Quote
user EngiN33R has written
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
range = 100 -- range within which the torch will kill enemies

addhook("flashlight","killtorch")
function killtorch(id,state)
	if state==1 then
		for _,iid in pairs(player(0,"tableliving")) do --check all players that are alive
			if iid~=id then --if the player being checked isn't the torch activator
				local ix=player(id,"x")
				local iy=player(id,"y")
				local iix=player(iid,"x")
				local iiy=player(iid,"y")	
				if ((ix-iix)*(ix-iix)+(iy-iiy)*(iy-iiy))<=range then --mathematical formula for checking distancethen kill player
					parse("customkill "..id.." Torch "..iid)
				end
			end
		end
	end
end


Torch lol

old Re: Flashlight can kill enemies

Eternal
User Off Offline

Quote
user Ridho has written
i think, it good in zombie mode, when player move his flashlight to zombie, it decrease the zombie hp
hehe

yeah i think like this i want to use flashlight to hurt zombies


Ahhh it not work how to do it work? i don't understand
edited 1×, last 12.03.12 03:38:00 pm

old Re: Flashlight can kill enemies

EngiN33R
Moderator Off Offline

Quote
user Suprise has written
Torch lol


I don't see anything funny.

user Eternal has written
Ahhh it not work how to do it work? i don't understand


How exactly does it not work? And stop putting crying smilies for goodness' sakes.

old Re: Flashlight can kill enemies

Anders4000
User Off Offline

Quote
@user EngiN33R: He probably didn't put state = 1.
Also, I don't like that you call it "iid". iid is short for Item ID.

EDIT: Forget about that state thing ^^, I though it was something else.

old Re: Flashlight can kill enemies

EngiN33R
Moderator Off Offline

Quote
user Anders4000 has written
Also, I don't like that you call it "iid". iid is short for Item ID.


You do know that I don't care and call my variables whatever the hell I want?

user Eternal has written
aaaa -..-
how to make it work i don't understand?


We won't be able to bloody help you unless you tell us whether or not there's an error and if there is, what error is it.

old Re: Flashlight can kill enemies

Eternal
User Off Offline

Quote
when i turn on flashlight [F] enemies aren't hurt and take any damage,yeah i call it not work but if i see on console it works
i am confuse how to install?,
i install exactly?,
how to do it works?


i test it very sure

Sorry for my bad english
i am not in your country

old Re: Flashlight can kill enemies

Grulf
User Off Offline

Quote
user Eternal has written
when i turn on flashlight [F] enemies aren't hurt and take any damage,yeah i call it not work but if i see on console it works
i am confuse how to install?,
i install exactly?,
how to do it works?


i test it very sure

Sorry for my bad english
i am not in your country


put the script in the [cs2d directory]/sys/lua/server.lua
d00d

old Re: Flashlight can kill enemies

Anders4000
User Off Offline

Quote
user EngiN33R has written
user Anders4000 has written
Also, I don't like that you call it "iid". iid is short for Item ID.


You do know that I don't care and call my variables whatever the hell I want?

Well, I didn't mean to offend you. But it's bad not to call variables things that other people understand.
Adding comments, and making the code the most understandable possible is being a good programmer.

old Re: Flashlight can kill enemies

Anders4000
User Off Offline

Quote
user Yates has written
user Anders4000 has written
and making the code the most understandable possible is being a good programmer.

Lolno. Coding something that works is being a good programmer.

U won't get a job without the skills i mentioned.

old Re: Flashlight can kill enemies

EngiN33R
Moderator Off Offline

Quote
user Anders4000 has written
Well, I didn't mean to offend you. But it's bad not to call variables things that other people understand.
Adding comments, and making the code the most understandable possible is being a good programmer.


There's quite a bit of comments there, and I could call the variable 'dickshit', but I didn't, so it doesn't really matter as long as people understand which variable corresponds to what. What if in this case iid is imaginary ID for me? It doesn't matter. And you can't say that this script is not commented well enough because it is.

Also, I must agree with Yates - being a good programmer is mainly producing things that work. Adding comments and making the code understandable come in in certain situations - like this one.

old Re: Flashlight can kill enemies

Anders4000
User Off Offline

Quote
user EngiN33R has written
user Anders4000 has written
Well, I didn't mean to offend you. But it's bad not to call variables things that other people understand.
Adding comments, and making the code the most understandable possible is being a good programmer.


There's quite a bit of comments there, and I could call the variable 'dickshit', but I didn't, so it doesn't really matter as long as people understand which variable corresponds to what. What if in this case iid is imaginary ID for me? It doesn't matter. And you can't say that this script is not commented well enough because it is.

Also, I must agree with Yates - being a good programmer is mainly producing things that work. Adding comments and making the code understandable come in in certain situations - like this one.

I didn't say your code wasn't commented. I just think it's a big and important part of coding.
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview