English Lua Error - Custom kill

5 replies
Goto Page
To the start Previous 1 Next To the start
18.08.11 12:56:27 pm
Up
Infinite Rain
Reviewer
Offline Off
I want to make a turrets that you can sit in it and controll
But I got problem with customkill:

Here is the script:
Code:
1
2
3
4
5
6
7
8
9
function hit_hook(id, source, weapon, hpdmg, apdmg)
     if entered[source] ~= 0 then
          parse('sethealth '.. id ..' '.. player(id, 'health') - turrets[entered[source]][4])
          if player(id, 'health') < 1 then
               parse('customkill '.. source ..' '.. turrets[entered[source]][7] ..' '.. id)
          end
          return 1
     end
end


There is no error
Just not working
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
18.08.11 01:11:53 pm
Up
MikuAuahDark
User
Offline Off
wee we have same problem, i think use strinng.format work, just like this:
Code:
1
parse(string.format('customkill %s %s %s", source, turrets[entered[source]][7], id))

maybe work
file cs2d LuaJIT for Dedicated Server (13) JIT POWER! | Know your Lua errors! | Part of LÖVE development team since 11.3
18.08.11 01:22:53 pm
Up
Infinite Rain
Reviewer
Offline Off
No, its not working
And my string is 100% right
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
18.08.11 05:23:06 pm
Up
Unknown_Soldier
User
Offline Off
I think the problem is the hook, because a function with the hook "hit" reacts before the damage

For example, I have 20 HP, and you shoot me with a deagle, it is an instant kill, but the script reacts first, and the player(id,"health") will return 20

you should change the second if to
Code:
1
if player(id, 'health') - hpdmg < 1 then

with that, it will check if the damage after the shot is < 1 (correct me if I am wrong)
Should I come back and make one last map for CS2D?
18.08.11 08:37:36 pm
Up
Apache uwu
User
Offline Off
Try this.

Code:
1
2
3
4
5
6
7
8
9
10
function hit_hook(id, source, weapon, hpdmg, apdmg)
     if entered[source] ~= 0 then
          if player(id, 'health')-hpdmg <= 0 then
               parse('customkill '.. source ..' '.. turrets[entered[source]][7] ..' '.. id)
          else
               parse('sethealth '.. id ..' '.. player(id, 'health') - turrets[entered[source]][4])
          end
          return 1
     end
end
18.08.11 08:58:19 pm
Up
Infinite Rain
Reviewer
Offline Off
Thanks Context but it must be:
Code:
1
2
3
4
5
6
7
8
9
10
function hit_hook(id, source, weapon, hpdmg, apdmg)
     if entered[source] ~= 0 then
          if player(id, 'health') - turrets[entered[source]][4] <= 0 then
               parse('customkill '.. source ..' '.. turrets[entered[source]][7] ..' '.. id)
          else
               parse('sethealth '.. id ..' '.. player(id, 'health') - turrets[entered[source]][4])
          end
          return 1
     end
end


Theres is custom damage for weapon tanks BTW
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
To the start Previous 1 Next To the start