Cuberite Forum

Full Version: Lua hooks needed!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13
yes i want to make a login system but i don't want the server admin first edit the Groups.ini before he can use it. I want a "plug and play" plugin Smile
I have added a HOOK_EXECUTE_COMMAND hook that fires just before a command handler for the command or console command is executed. The command is already known to have been bound; the permissions haven't been checked yet though.

Note that the same hook is called for both in-game commands and console commands. To tell them apart, use the first parameter, which is the cPlayer issuing the in-game command, or nil for console commands.
so i should do something like this:
function OnExecuteCommand(Player, Command) 
if Auth[Player:GetName()] == false then
    if Command ~= "/login" then
        return true
    end
end
end
You need to first check if you're getting a Player at all - compare to nil. And don't compare to booleans, that is bad practice and can lead to errors (in C/C++, it is possible that "true != true")

Code:
function OnExecuteCommand(Player, CommandSplit)
  if (Player == nil) then
    return false;
  end

  if (Auth[Player:GetName()]) then
    return false;
  end

  if (CommandSplit[0] ~= "/login") then
    return true
  end
end
is there a OnBlockChange or something that fires when the fire simulator is working or the fluid simulator or anything else that isn't a player that changes a block?
I don't think so, because that would put quite a strain. Already the blockchanges are the most expensive operation of the TickThread.

What if, instead, you could ask at each tick for the list of changed blocks, per chunk? That, to me, seems more likely to get implemented.
yes that could be usefull Wink
Still, don't count on that being added anytime soonTongue
Maybe you can also add a OnTakingDamage and if you do return true you won't even get the damage animation.
OnTakeDamage is already working as an "in progress"-style hook, so I'd rather add some kind of processing to that, perhaps adding a new member to TakeDamageInfo.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13