Tired of kiddies typing cheats in public chat, ruining your work?
Well, i'm not, cause i don't use cheats. But if you do, here is the answer to your problems.
Quote:
function ActivationSystemReset takes nothing returns nothing
call SetHandleBoolean(GetHandleTrigger(GetExpiredTimer(), "trigref"), "running", false)
endfunction
function ActivationSystem takes nothing returns nothing
local trigger tr = GetTriggeringTrigger()
local timer t = GetHandleTimer(tr, "timer")
local integer i = 0
local real duration = 1.5-TimerGetRemaining(t)
if GetHandleBoolean(tr, "running") then
call SetHandleInt(tr, "passes", GetHandleInt(tr, "passes")-1)
if duration>GetHandleReal(tr, "max") then
call SetHandleReal(tr, "max", duration)
endif
if duration<GetHandleReal(tr, "min") then
call SetHandleReal(tr, "min", duration)
endif
call SetHandleReal(tr, "duration"+I2S(StringLength(GetHandleString(tr, "code"))-GetHandleInt(tr, "passes")), duration)
call TimerStart(t, 1.5, false, function ActivationSystemReset)
if GetHandleInt(tr, "passes")<=0 then
call SetHandleBoolean(tr, "running", false)
call PauseTimer(t)
call SetHandleReal(tr, "average", GetHandleReal(tr, "min")+(GetHandleReal(tr, "max")-GetHandleReal(tr, "min"))/2)
loop
set i = i+1
if GetHandleReal(tr, "duration"+I2S(i))<GetHandleReal(tr, "average") then
call SetHandleString(tr, "ac", GetHandleString(tr, "ac")+".")
else
call SetHandleString(tr, "ac", GetHandleString(tr, "ac")+"-")
endif
exitwhen i == StringLength(GetHandleString(tr, "code"))
endloop
if GetHandleString(tr, "ac")==GetHandleString(tr, "code") then
call ExecuteFunc(GetHandleString(tr, "act"))
endif
endif
else
call SetHandleBoolean(tr, "running", true)
call SetHandleInt(tr, "passes", StringLength(GetHandleString(tr, "code")))
call TimerStart(t, 1.5, false, function ActivationSystemReset)
call SetHandleReal(tr, "max", 0)
call SetHandleReal(tr, "min", 1.5)
call SetHandleString(tr, "ac", "")
endif
set tr = null
set t = null
endfunction
function ActivationSystemInit takes player p, string c, string action returns trigger
local trigger t = CreateTrigger()
call SetHandleHandle(t, "timer", CreateTimer())
call SetHandleHandle(GetHandleTimer(t, "timer"), "trigref", t)
call SetHandleString(t, "act", action)
call SetHandleString(t, "code" ,SubString(c, 0, StringLength(c)-1))
call TriggerRegisterPlayerEvent(t, p, EVENT_PLAYER_END_CINEMATIC)
call TriggerAddAction(t, function ActivationSystem)
return t
endfunction
How does it work?This system allows you to call a function by pressing Esc in a row using longer or shorter intervalls.
You don't have to type chat messages some people could read.
It doesn't matter, how fast you press Esc, the system will handle it, if there are detecteble time lags between short (·) and long (-) intervalls.
How to use it?First you need KaTTaNas Local Handle Variables:
http://www.wc3jass.com/viewtopic.php?t=224After importing Handle Locals, copy the code over here into your header and save the game.
Next we need this function:
Code:
function ActivationSystemInit takes player p, string c, string action returns trigger
There are 3 parameters:
- player: which player can use the function?
- string: a string which consists only minus and dots (".--.-..-") without any spaces
- string: name of the function you want to call
Important!!!- Don't use morse-codes only with dots or minus. A combination of both is needed. (combination is coming soon...)
- The last minus or dot in the morse-string isn't used by the system. Its needed to force the player to end the run with an Esc-click
- Your morse-code should be longer than 3 characters