Forum

> > CS2D > Scripts > Need solution for "Hit" hook.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Need solution for "Hit" hook.

11 replies
To the start Previous 1 Next To the start

old Need solution for "Hit" hook.

Rainoth
Moderator Off Offline

Quote
Can anyone tell me what to write so when I get a "power or whatever" it allows me to slow/stun/flash/deal extra damage. I tried to make it and I tried to look into Superhero script stun but I couldn't make it. Could there be something wrong in this script ? It doesn't work at all but I get no errors. I need it to work when I hit someone but do nothing when I get hit myself. Here's the
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook("hit","_hit")
function _hit(id,sour,wep,hpdmg,apdmg,rawdmg)
	if player(id,"team") ~= player(sour,"team") then
		if player(sour,"exists") then
			if ice[id] == 1 then		
				parse("speedmod "..id.." -50")
				print("hohohoho")
			elseif flash[id] == 1 then
				parse("flashplayer "..id.." 70")
				print("hohohoho")
			elseif crit[id] == 1 then
				parse("sethealth "..id.." "..(player(id,"health")-5).."")
				print("hohohoho")
			end
		end
	end
end

Hopefully you can help me. Thanks

old Re: Need solution for "Hit" hook.

Gajos
BANNED Off Offline

Quote
I dont't understand your request.

In my script variable victim = player get bullet, id = player which shot.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook("hit","_hit")
function _hit(victim,id,wep,hpdmg,apdmg,rawdmg)
     if player(id,"team") ~= player(victim,"team") then
          if player(victim,"exists") then
               if ice[id] == 1 then          
                    parse("speedmod "..victim.." -50")
                    print("hohohoho")
               elseif flash[id] == 1 then
                    parse("flashplayer "..victim.." 70")
                    print("hohohoho")
               elseif crit[id] == 1 then
                    parse("sethealth "..victim.." "..(player(id,"health")-5).."")
                    print("hohohoho")
               end
          end
     end
end


Idea for script:
use variables like this:
1
kopytko = true
1
2
3
4
5
kopytko = true
gowno = false
if kopytko and not gowno then
	msg('Gajos PL is the best! @C')
end
edited 2×, last 15.03.13 09:04:55 pm

old Re: Need solution for "Hit" hook.

orkin2913
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
addhook("hit","_hit") 
function _hit(id,sour,wep,hpdmg,apdmg,rawdmg) 
if player(id,"team") ~= player(sour,"team") then
 if player(sour,"exists") then
lottery = math.random(1,100)
 if lottery == 1 then 
parse("speedmod "..id.." -50") 
print("hohohoho") 
elseif lottery == 2 then 
parse("flashplayer "..id.." 70") 
print("hohohoho") 
elseif lottery == 3 then 
parse("sethealth "..id.." "..(player(id,"health")-5).."") 
print("hohohoho") 
end 
end 
end
 end

old Re: Need solution for "Hit" hook.

Rainoth
Moderator Off Offline

Quote
user Yates has written
You should check if the source has the power up, and not the id.


Thanks. 3 simple changes fixed everything.

Now just need to know how to write sv_sound2 properly since it gives me error on it. Oh and if anyone knows how to save player location, please tell me. (Idea : Save location with tag and then teleport to it on another action)

1
2
3
4
elseif crit[sour] == 1 then
				if math.random(1,18)==1 then
				parse("sethealth "..id.." "..(player(id,"health")- "..math.random(5,7)..").." ")
				parse("sv_sound2 "..id.." "env/Aether_v2/critr.ogg" ")

old Re: Need solution for "Hit" hook.

EngiN33R
Moderator Off Offline

Quote
user Rainoth has written
Now just need to know how to write sv_sound2 properly since it gives me error on it.

-snip-


You need to escape your quotes. It will look like this:

1
parse("sv_sound2 "..id.." \"env/Aether_v2/critr.ogg\"")
The backslashes make sure it's a character and not Lua string notation.


user Rainoth has written
Oh and if anyone knows how to save player location, please tell me. (Idea : Save location with tag and then teleport to it on another action)


1
2
3
4
5
6
7
8
9
10
11
playerlocation = {}

addhook("serveraction","tagandtele")
function tagandtele(id,a)
	if a==2 then
		playerlocation[id] = {player(id,"x"),player(id,"y")}
		msg2(id,"Tag set!")
	elseif a==3 then
		parse("setpos "..id.." "..playerlocation[id][1].." "..playerlocation[id][2])
	end
end

old Re: Need solution for "Hit" hook.

Gajos
BANNED Off Offline

Quote
Man, you have only 5,5% that this function work, because line 1, if crit[sour] == 1
1
2
3
4
elseif crit[sour] == 1 then
	if math.random(1,18) == 1 then
		parse("sethealth "..id.." "..(player(id,"health") - math.random(5,7)))
		parse("sv_sound2 "..id.." env/Aether_v2/critr.ogg")

old Re: Need solution for "Hit" hook.

Rainoth
Moderator Off Offline

Quote
EDIT : I was making so on certain conditions on hit hook so there would be an explosion if you hit an enemy.
1
st = player(id,"team")
This means player who get's hit team right ?
1
timer(3000,"parse",'explosion '..sx..' '..sy..' 128 1000 '..st)

Wouldn't it be friendly explosion and do no damage ? I tried it with source and then it appears it's like friendly explosion. So why does it work properly when it shouldn't (I think)

E.g. Source - Ct hits id - T and after 3 seconds explosion which's team is the one of id (that makes it friendly explosion)

What I see : After 3 seconds explosion appears that kills all Terrorists around it.

Why does this work ?
edited 1×, last 16.03.13 11:23:21 pm

old Re: Need solution for "Hit" hook.

Dousea
User Off Offline

Quote
Maybe it works perfectly.
Spoiler >

old Re: Need solution for "Hit" hook.

Alistaire
User Off Offline

Quote
user Rainoth has written
EDIT : I was making so on certain conditions on hit hook so there would be an explosion if you hit an enemy.
1
st = player(id,"team")
This means player who get's hit team right ?
1
timer(3000,"parse",'explosion '..sx..' '..sy..' 128 1000 '..st)

Wouldn't it be friendly explosion and do no damage ? I tried it with source and then it appears it's like friendly explosion. So why does it work properly when it shouldn't (I think)

E.g. Source - Ct hits id - T and after 3 seconds explosion which's team is the one of id (that makes it friendly explosion)

What I see : After 3 seconds explosion appears that kills all Terrorists around it.

Why does this work ?


player(id, 'team') is always 1 or 2. So if you tested it with 2 players, the explosion is always from id (team). You made the explosion do 128 damage and it has a range of 1000 pixels. That is two times the screen, and 128 damage will kill most players in one hit.

old Re: Need solution for "Hit" hook.

Rainoth
Moderator Off Offline

Quote
Quote
player(id, 'team') is always 1 or 2. So if you tested it with 2 players, the explosion is always from id (team). You made the explosion do 128 damage and it has a range of 1000 pixels. That is two times the screen, and 128 damage will kill most players in one hit.


That's not correct. It's 128 pixels wide which is 4 tiles and deals a damage of 1000. And for the explanation about teams - thanks.

old Re: Need solution for "Hit" hook.

Alistaire
User Off Offline

Quote
Okay so what are sx and sy. If you're looping through the T's players and exploding every one of them, obviously it would kill them all if the explosion was parsed by a CT player (id 2?)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview