Forum

> > CS2D > Scripts > Bonus dmg if..
Forums overviewCS2D overview Scripts overviewLog in to reply

English Bonus dmg if..

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

old Bonus dmg if..

Sudden Death
User Off Offline

Quote
Hi, i was doing script, but suddenly this won't work:
1
2
3
4
5
6
addhook("hit","bonusdmg")
function bonusdmg(id,victim)
if bdmg[id]==1 then
parse("sethealth '..victim..' '..player(victim,'health')-10'")
end
end
• I got array for "bdmg[id]"

In console there isn't problems, so please try to do something guys

old Re: Bonus dmg if..

EP
User Off Offline

Quote
1
2
3
4
5
6
addhook("hit","bonusdmg")
function bonusdmg(victim,id)
	if bdmg[id]==1 then
		parse("sethealth "..victim.." "..(player(victim,"health")-10))
	end
end
Remember the 1st parameter of hit hook is "victim" and the 2nd is "id".

old Re: Bonus dmg if..

Sudden Death
User Off Offline

Quote
Awww, thanks man!
Edit: I try to do something with it but.. It isn't working!
edited 1×, last 08.06.12 08:58:31 pm

old Re: Bonus dmg if..

omg
User Off Offline

Quote
how is it not working? the only problem i can see is that the person is dying because u set his health below zero

if u want the person to die by ur weapon, try this
1
2
3
4
5
6
7
8
addhook("hit","bonusdmg")
function bonusdmg(victim,id,weapon)
     if bdmg[id]==1 and player(victim,"health")>10 then
          parse("sethealth "..victim.." "..player(victim,"health")-10)
     else
          parse("customkill "..id.." "..itemtype(weapon,"name").." "..victim)
     end
end

old @omg

Sudden Death
User Off Offline

Quote
Thanks you for this, now everything work :3
Edit: No, don't work if bdmg is on, then just kill on 1 hit
edited 1×, last 09.06.12 12:23:49 pm

old Re: Bonus dmg if..

Kisses
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
addhook("hit","bonusdmg")
function bonusdmg(id, source, weapon, hpdmg, apdmg, rawdmg)
	if bdmg[source] == 1 then
		local health = player(id, "health")
		if health > 10 then
			parse("sethealth " .. id .. " " .. health-10)
		else
			parse("sethealth " .. id .. " " .. hpdmg)
		end
	end
end

This should work

old Re: Bonus dmg if..

Cure Pikachu
User Off Offline

Quote
@user Kisses: You can't kill someone with sethealth.
1
2
3
4
5
6
7
8
9
10
11
addhook("hit","bonusdmg")
function bonusdmg(victim,id,weapon)
	if bdmg[id]==1 then
		local hp = player(victim,"health")
		if hp>10 then
			parse("sethealth "..victim.." "..hp-10)
		else
			parse("customkill "..id.." \""..itemtype(weapon,"name").."\" "..victim)
		end
	end
end

old Re: Bonus dmg if..

Avo
User Off Offline

Quote
Yes, try this:
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("hit","bonus_dmg")
function bonus_dmg(victim,id,weapon,hpdmg)
	if player(victim,"health")-hpdmg<=0 then
		return 0
	else
		if player(victim,"health")-hpdmg-10<=0 then	
			return 0
		else
			local health=player(victim,"health")-10
			parse("sethealth "..victim.." "..health)
		end
	end
end

It should work.

old Re: Bonus dmg if..

Kisses
User Off Offline

Quote
user Avo has written
Yes, try this:
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("hit","bonus_dmg")
function bonus_dmg(victim,id,weapon,hpdmg)
	if player(victim,"health")-hpdmg<=0 then
		return 0
	else
		if player(victim,"health")-hpdmg-10<=0 then	
			return 0
		else
			local health=player(victim,"health")-10
			parse("sethealth "..victim.." "..health)
		end
	end
end

It should work.


Let's see.
health = 7
hpdmg = 4
health - hpdmg - 10 = -7 > return 0 .. why? Also you forgot to check if 'id' is in bdmg table.

Please test your scripts before posting them here

old Re: Bonus dmg if..

Sudden Death
User Off Offline

Quote
I have no idea, why it won't set health, probably lua don't like me.
I tried to do it with msg and it was fine, it just won't set health.

old Re: Bonus dmg if..

Kisses
User Off Offline

Quote
user Sudden Death has written
I have no idea, why it won't set health, probably lua don't like me.
I tried to do it with msg and it was fine, it just won't set health.


Whose code you tried?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("hit","bonusdmg")
function bonusdmg(id, source, weapon, hpdmg, apdmg, rawdmg)
	msg(id .. " got hit by " .. source)
	if bdmg[source] == 1 then
		local health = player(id, "health")
		if health > 10 then
			parse("sethealth " .. id .. " " .. health-10)
			msg(id .. " health decreased by 10")
		else
			parse("sethealth " .. id .. " " .. hpdmg)
			msg(id .. " health set to " .. hpdmg)
		end
	end
end

Output >

old Re: Bonus dmg if..

Avo
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function array(m,v)
	local t = {}
	for i = 1, m do
		t[i]=v
	end
	return t
end

bdmg=array(32,true)

addhook("hit","bonus_dmg")
function bonus_dmg(victim,id,weapon,hpdmg)
	if bdmg[id] then
		if player(victim,"health")-hpdmg>0 and player(victim,"health")-hpdmg-10>0 then
			local health=player(victim,"health")-10-hpdmg
			parse("sethealth "..victim.." "..health)
			return 1
		else
			return 0
		end
	end
end
I tested, it works, user Kisses.

old Re: Bonus dmg if..

Kisses
User Off Offline

Quote
user Avo has written
I tested, it works, user Kisses.


You didn't get my point.

Let's say the victim has 9hp which means it should die from a single shot because damage bonus is 10. However the weapon causes damage of 5 and this is where your script fails.

See line 14 >

health - hpdmg - 10
= 9 - 5 - 10
= -6

-6 is not more than 0 so your script will return 0 which means "damage will proceed normally". 9hp suffers from damage of 5 so remaining health will be 4. As far as I know player who has 4hp is still alive.

old Re: Bonus dmg if..

Avo
User Off Offline

Quote
No, you're wrong.
return 0 means that damage is proceed normally
return 1 means that player don't get damage

old Re: Bonus dmg if..

Kisses
User Off Offline

Quote
user Avo has written
No, you're wrong.
return 0 means that damage is proceed normally
return 1 means that player don't get damage


Didn't I just say so?
Previous message has written
.. return 0 which means "damage will proceed normally"


Player who has 9hp and gets damage of 5 should die but your script lets him be alive.

old Re: Bonus dmg if..

Avo
User Off Offline

Quote
Maybe I'll surprise you, but I tested it and it works. Even if player's health is number lower than 10.

old Re: Bonus dmg if..

Kisses
User Off Offline

Quote
user Avo has written
Maybe I'll surprise you, but I tested it and it works. Even if player's health is number lower than 10.


Did you read my messages at all? I tested your script and it didn't work the way OP wanted.

> buy Mac 10
> set your friends health to 10
> shoot him
> he will have 1hp, but he should be dead

Summary: your script doesn't do its job. You must be stupid or very bored troll. I can confirm that mine and pikachus's one are working correctly.
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview