English Bonus dmg if..

20 replies
Goto Page
To the start Previous 1 2 Next To the start
08.06.12 08:05:42 pm
Up
Sudden Death
User
Offline Off
Hi, i was doing script, but suddenly this won't work:
Code:
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
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
08.06.12 08:09:02 pm
Up
EP
User
Offline Off
Code:
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".
08.06.12 08:13:55 pm
Up
Sudden Death
User
Offline Off
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
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
09.06.12 05:56:55 am
Up
omg
User
Offline Off
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
Code:
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
will code for food
09.06.12 12:09:00 pm
Up
Sudden Death
User
Offline Off
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
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
10.06.12 12:56:20 pm
Up
Kisses
User
Offline Off
Code:
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
probably hate me, I do too
10.06.12 01:00:39 pm
Up
Cure Pikachu
User
Offline Off
@user Kisses: You can't kill someone with sethealth.
Code:
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
IMG:https://i.imgur.com/uUrye71.png
IMG:https://i.imgur.com/xpsyQRX.png
10.06.12 01:05:56 pm
Up
Kisses
User
Offline Off
user Cure Pikachu has written:
@user Kisses: You can't kill someone with sethealth.

I'm not killing anyone with sethealth.

> health-10 isn't negative
> hpdmg isn't negative
probably hate me, I do too
10.06.12 01:10:21 pm
Up
user Cure Pikachu has written:
@user Kisses: You can't kill someone with sethealth.
You can.
10.06.12 01:13:38 pm
Up
Avo
User
Offline Off
Yes, try this:
Code:
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.
10.06.12 01:19:14 pm
Up
Kisses
User
Offline Off
user Avo has written:
Yes, try this:
Code:
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
probably hate me, I do too
10.06.12 01:31:07 pm
Up
Sudden Death
User
Offline Off
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.
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
10.06.12 01:40:52 pm
Up
Kisses
User
Offline Off
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?

Code:
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 >
probably hate me, I do too
10.06.12 02:06:35 pm
Up
Avo
User
Offline Off
Code:
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.
10.06.12 02:26:45 pm
Up
Kisses
User
Offline Off
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.
probably hate me, I do too
10.06.12 03:41:49 pm
Up
Avo
User
Offline Off
No, you're wrong.
return 0 means that damage is proceed normally
return 1 means that player don't get damage
10.06.12 03:52:47 pm
Up
Sudden Death
User
Offline Off
YESSS, thx you Bolt!
Sniffin'Man "If it cannot be done with lua, it must be you mama, coz she's too fat"
10.06.12 04:27:49 pm
Up
Kisses
User
Offline Off
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.
probably hate me, I do too
10.06.12 04:32:43 pm
Up
Avo
User
Offline Off
Maybe I'll surprise you, but I tested it and it works. Even if player's health is number lower than 10.
10.06.12 04:39:08 pm
Up
Kisses
User
Offline Off
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.
probably hate me, I do too
To the start Previous 1 2 Next To the start