Forum

> > CS2D > General > Changing Radio messages and wepaon names
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Changing Radio messages and wepaon names

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

old Re: Changing Radio messages and wepaon names

Apache uwu
User Off Offline

Quote
Custom Weapon Names:

1
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
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

old Re: Changing Radio messages and wepaon names

Apache uwu
User Off Offline

Quote
It's a custom script, you need to copy this into server.lua or whatever your mp_luaserver is.

As you can see for the custom weapon names:

1
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=".

old Re: Changing Radio messages and wepaon names

DevGru
User Off Offline

Quote
Do you think this will work?

1
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

old Re: Changing Radio messages and wepaon names

DevGru
User Off Offline

Quote
This didn't work.

1
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

old Re: Changing Radio messages and wepaon names

MikuAuahDark
User Off Offline

Quote
don't use end. table and function is diffrent!
1
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",
}

old Re: Changing Radio messages and wepaon names

DannyDeth
User Off Offline

Quote
There is an extra comma. You only need to add a comma if there is another element for the array afterwards:
1
2
3
4
5
6
7
8
9
10
my_array = {
	"trol",
	1
}

my_second_array = {
	1,
	"two",
	"three"
}
See what I mean? Remove the comma after the last thing from the list.

old Re: Changing Radio messages and wepaon names

Apache uwu
User Off Offline

Quote
@user DevGru: Works fine.


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

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

old Re: Changing Radio messages and wepaon names

DannyDeth
User Off Offline

Quote
user Apache uwu has written
@user 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. ( Sorry, but once you start with C, you never stop. It's strict-ass rules even affect you in life sometimes. )

old Re: Changing Radio messages and wepaon names

DevGru
User Off Offline

Quote
@user Apache uwu: It still doesn't work.

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

IMG:https://img585.imageshack.us/img585/4876/scripte.png


Note: The line after .45 SMG is nothing.
To the start Previous 1 2 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview