It's my first attempt on making custom ulx commands.
Im a total newb at this
Here is the code. The error is commented at the top of the script.
-- [ERROR] expected near '>'
-- 1. unknown addons/ulx/lua/ulx/modules/sh/extras.lua:0
local CATEGORY_NAME = "Custom"
function ulx.build(calling_ply)
local Weapons = {}--Weapon strings will be stored here
local Weps = calling_ply:GetWeapons()--Gets all the weapon names from the players inv
for _,v in pairs(Weps) do--Takes all the weapon names and stores then in the "Weapons" table
table.insert(Weapons,v)
end
calling_ply:StripWeapons() --takes all the weapons away
calling_ply:GodEnable() -- enables God Mode
calling_ply:Give("gmod_tool")--Gives the player a toolgun and a physgun
calling_ply:Give("weapon_physgun")
ulx.fancyLogAdmin( calling_ply, "#A is now in Build Mode and is now un-killable." )
end
local build = ulx.command(CATEGORY_NAME,"ulx build", ulx.build, "!build" )
build:addParam{ type=ULib.cmds.PlayersArg }
build:defaultAccess( ULib.ACCESS_SUPERADMIN )
build:help( "Enables Build Mode, which allows you to build without being killed." )
function ulx.dm(calling_ply)
LV = #Weapons --Number of values in the Weapons table and the number of the last value.
FV = #Weapons-#Weapons+1 --Gets the first value of the Weapons table, IE, 1
calling_ply:GodDisable() -- Self explanatory
calling_ply:Give("weapon_physgun")
for i = 1,LV do --Gives the player all the weapons back according to the table value defined in [FV+i]
calling_ply:Give(Weapons[FV+i)
ulx.fancyLogAdmin(calling_ply, "#A is now in DeathMatch Mode! Slaughter them!" )
end
end
local dm = ulx.command(CATEGORY_NAME, "ulx dm", ulx.dm, "!dm" )
dm:addParam{ type=ULib.cmds.PlayersArg }
dm:defaultAccess( ULib.ACCESS_SUPERADMIN )
dm:help( "Enables DeathMatch Mode, which enables you to be killed." )