Files

> > CS2D > Lua Scripts > NWH(New Ways to Hook)
Files overviewCS2D overviewLua Scripts overview

English NWH(New Ways to Hook) >

1 comment900 b, 370 Downloads

old NWH(New Ways to Hook)

MikuAuahDark
User Off Offline

New Ways to Hook by MikuAuahDark(user MikuAuahDark)

∗ Description ∗
NWH create a function that extends cs2d lua cmd addhook & cs2d lua cmd freehook function

∗ Features ∗
• > No Conflicting Hooks
• > Use function address instead of string
• > On first add, it only need 1 hook only
• > Return 0 would cause the another code to called
• > Priority depending by ID(1 is the highest)

∗ How to Install ∗
• 1. extract nwh.txt to desired folder(or just extract "sys" folder at cs2d folder and it will merged)
• 2. add to server.lua: dofile"sys/lua/nwh.txt"
• 3. save and done

∗ Reserved Global Variables ∗
> Hooks
> AddHook(NOT cs2d lua cmd addhook)
> FreeHook(NOT cs2d lua cmd freehook)
> (All function name start from "temporary_<hook>")

∗ Information ∗
> Hooks: depending how many hooks used
> Lines: 64
> Size: 1787 Bytes
> Importat Function: AddHook, FreeHook

∗ Limitations ∗
> Priority is set depending by ID(1 is highest)
> ID of hook is separated(using "say" and then "sayteam" hook at same function would always return 1)

∗ Functions ∗
• NOTE: Function listen here is Case-Sensitive
> AddHook(hook(string),func(string/function))
• Parameters:
• - hook, the hook name(list is here)
• - func, function to executed when event occurs
• ∗ Returns: ID of the hook(separated)(number)
• ∗ On Error, it would return 0 and the string of the error
• Example:
1
HookID=AddHook("say",function(id,txt) print(id.." "..txt) end)
> FreeHook(hook(string),id(number))
• Parameters:
• - hook, what hook to removed
• - id, the separated ID of the hook
• ∗ Returns: it's removed or not(boolean)
• Example:
1
print(tostring(FreeHook("say",HookID)))

∗ Tip ∗
• Return code on function is:
• 0 - Execute another function with same hook
• 1(or up) - Don't execute another functon until this event is triggered again

∗ Rules ∗
√ You can use it for your server
√ You can edit it
√ You can upload at another website, say MikuAuahDark or user MikuAuahDark made it
× You can't say this is yours
× You can't upload on another website without put me on credits

∗ Notes
• 1. When table containing the function list to executed is empty(for "this" hook), the hook would be free itself
• 2. I would recommended that this function is executed first at server.lua

∗ Version History ∗
> v1.0
ADDED
Initial Release
edited 2×, last 19.07.13 12:43:17 am
Approved by Seekay

Download Download

900 b, 370 Downloads

Comments

1 comment
To the start Previous 1 Next To the start

Log in!

You need to log in to be able to write comments!Log in

old

mafia_man
User Off Offline

Pointless thing.
To the start Previous 1 Next To the start