// How to use:
/*
You basically only change the constants in the global tags and add strings in the SetupHint function.
Once everything is setup you chose which function you prefer to use either the "LinearHints function"
or the "RandomizedHints function"
*/
// LinearHints work by just looping through every hint in the array and starting over.
// Randomized Hints work by picking a random hint each time and then removing it from the avalible pool until all hints
// have been played, then it restarts.
globals
trigger trg_Hints
boolean array hintsPlayerOn
string array hint
boolean hintsOn
constant real HINT_DISPLAY_TIME = 15 // This is the Time which the messages are displayed.
constant real HINT_RESTART_WAIT = 5 // This is the Wait Time befor the hint cycle restarts
constant real HINT_INTEVAL_WAIT = 5 // This is the Wait Time between two hints, prior to a cycle finnish.
constant real MIN_TIME_BEFOR_REMINDER = 15 // This is the Time befor a hint "enable" reminder is shown.
endglobals
function SetupHints takes nothing returns nothing
set hint[0] = "|cff32cd32Hint #1|r - Generic Hint Here!"
set hint[1] = "|cff32cd32Hint #2|r - Generic Hint Here!"
set hint[2] = "|cff32cd32Hint #3|r - Generic Hint Here!"
set hint[3] = "|cff32cd32Hint #4|r - Generic Hint Here!"
endfunction
function LinearHints takes nothing returns nothing
local real array timeSinceLastHint
local integer MAX = 0
local integer count
local integer i
call SetupHints()
call EnableTrigger(trg_Hints)
set trg_Hints = null
loop
exitwhen hint[MAX + 1] == null
set MAX = MAX + 1
endloop
set count = 0
loop
if hintsOn == TRUE then
set i = 0
loop
if hintsPlayerOn[i] == TRUE and GetPlayerController(Player(i)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call DisplayTimedTextToPlayer( Player(i), 0, 0, HINT_DISPLAY_TIME, hint[count])
elseif hintsPlayerOn[i] == FALSE and GetPlayerController(Player(i)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set timeSinceLastHint[i] = timeSinceLastHint[i] + HINT_INTEVAL_WAIT // Basically this counts the interval time, not accuretly,
if MIN_TIME_BEFOR_REMINDER < timeSinceLastHint[i] then // but it fills its purpose in my oppinion.
call DisplayTimedTextToPlayer( Player(i), 0, 0, HINT_DISPLAY_TIME, "|cff995500Notice|r - You can enable/disable hints by typing '|cffffcc00-hints on|r/|cffffcc00off|r'")
set timeSinceLastHint[i] = 0
endif
endif
exitwhen i == 11
set i = i + 1
endloop
set count = count + 1
if count > MAX then
set count = 0
call TriggerSleepAction(HINT_RESTART_WAIT)
endif
call TriggerSleepAction(HINT_INTEVAL_WAIT)
endif
endloop
endfunction
function RandomizedHints takes nothing returns nothing
local string array hint1
local real array timeSinceLastHint
local integer MAX = 0
local integer random
local string tempHint
local integer count
local integer i
call SetupHints()
call EnableTrigger(trg_Hints)
set trg_Hints = null
loop
set hint1[MAX] = hint[MAX]
exitwhen hint[MAX + 1] == null
set MAX = MAX + 1
endloop
set count = MAX
loop
if hintsOn == TRUE then
set random = GetRandomInt(0, count)
set i = 0
loop
if hintsPlayerOn[i] == TRUE and GetPlayerController(Player(i)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call DisplayTimedTextToPlayer( Player(i), 0, 0, HINT_DISPLAY_TIME, hint1[random])
elseif hintsPlayerOn[i] == FALSE and GetPlayerController(Player(i)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set timeSinceLastHint[i] = timeSinceLastHint[i] + HINT_INTEVAL_WAIT // Basically this counts the interval time, not accuretly,
if MIN_TIME_BEFOR_REMINDER < timeSinceLastHint[i] then // but it fills its purpose in my oppinion.
call DisplayTimedTextToPlayer( Player(i), 0, 0, HINT_DISPLAY_TIME, "|cff995500Notice|r - You can enable/disable hints by typing '|cffffcc00-hints on|r/|cffffcc00off|r'")
set timeSinceLastHint[i] = 0
endif
endif
exitwhen i == 11
set i = i + 1
endloop
set tempHint = hint1[random]
set hint1[random] = hint1[count]
set hint1[count] = tempHint
set count = count - 1
if count < 0 then
set count = MAX
call TriggerSleepAction(HINT_RESTART_WAIT)
endif
call TriggerSleepAction(HINT_INTEVAL_WAIT)
endif
endloop
endfunction
function HintCommands takes nothing returns nothing
local integer pID = GetPlayerId(GetTriggerPlayer())
local integer substring
if GetEventPlayerChatString() == "-hints on" and hintsPlayerOn[pID] == FALSE then
set hintsPlayerOn[pID] = TRUE
call DisplayTimedTextToPlayer( Player(pID), 0, 0, HINT_DISPLAY_TIME, "|cff995500Hints Enabled|r")
elseif GetEventPlayerChatString() == "-hints off" and hintsPlayerOn[pID] == TRUE then
set hintsPlayerOn[pID] = FALSE
call DisplayTimedTextToPlayer( Player(pID), 0, 0, HINT_DISPLAY_TIME, "|cff995500Hints Disabled|r")
elseif GetEventPlayerChatStringMatched() == "-hint" then
set substring = S2I(SubString(GetEventPlayerChatString(),6,7)) - 1
// set substring = substring - 1
if hint[substring] != null then
call DisplayTimedTextToPlayer( Player(pID), 0, 0, HINT_DISPLAY_TIME, hint[substring])
else
call DisplayTimedTextToPlayer( Player(pID), 0, 0, HINT_DISPLAY_TIME, "|cffff0000Error|r - No maching hint found.")
endif
endif
endfunction
function InitTrig_Hints takes nothing returns nothing
set trg_Hints = CreateTrigger()
call DisableTrigger(trg_Hints )
call TriggerRegisterPlayerChatEvent(trg_Hints, Player(0), "-hint", false )
call TriggerRegisterPlayerChatEvent(trg_Hints, Player(1), "-hint", false )
call TriggerRegisterPlayerChatEvent(trg_Hints, Player(2), "-hint", false )
call TriggerRegisterPlayerChatEvent(trg_Hints, Player(3), "-hint", false )
call TriggerRegisterPlayerChatEvent(trg_Hints, Player(4), "-hint", false )
call TriggerRegisterPlayerChatEvent(trg_Hints, Player(5), "-hint", false )
call TriggerRegisterPlayerChatEvent(trg_Hints, Player(6), "-hint", false )
call TriggerRegisterPlayerChatEvent(trg_Hints, Player(7), "-hint", false )
call TriggerRegisterPlayerChatEvent(trg_Hints, Player(8), "-hint", false )
call TriggerRegisterPlayerChatEvent(trg_Hints, Player(9), "-hint", false )
call TriggerRegisterPlayerChatEvent(trg_Hints, Player(10), "-hint", false )
call TriggerRegisterPlayerChatEvent(trg_Hints, Player(11), "-hint", false )
call TriggerAddAction(trg_Hints, function HintCommands )
endfunction