• Send variables to console?
    7 replies, posted
How would I go about sending a variable to the console? I wanna do something like: [CODE]local somevar = "player" ply:ConCommand("give", somevar, "weapon_smg")[/CODE]
There is two ways to do it: [lua] -- You can write a complete line like this LocalPlayer():ConCommand("say Hello, I didn't type this.") -- Or you can use this RunConsoleCommand("say", "Hello, I didn't type this.") [/lua]
[QUOTE=ms333;38649740]There is two ways to do it: [lua] -- You can write a complete line like this LocalPlayer():ConCommand("say Hello, I didn't type this.") -- Or you can use this RunConsoleCommand("say", "Hello, I didn't type this.") [/lua][/QUOTE] No.. I mean send a variable through a console command. As I stated above.... But the method I posted doesn't work.
concommand.Add("mycommand", function(args) PrintTable(args) end) RunConsoleCommand("mycommand", "lolarg", 4534, "penis")
[lua] local var = "thisisavariable" RunConsoleCommand("give",var,"weapon_smg") [/lua]
Guys, the real answer here is it is only possible to send strings through console. (And numbers, yes) Any other data will have to be split into strings, sent, and then reassembled serverside. The 'right' way to send variables like this is the net library.
[QUOTE=ollie;38649886][lua] local var = "thisisavariable" RunConsoleCommand("give",var,"weapon_smg") [/lua][/QUOTE] [QUOTE=Donkie;38649786]concommand.Add("mycommand", function(args) PrintTable(args) end) RunConsoleCommand("mycommand", "lolarg", 4534, "penis")[/QUOTE] RunConsoleCommand did the trick! Apparently player:ConCommand() can't take variables.
[QUOTE=allnewryan1;38650547]RunConsoleCommand did the trick! Apparently player:ConCommand() can't take variables.[/QUOTE] You can always do ply:ConCommand("blablabla"..variable.."moreblabla"), but only works for string and numbers.
Sorry, you need to Log In to post a reply to this thread.