• DarkRP.defineChatCommand() - Help with solving...
    5 replies, posted
Hello FP, I'm wondering if anyone can tell me if it's possible to have extra arguments in the 'DarkRP.defineChatCommand()', just to not confuse you this is a normal chat command below. [CODE] local function ChatCommand( ply, args) end DarkRP.defineChatCommand("nopurpose", ChatCommand) [/CODE] Now hear me out, what I'm trying to do is add extra arguments to that chat command, as above in the function the arguments are 'ply' for player and 'args' for arguments. So if we did /nopurpose hi, hi would be args. But to come to final summary I'm asking is there a way to add more args? i.e /mycommand arg arg1 arg2? Thank you, your help is greatly appreciated.
Args is a table and every word after is an entry on the table /admintome kidd12 bully args[1] would me kidd12 args[2] is bully More info here [url]https://www.lua.org/pil/2.5.html[/url]
As far as I can tell, everything entered after the command is returned by the second parameter as a string (args in your function). So you'd have to split up the arguments yourself.
[QUOTE=Blinkenn;51788082]Args is a table and every word after is an entry on the table /admintome kidd12 bully args[1] would me kidd12 args[2] is bully More info here [url]https://www.lua.org/pil/2.5.html[/url][/QUOTE] From what I've experience in the past all through testing args isn't a table of a sort, args[1] means the first character so if we did /cmd Hello, args[1] would return 'H'
[code] local function chatCommand(ply, args) args = DarkRP.explodeArgs(args) end DarkRP.defineChatCommand("nopurpose", chatCommand) [/code] [editline]7th February 2017[/editline] [url]https://github.com/FPtje/DarkRP/blob/master/gamemode/modules/base/sh_util.lua#L222[/url]
[QUOTE=Fruitwesp;51788923][code] local function chatCommand(ply, args) args = DarkRP.explodeArgs(args) end DarkRP.defineChatCommand("nopurpose", chatCommand) [/code] [editline]7th February 2017[/editline] [url]https://github.com/FPtje/DarkRP/blob/master/gamemode/modules/base/sh_util.lua#L222[/url][/QUOTE] You absolute life saver! Thank you so much, I love you so dearly... [editline]7th February 2017[/editline] [QUOTE=Fruitwesp;51788923][code] local function chatCommand(ply, args) args = DarkRP.explodeArgs(args) end DarkRP.defineChatCommand("nopurpose", chatCommand) [/code] [editline]7th February 2017[/editline] [url]https://github.com/FPtje/DarkRP/blob/master/gamemode/modules/base/sh_util.lua#L222[/url][/QUOTE] Time to cry, it doesn't work, prints a nil valaue when I try 'PrintTable( args )', any solution?
Sorry, you need to Log In to post a reply to this thread.