ULX

Author Topic: [ERROR] expected near '>'  (Read 2759 times)

0 Members and 1 Guest are viewing this topic.

Offline Panda

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
[ERROR] expected near '>'
« on: July 12, 2014, 03:20:47 AM »
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.

Code: [Select]
-- [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." )

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: [ERROR] expected near '>'
« Reply #1 on: July 12, 2014, 09:06:02 AM »
calling_ply:Give(Weapons[FV+i)
You forgot the ]

Offline Panda

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: [ERROR] expected near '>'
« Reply #2 on: July 12, 2014, 02:48:33 PM »
Wow, I'm a total derp.
Thanks!

Offline Panda

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: [ERROR] expected near '>'
« Reply #3 on: July 12, 2014, 04:00:31 PM »
Also, what would I use to make the players weapons be removed while they are in build mode? For example, if the player spawn a rocket launcher while in build mode? I don't need the code written out for me, I just would like a few pointers.

Here is the code as of now:
Code: [Select]
local CATEGORY_NAME = "Custom"


function ulx.build(calling_ply)

calling_ply:StripWeapons()
calling_ply:GodEnable()
calling_ply:Give("gmod_tool")
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_USER )
build:help( "Enables Build Mode, which allows you to build without being killed." )


function ulx.dm(calling_ply)

calling_ply:GodDisable()
calling_ply:Give("weapon_physgun")
ulx.fancyLogAdmin(calling_ply, "#A is now in DeathMatch Mode! Slaughter them!" )
end


local dm = ulx.command(CATEGORY_NAME, "ulx dm", ulx.dm, "!dm" )
dm:addParam{ type=ULib.cmds.PlayersArg }
dm:defaultAccess( ULib.ACCESS_USER )
dm:help( "Enables DeathMatch Mode, which enables you to be killed." )

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: [ERROR] expected near '>'
« Reply #4 on: July 12, 2014, 07:31:27 PM »
Could tinker with http://wiki.garrysmod.com/page/GM/PlayerSwitchWeapon or http://wiki.garrysmod.com/page/GM/WeaponEquip
There's other ways, but I've forgotten key term to search the wiki for.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: [ERROR] expected near '>'
« Reply #5 on: July 12, 2014, 07:32:36 PM »
Could tinker with http://wiki.garrysmod.com/page/GM/PlayerSwitchWeapon or http://wiki.garrysmod.com/page/GM/WeaponEquip
There's other ways, but I've forgotten key term to search the wiki for.
I believe you're looking for GM:PlayerCanPickupWeapon

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: [ERROR] expected near '>'
« Reply #6 on: July 12, 2014, 08:10:38 PM »
Yep, that's one.
Done right, he might not even need to strip the other weapons, just use that and switchweapon to make sure nothing being used other than tool or camera or other approved stuff, and viola!
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming