Forum




Changing Radio messages and wepaon names
22 replies1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("hit","_hit") weapon_names={ 	[1]="AWESOME USP" --USP 	--[ID]="new name" } function _hit(id,source,weapon,hpdmg,apdmg) 	if player(id,"health")-hpdmg<=0 then 		if weapon_names[weapon]~=nil then 			parse("customkill "..source.." \""..weapon_names[weapon].."\" "..id) 			return 1 		end 	end end
Custom Radio Messages:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("radio","_radio") function _radio(id,message) 	if message==0 then 		--Affirmative! 		message="Yes Sir!" 		sound="radio/affirm.ogg" 	--elseif message==1 then 		--message="your message" 		--sound="your sound" 	end 	if type(message)~="number" then 		for _,ids in ipairs(player(0,"team"..player(id,"team").."living")) do 			msg2(id,player(id,"name").." (Radio): "..message) 			parse("sv_sound2 "..ids.." \""..sound.."\"") 		end 		return 1 	end end

As you can see for the custom weapon names:
1
2
3
4
2
3
4
weapon_names={ [1]="AWESOME USP" --USP --[ID]="new name" }
It's pretty self explanatory, place the id of the weapon in braces and the new name in quotes.
For the custom radio messages you just need to figure out which message links to which number. Then you can change the message with "message=" and change the sound with "sound=".
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
weapon_names={ [1]="10mm Pistol" --USP --[1]=10mm Pistol end [2]="Plasma Defender" --Glock --[2]=Plasma Defender end end end
1
2
3
4
2
3
4
weapon_names={ [1]="10mm Pistol", [2]="Plasma Defender", }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
weapon_names={ [1]="10mm Pistol", [2]="Plasma Defender", [3]=".357 Magnum Revolver", [4]="9mm Pistol", [5]="5.56 Pistol", [6]="Laser Pistol", [10]="Hunting Shotgun", [11]="Riot Shotgun", [20]=".45 auto SMG", end end end
Why?
edited 1×, last 17.02.12 08:54:11 am
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
weapon_names={ 	[1]="10mm Pistol", 	[2]="Plasma Defender", 	[3]=".357 Magnum Revolver", 	[4]="9mm Pistol", 	[5]="5.56 Pistol", 	[6]="Laser Pistol", 	[10]="Hunting Shotgun", 	[11]="Riot Shotgun", 	[20]=".45 auto SMG", }

The lua name of it is weaponrename.lua, I typed in server.lua ("dofile(sys/lua/weaponrename.lua"), my mp_serverlua was server.lua and it doesn't work.
maybe you forgot to add a doublequote
1
dofile("sys/lua/weaponrename.lua")

is there a lua error?
maybe you forgot to add a doublequote
maybe you forgot to add a doublequote
1
dofile("sys/lua/weaponrename.lua")
That's what I typed, maybe the error has to do with notepad or the script itself.
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
my_array = { 	"trol", 	1 } my_second_array = { 	1, 	"two", 	"three" }

You probably wrote weapon_names twice and only had 1 weapon name changed in the example.
Note that this code is completely unchanged (so I'm saying this is your fault).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
weapon_names={ [1]="10mm Pistol", [2]="Plasma Defender", [3]=".357 Magnum Revolver", [4]="9mm Pistol", [5]="5.56 Pistol", [6]="Laser Pistol", [10]="Hunting Shotgun", [11]="Riot Shotgun", [20]=".45 auto SMG", } addhook("hit","_hit") function _hit(id,source,weapon,hpdmg,apdmg) 	if player(id,"health")-hpdmg<=0 then 		if weapon_names[weapon]~=nil then 			parse("customkill "..source.." \""..weapon_names[weapon].."\" "..id) 			return 1 		end 	end end
@


@
DannyDeth: Actually lua is pretty awesome, you can have commas at the last array key.

WUT? Seriously? I could have sworn that Lua threw a fit when you head extra commas.. or maybe it was C that i was thinking about.



What about this?
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
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
weapon_names={ [1]="10mm Pistol", end [2]="Plasma Defender", end [3]=".357 Magnum Revolver", end [4]="9mm Pistol", end [5]="5.56 Pistol", end [6]="Laser Pistol", end [10]="Hunting Shotgun", end [11]="Riot Shotgun", end [20]=".45 auto SMG" } addhook("hit","_hit") function _hit(id,source,weapon,hpdmg,apdmg) if player(id,"health")-hpdmg<=0 then if weapon_names[weapon]~=nil then parse("customkill "..source.." \""..weapon_names[weapon].."\" "..id) return 1 end end end
or
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
weapon_names={ [1]="10mm Pistol", [2]="Plasma Defender", [3]=".357 Magnum Revolver", [4]="9mm Pistol", [5]="5.56 Pistol", [6]="Laser Pistol", [10]="Hunting Shotgun", [11]="Riot Shotgun", [20]=".45 auto SMG" } addhook("hit","_hit") function _hit(id,source,weapon,hpdmg,apdmg) if player(id,"health")-hpdmg<=0 then if weapon_names[weapon]~=nil then parse("customkill "..source.." \""..weapon_names[weapon].."\" "..id) return 1 end end end
This is how I type the script in notepad

Note: The line after .45 SMG is nothing.
1
addhook("hit","whatever")

1
addhook("hit","hitshake")