Forum

> > CS2D > Scripts > Need solution for "Hit" hook.
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Need solution for "Hit" hook.

11 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Need solution for "Hit" hook.

Rainoth
Moderator Off Offline

Zitieren
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

alt Re: Need solution for "Hit" hook.

Gajos
BANNED Off Offline

Zitieren
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
2× editiert, zuletzt 15.03.13 21:04:55

alt Re: Need solution for "Hit" hook.

orkin2913
User Off Offline

Zitieren
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

alt Re: Need solution for "Hit" hook.

Rainoth
Moderator Off Offline

Zitieren
user Yates hat geschrieben
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" ")

alt Re: Need solution for "Hit" hook.

EngiN33R
Moderator Off Offline

Zitieren
user Rainoth hat geschrieben
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 hat geschrieben
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

alt Re: Need solution for "Hit" hook.

Gajos
BANNED Off Offline

Zitieren
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")

alt Re: Need solution for "Hit" hook.

Rainoth
Moderator Off Offline

Zitieren
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 ?
1× editiert, zuletzt 16.03.13 23:23:21

alt Re: Need solution for "Hit" hook.

Dousea
User Off Offline

Zitieren
Maybe it works perfectly.
Spoiler >

alt Re: Need solution for "Hit" hook.

Alistaire
User Off Offline

Zitieren
user Rainoth hat geschrieben
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.

alt Re: Need solution for "Hit" hook.

Rainoth
Moderator Off Offline

Zitieren
Zitat
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.

alt Re: Need solution for "Hit" hook.

Alistaire
User Off Offline

Zitieren
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?)
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht