• Unknown Command: 'ehs'
    12 replies, posted
Dumb question, but I'm rusty. I haven't scripted something in ages :D Anyway, problem is, I'm trying to create a console command client and so far it's not working... [code] ] lua_openscript_cl autorun\client\EHS.lua Running script autorun\client\EHS.lua... EHS :: INITIALIZING CORE... EHS :: INITIALIZATION COMPLETE... EHS :: INITIALIZING CORE ADDITIONS... EHS :: INITIALIZATION COMPLETE... EHS :: INITIALIZING ADDITIONS... EHS :: INITIALIZATION COMPLETE... ] ehs Unknown Command: 'ehs' [/code]ehs.lua is a rather large file, so I'm going to paste the lines that validate that I'm actually trying to create the console command and the callback does actually exists. [B]Lines 61-79[/B] [lua] EHS.ConsoleCommand = function(ply, command, args) for _,v in pairs(EHS.Commands) do if v.C == args[1] then if v.A then if EHS.InPassword == EHS.Password then table.remove(args, 1) v.F(args) else print("Authentication failed, this command is unavailable!") end else table.remove(args, 1) v.F(args) end end end end concommand.Add("ehs", EHS.ConsoleCommand) [/lua] I'm getting no errors, please slap me on the back of the head and point out the incredibly stupid mistake I'm making, oh mighty lau people? Also: Is it just me, or is the search not working?
Should it not be in client? I don't know much about lua but I thought you coudn't create commands clientside. Also dont trust me in saying this but im pretty sure concommand.add had to be used on a function like this: function EHS.consolecommand(ply, command, args)
[QUOTE=chonks;21236433]Should it not be in client? I don't know much about lua but I thought you coudn't create commands clientside. Also dont trust me in saying this but im pretty sure concommand.add had to be used on a function like this: function EHS.consolecommand(ply, command, args)[/QUOTE He had Con.Commandadd right. I think your right about clientside also.
You can use concommand.Add clientside and it will work fine.
[QUOTE=SSAAMM;21233937]Dumb question, but I'm rusty. I haven't scripted something in ages :D Anyway, problem is, I'm trying to create a console command client and so far it's not working... [code] ] lua_openscript_cl autorun\client\EHS.lua Running script autorun\client\EHS.lua... EHS :: INITIALIZING CORE... EHS :: INITIALIZATION COMPLETE... EHS :: INITIALIZING CORE ADDITIONS... EHS :: INITIALIZATION COMPLETE... EHS :: INITIALIZING ADDITIONS... EHS :: INITIALIZATION COMPLETE... ] ehs Unknown Command: 'ehs' [/code]ehs.lua is a rather large file, so I'm going to paste the lines that validate that I'm actually trying to create the console command and the callback does actually exists. [B]Lines 61-79[/B] [lua] EHS.ConsoleCommand = function(ply, command, args) for _,v in pairs(EHS.Commands) do if v.C == args[1] then if v.A then if EHS.InPassword == EHS.Password then table.remove(args, 1) v.F(args) else print("Authentication failed, this command is unavailable!") end else table.remove(args, 1) v.F(args) end end end end concommand.Add("ehs", EHS.ConsoleCommand) [/lua] I'm getting no errors, please slap me on the back of the head and point out the incredibly stupid mistake I'm making, oh mighty lau people? Also: Is it just me, or is the search not working?[/QUOTE] Aren't you supposed to change the first line of code to something like; [lua]function EHS.ConsoleCommand(ply, command, args)[/lua] instead of; [lua]EHS.ConsoleCommand = function(ply, command, args)[/lua] Might not change anything or I maybe did something wrong, but anyway, it's just what I thought.
Nah Sylph they're the same thing. Are you sure the code isn't erroring at all? Because that would cause the console command not registering. What if you put prints before and after it, for testing?
Yeah, I'm 100% sure that there's no errors. I'll add prints directly before and after trying to add the console command and let you know how it goes. But before that happens, I gotta go to the gym, I'll test it when I get back.
That part compares the Command in the Commands table of my system with argument one of the concommand. It's a cheap way of using only one console command. I'll show you when I get back [editline]08:24PM[/editline] Weird, it started working when I added the prints. Perhaps Garry's Mod just needed to restart.
You have to manually reload the script for changes to take effect.
Hm? That's the thing, I'd already reloaded the script using "reload", disconnecting then reconnecting, all the standard reload methods. Guess they all expire after a few uses.
Concommands are a bitch sometimes. Can take a few gmod restarts to get them working on rare occasions.
Well, it's working now, so I'm satisfied and I think we should let this thread die.
Sorry, you need to Log In to post a reply to this thread.