Lua hooks needed!
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
Reply
Thanks given by:
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.
Reply
Thanks given by: NiLSPACE
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
Reply
Thanks given by:
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
Reply
Thanks given by: NiLSPACE
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?
Reply
Thanks given by:
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.
Reply
Thanks given by:
yes that could be usefull Wink
Reply
Thanks given by:
Still, don't count on that being added anytime soonTongue
Reply
Thanks given by:
Maybe you can also add a OnTakingDamage and if you do return true you won't even get the damage animation.
Reply
Thanks given by:
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.
Reply
Thanks given by:




Users browsing this thread: 8 Guest(s)