(Newbie) Needing Plugin Help (lua)
#1
Hello, I'm new to lua and I've started created plugins for a new server that I will be helping with, I made my first plugin and it was working fine until I went to go add the permissions, I looked at the file for the permissions then restarted the server, the console then gave my the following error:

Code:
LUA: 2 - Plugins/SeaCustom/main.lua:10: "BindCommand" function expects a function as its 3rd parameter. Command-binding aborted.

Error in plugin SeaCustom calling function Initialize()

Error in plugin SeaCustom: Cannot call the Initialize() function. Plugin is temporarily disabled.

cLuaState::Close: Trying to close an invalid LuaState, ignoring.

Here is the code (main.lua):
Code:
PLUGIN = {}
--Commands
function Initialize( Plugin )
    PLUGIN = Plugin

    Plugin:SetName( "SeaCustom" )
    Plugin:SetVersion( 0.1 )

    PluginManager = cRoot:Get():GetPluginManager()
    PluginManager:BindCommand("/heal",            "SeaCustom.heal",            HandleHealCommand,            " ~ Heal yourself!")
    PluginManager:BindCommand("/killstats",       "SeaCustom.killstats",       HandleKillStatsCommand,       " - Lose the game!")


    return true
    end
Since the errors are in the main.lua I don't think that the other lua would effect it (correct me if I'm wrong)

Any help would be greatly appreciated, if possible, an explanation would be nice but if there is none that is fineBig Grin
Reply
Thanks given by:
#2
Hello, welcome to the forum.
The error basically tells you that the 3rd parameter to BindCommand() is wrong. It also tries to guess what's wrong with it. In this case, it was expecting a function as the parameter, but you seem to give it something else. What is your HandleHealCommand, is it defined? Is it a function?
Reply
Thanks given by: Sea
#3
Yeah the problem is probably that you have not defined your function.
Reply
Thanks given by:
#4
Look at other plugins and see what's the correct way of binding commands
Reply
Thanks given by:
#5
Also a tip, if you post code on the forum you can use
Code:
[shcode=lua] Code here [/shcode]
to make it look right. then you get:
PLUGIN = {}
--Commands
function Initialize( Plugin )
    PLUGIN = Plugin

    Plugin:SetName( "SeaCustom" )
    Plugin:SetVersion( 0.1 )

    PluginManager = cRoot:Get():GetPluginManager()
    PluginManager:BindCommand("/heal",            "SeaCustom.heal",            HandleHealCommand,            " ~ Heal yourself!")
    PluginManager:BindCommand("/killstats",       "SeaCustom.killstats",       HandleKillStatsCommand,       " - Lose the game!")


    return true
end
Reply
Thanks given by: Sea
#6
Thanks for all the help guysBig Grin the main.lua wasn't the issue, it was that my Heal.lua had
function HandleKillStatsCommand( Split, Player )
instead of
function HandleHealCommand( Split, Player )
I guess I saved the killstats file it over on accidentTongue
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)