function OnTypeCommand takes nothing returns boolean
local string s = GetEventPlayerChatString()
local integer i = 1
local integer i2 = StringLength(s)
local integer i3
loop
exitwhen i == i2
call FireEvent(LoadInteger(udg_Command_Table, StringHash(SubString(s, i, i + 2)), 0))
set i = i + 2
endloop
endfunction
function InitCommand takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i == 12
call TriggerRegisterPlayerChatEvent(t, Player(i), "-", false)
set i = i + 1
endloop
call TriggerAddCondition(t, Condition(function OnTypeCommand))
set udg_Command_Table = InitHashtable()
endfunction
function CreateCommand takes string command returns nothing
if null == udg_Command_Table then
call InitCommand()
endif
set command = SubString(command, 0, 2)
call SaveInteger(udg_Command_Table, StringHash(command), 0, CreateEvent())
set udg_Commands = udg_Commands + 1
set udg_Command[udg_Commands] = command
endfunction
function RegisterCommandEvent takes string command, code c returns nothing
call RegisterEvent(c, LoadInteger(udg_Command_Table, StringHash(command), 0))
endfunction
function TriggerRegisterCommandEvent takes string command, trigger t returns nothing
call TriggerRegisterEvent(t, LoadInteger(udg_Command_Table, StringHash(command), 0))
endfunction