I've found how to use CallHook from any plugins.
basically we could use the old way and do something like: arenaplugin:canRedeemKit(player)Code:function PLUGIN:checkPlugins(player) local arr = util.TableToArray( { player } ) util.ConvertAndSetOnArray(arr, 0, player, UnityEngine.Object._type) local thereturn = plugins.CallHook("canRedeemKit", arr ) if(thereturn == nil) then return true end return false, tostring(thereturn) end
but the advantage of this is that if you want to make another plugin (another arena plugin, or block a player from using stuff, or what ever) you will NOT have to edit the original plugin.
you just have to add inside your new plugin:
function PLUGIN:canRedeemKit(player)
return "You can't redeem the kit
end
to block the kit from being redeemed.
[DOUBLEPOST=1417026836][/DOUBLEPOST]using 2 arguments will not work
local success, err = plugins.CallHook("watchEver", are)
as the CallHook may only send back 1 argument (the first one, so for success only, err will ALWAYS be nil)
CallHook
Discussion in 'Rust Development' started by Reneb, Nov 26, 2014.
-
I really like the idea of letting other plugin cancel actions.
The only problem I see is if 2 plugins "awnser" to the same callhook, only one awnser will be received. I don't think it's a big deal as the action will be cancelled anyway. -
yes exactly.
if both plugins don't return anything => then it will continue
if both plugins say that it can't continue => it will not continue
if 1 plugin out of the 2 say that it can't continue => it will not continue
so yeah it's exactly the thing that i was looking for