I´m a littlebit confused about my problem:
I´m running this small script:
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
-- Just the numbers from 1 to 91 table1 = {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,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91} addhook("attack","fame") function fame(id) 		-- string.char(169) = © ((C)) - Just for the colour. Ignore it! 		msg2(id,string.char(169).."255255255Your Weapon-ID: "..table1[player(id,"weapontype")].."@C") 	end end
The problem:
Usually, on every attack the script says:
Your Weapon-ID: <weapontype>
If you shot with an USP then it says:
Your Weapon-ID: 1
If I´m throwing my HE (ID: 51) then this error appears in the console:
1
LUA ERROR: sys/lua/test.lua:6: attempt to concatenate field '?' (a nil value)
Then I thought, I change the code a littlebit:
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
-- Just the numbers from 1 to 91 table1 = {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,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91} addhook("attack","fame") function fame(id) 	-- 51 = HE, 52 = Flashbang, etc. almost every grenade 	if player(id,"weapontype")~=51 or player(id,"weapontype")~=52 or player(id,"weapontype")~=53 or player(id,"weapontype")~=54 or player(id,"weapontype")~=75 or player(id,"weapontype")~=76 or player(id,"weapontype")~=77 or player(id,"weapontype")~=86 or player(id,"weapontype")~=87 or player(id,"weapontype")~=89 then 	msg2(id,string.char(169).."255255255Your Weapon-ID: "..table1[player(id,"weapontype")].."@C") end end
If my code is like this:
1
2
3
4
2
3
4
addhook("attack","fame") function fame(id) 	msg2(id,string.char(169).."255255255Your Weapon-ID: "..player(id,"weapontype").."@C") end
Your Weapon-ID: 0
Thanks for reading this!