Any way to run a player command from a plugin? - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: Any way to run a player command from a plugin? (/thread-3340.html) |
Any way to run a player command from a plugin? - mueller_minki - 02-20-2021 Hello, I'm planning on making something that allows the console and command blocks to run commands as if they were a player. You would put like /run [SomePlayerCommand] inside of a command block and when powering it, it would execute it as if it was a player in the overworld with rank Admin. Has anyone done something like that before or knows what functions to call to make this work? And for all those shouting "Just use cPluginManager.ExecuteCommand": It doesn't seem to work correctly for my usecase. At least not in the way I tried to use it before. Here is my current code that doesn't work: Code: function run(Split) Edit: I'm so terrible at lua that even the help message won't work: Code: error in function 'BroadcastChatInfo'. RE: Any way to run a player command from a plugin? - NiLSPACE - 02-20-2021 Look at the API documentation for what ExecuteCommand function requires. It also requires a player object. Also, tostring(Split) isn't how you concatenate a table in Lua. You use table.concat for that. EDIT: Also, only functions marked in the documentation as STATIC require that you call the function with a period. Otherwise you can call the function with a colon without itself as the first argument. |