Forum

> > CS2D > Scripts > Lua Error - Custom kill
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Error - Custom kill

5 replies
To the start Previous 1 Next To the start

old Lua Error - Custom kill

Infinite Rain
Reviewer Off Offline

Quote
I want to make a turrets that you can sit in it and controll
But I got problem with customkill:

Here is the script:
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

old Re: Lua Error - Custom kill

MikuAuahDark
User Off Offline

Quote
wee we have same problem, i think use strinng.format work, just like this:
1
parse(string.format('customkill %s %s %s", source, turrets[entered[source]][7], id))
maybe work

old Re: Lua Error - Custom kill

Unknown_Soldier
User Off Offline

Quote
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
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)

old Re: Lua Error - Custom kill

Apache uwu
User Off Offline

Quote
Try this.

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

old Re: Lua Error - Custom kill

Infinite Rain
Reviewer Off Offline

Quote
Thanks Context but it must be:
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
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview