Forum

> > CS2D > Scripts > If silenced / knife kill then..
Forums overviewCS2D overview Scripts overviewLog in to reply

English If silenced / knife kill then..

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

old If silenced / knife kill then..

Alistaire
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
23
24
addhook("objectkill","Collectables_objectkill_hook")
function Collectables_objectkill_hook(dynid, i)
	if object(dynid, "type") == 30 then
		if player(id, "weapontype") == 2 and item(id, 'mode") == 2 then
			Col2-2_Collected = Col2-2_Collected + 1
			parse('hudtxt 2 "'..Col2-2_Collected..'" 40 388 3')
			for n, w in ipairs(player(0, 'tableliving')) do
				parse('setmoney '..w..' '..player(w, 'money')+20)
			end
		elseif player(id, "weapontype") == *knife* then
			Col2-3_Collected = Col2-3_Collected + 1
			parse('hudtxt 2 "'..Col2-3_Collected..'" 40 388 3')
			for n, w in ipairs(player(0, 'tableliving')) do
				parse('setmoney '..w..' '..player(w, 'money')+30)
			end
		else 
			Col2_Collected = Col2_Collected + 1
			parse('hudtxt 2 "'..Col2_Collected..'" 40 388 3')
			for n, w in ipairs(player(0, 'tableliving')) do
				parse('setmoney '..w..' '..player(w, 'money')+10)
			end
		end
	end
end

Is there a way to get the player like Col2-2_Collected if the kill was silenced and Col2-3_Collected if it was a knifekill?

I just used my Lua knowledge for this, but it doesn't work (of course..).

----

Also, what is the weapontype of a knife? If I need it for the script of course.
edited 1×, last 12.01.12 05:52:21 pm

old Re: If silenced / knife kill then..

Apache uwu
User Off Offline

Quote
hmm weapon types are listed @ env_item in the editor

Knife is 50


A silenced kill is different from a lethal knife kill, to check if it's a kill from a silenced you need to probably hold a boolean table of all the weapons from the players...

old Re: If silenced / knife kill then..

Alistaire
User Off Offline

Quote
Spoiler >


Oh wow! The knifekill is actually working!

I just don't know about the silenced kill.

old Re: If silenced / knife kill then..

TimeQuesT
User Off Offline

Quote
Get a table of all items -->

item(0,"table");


check each item in the table if it contains to the player-->

item(int,"player") could help.

--> check the item type -->
check the item mode -->

hooray you're done!

old Re: If silenced / knife kill then..

TimeQuesT
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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
addhook("objectkill","Collectables_objectkill_hook")
function Collectables_objectkill_hook(dynid, id)


tiThisIsTable = item(0,"table");
bLetPass = false;

for i=1,#tiThisIsTable do

if (item(i,"player")==id and item(i,"type")==player(id,"weapontype") and item(i,"mode")==2) then
bLetPass = true;
break;
end

end

if (bLetPass) then
     if object(dynid, "type") == 30 then
          if player(id, "weapontype") == 2 and item(id, 'mode") == 2 then
               Col2-2_Collected = Col2-2_Collected + 1
               parse('hudtxt 2 "'..Col2-2_Collected..'" 40 388 3')
               for n, w in ipairs(player(0, 'tableliving')) do
                    parse('setmoney '..w..' '..player(w, 'money')+20)
               end
          elseif player(id, "weapontype") == *knife* then
               Col2-3_Collected = Col2-3_Collected + 1
               parse('hudtxt 2 "'..Col2-3_Collected..'" 40 388 3')
               for n, w in ipairs(player(0, 'tableliving')) do
                    parse('setmoney '..w..' '..player(w, 'money')+30)
               end
          else
               Col2_Collected = Col2_Collected + 1
               parse('hudtxt 2 "'..Col2_Collected..'" 40 388 3')
               for n, w in ipairs(player(0, 'tableliving')) do
                    parse('setmoney '..w..' '..player(w, 'money')+10)
               end
          end
     end
end
end

Should work

edit:

Why the heck you named the second parameter "i" --> changed to id.
edited 1×, last 12.01.12 09:07:29 pm

old Re: If silenced / knife kill then..

Alistaire
User Off Offline

Quote
Nope.

----

The start post is all messy. Use this one instead;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("objectkill","Collectables_objectkill_hook")
function Collectables_objectkill_hook(dynid, i)
	if object(dynid, "type") == 30 then
		if player(id, "weapontype") == 2 and item(id, "mode") == 1 then
			Col2_2_Collected = Col2_2_Collected + 1
			money_killtype="20"
		elseif player(id, "weapontype") == 50 then
			Col2_3_Collected = Col2_3_Collected + 1
			money_killtype="30"
		else 
			Col2_Collected = Col2_Collected + 1
			money_killtype="10"
		end
		parse('hudtxt 2 "'..Col2_Collected..' / '..Col2_2_Collected..' / '..Col2_3_Collected..'" 40 388 3')
		for n, w in ipairs(player(0, 'tableliving')) do
			parse('setmoney '..w..' '..player(w, 'money')+money_killtype)
		end
	end
end

The USP silenced shit still doesn't work here tho.

old Re: If silenced / knife kill then..

TimeQuesT
User Off Offline

Quote
Okay then, here we go!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
addhook("objectkill","Collectables_objectkill_hook")
function Collectables_objectkill_hook(dynid, id)
tiThisIsTable = item(0,"table");
bLetPass = false;

for i=1,#tiThisIsTable do
if (item(i,"player")==id and item(i,"type")==player(id,"weapontype") and item(i,"mode")==2) then
bLetPass = true;
break;
end
end


if (bLetPass) then
	if object(dynid, "type") == 30 then
		if player(id, "weapontype") == 2 then
			Col2_2_Collected = Col2_2_Collected + 1
			money_killtype="20"
		elseif player(id, "weapontype") == 50 then
			Col2_3_Collected = Col2_3_Collected + 1
			money_killtype="30"
		else 
			Col2_Collected = Col2_Collected + 1
			money_killtype="10"
		end
		parse('hudtxt 2 "'..Col2_Collected..' / '..Col2_2_Collected..' / '..Col2_3_Collected..'" 40 388 3')
		for n, w in ipairs(player(0, 'tableliving')) do
			parse('setmoney '..w..' '..player(w, 'money')+money_killtype)
		end
	end
end
end

old Re: If silenced / knife kill then..

MikuAuahDark
User Off Offline

Quote
hmm
untested >

old Re: If silenced / knife kill then..

EngiN33R
Moderator Off Offline

Quote
I'll add to everyone's speculations.

In theory, this should work:
Spoiler >

old Re: If silenced / knife kill then..

Alistaire
User Off Offline

Quote
user MikuAuahDark has written
hmm
untested >


It returns some Lua errors;

I made the script into this:

Spoiler >


But, it doesn't seem to see play[id].silenced as an existing value. That's the major problem atm.
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview