-
Notifications
You must be signed in to change notification settings - Fork 836
Expand file tree
/
Copy pathgame.lua
More file actions
54 lines (47 loc) · 1.31 KB
/
game.lua
File metadata and controls
54 lines (47 loc) · 1.31 KB
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
local AmmoTypes = {}
--
-- Called by modders to add a new ammo type.
-- Ammo types aren't something you can add on the fly. You have one
-- opportunity during loadtime. The ammo types should also be IDENTICAL on
-- server and client.
-- If they're not you will receive errors and maybe even crashes.
--
--
-- game.AddAmmoType(
-- {
-- name = "customammo",
-- dmgtype = DMG_BULLET,
-- tracer = TRACER_LINE_AND_WHIZ,
-- plydmg = 20,
-- npcdmg = 20,
-- force = 100,
-- minsplash = 10,
-- maxsplash = 100
-- })
--
function game.AddAmmoType( tbl )
if ( !isstring( tbl.name ) ) then
ErrorNoHalt( "bad argument #1 to 'AddAmmoType' ('name' key expected a string, got " .. type( tbl.name ) .. ")\n" )
return
end
local name = string.lower( tbl.name )
for id, ammo in ipairs( AmmoTypes ) do
if ( name == string.lower( ammo.name ) ) then
AmmoTypes[ id ] = tbl
return
end
end
table.insert( AmmoTypes, tbl )
end
--
-- Called by the engine to retrive the ammo types.
-- You should never have to call this manually.
--
function game.BuildAmmoTypes()
--
-- Sort the table by name here to assure that the ammo types
-- are inserted in the same order on both server and client
--
table.SortByMember( AmmoTypes, "name", true )
return AmmoTypes
end