summaryrefslogtreecommitdiff
path: root/gamemode/items.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/items.lua')
-rw-r--r--gamemode/items.lua64
1 files changed, 29 insertions, 35 deletions
diff --git a/gamemode/items.lua b/gamemode/items.lua
index 7b3a057..f3d802c 100644
--- a/gamemode/items.lua
+++ b/gamemode/items.lua
@@ -5,15 +5,15 @@ local ItemTables = {}
local ID = 1
function Register( tbl )
-
+
tbl.Functions = tbl.Functions or {}
tbl.ID = ID
ItemTables[ ID ] = tbl
-
+
util.PrecacheModel( tbl.Model )
-
+
ID = ID + 1
-
+
end
function GetList()
@@ -25,37 +25,37 @@ end
function GetByID( id )
if not id then return end
-
+
if !ItemTables[ id ] then return end
return ItemTables[ id ]
-
+
end
function GetByModel( model )
-
+
for k,v in pairs( ItemTables ) do
-
+
if string.lower( v.Model ) == string.lower( model ) or ( v.DropModel and string.lower( v.DropModel ) == string.lower( model ) ) then
-
+
return v
-
+
end
-
+
end
end
function GetByClass( class )
-
+
for k,v in pairs( ItemTables ) do
-
+
if v.TypeOverride and string.lower( v.TypeOverride ) == string.lower( class ) then
-
+
return v
-
+
end
-
+
end
end
@@ -63,13 +63,13 @@ end
function GetByName( name )
for k,v in pairs( ItemTables ) do
-
+
if string.lower( v.Name ) == string.lower( name ) then
-
+
return v
-
+
end
-
+
end
end
@@ -77,17 +77,17 @@ end
function GetByType( itemtype )
local tbl = {}
-
+
for k,v in pairs( ItemTables ) do
-
+
if v.Type == itemtype then
-
+
table.insert( tbl, v )
-
+
end
-
+
end
-
+
return tbl
end
@@ -98,19 +98,13 @@ function RandomItem( itemtype )
local tbl = GetByType( itemtype )
local rand = table.Random( tbl )
-
+
while math.Rand(0,1) < rand.Rarity do
-
+
rand = table.Random( tbl )
-
+
end
return rand
end
-
-
-
-
-
-