Benny/gamemodes/benny/gamemode/shared.lua

65 lines
1.5 KiB
Lua

GM.Name = "Your Name Is Benny"
GM.Author = "Fesiug, Oranche, Alex"
GM.Email = "N/A"
GM.Website = "N/A"
BENNY = {}
function BENNY.SimpleAutoComplete( cmd, args, ... ) -- just stole it from the wiki
local possibleArgs = { ... }
local autoCompletes = {}
--TODO: Handle "test test" "test test" type arguments
args = args:upper()
local arg = string.Split( args:TrimLeft(), " " )
local lastItem = nil
for i, str in pairs( arg ) do
if ( str == "" && ( lastItem && lastItem == "" ) ) then table.remove( arg, i ) end
lastItem = str
end -- Remove empty entries. Can this be done better?
local numArgs = #arg
local lastArg = table.remove( arg, numArgs )
local prevArgs = table.concat( arg, " " )
if ( #prevArgs > 0 ) then prevArgs = " " .. prevArgs end
local possibilities = possibleArgs[ numArgs ] or { lastArg }
for _, acStr in pairs( possibilities ) do
if ( !acStr:StartsWith( lastArg ) ) then continue end
table.insert( autoCompletes, cmd .. prevArgs .. " " .. acStr )
end
return autoCompletes
end
local AC, IN = AddCSLuaFile, include
local CL = SERVER and AddCSLuaFile or include
function TSelShared( tbl, seed )
return tbl[math.Round( util.SharedRandom( seed, 1, #tbl ) )]
end
AC("language.lua")
IN("language.lua")
AC("camera.lua")
IN("camera.lua")
AC("items.lua")
IN("items.lua")
AC("player.lua")
IN("player.lua")
AC("player_class.lua")
IN("player_class.lua")
AC("inventory.lua")
IN("inventory.lua")
AC("gamestate.lua")
IN("gamestate.lua")
AC("teams.lua")
IN("teams.lua")
AC("debugmenu.lua")
IN("debugmenu.lua")
CL("hud.lua")