Lua RegisterTimedEvent

From ArcEmu-Wiki
Jump to: navigation, search
+/-
Main Page        LuaArcEmu Website     ArcEmu Forum     Bug Tracker



RegisterTimedEvent()

Registers a timed event

Syntax

hndEvent = RegisterTimedEvent(string FunctionName, uint Delay, uint Repeats [, optionalParamtersToFunction ...])

Returns a reference to the registered event.

Parameters

Delay: Time in ms
Repeats: 0 = repeats endless, > 1 no. of repeats


Ico warning.png Be careful by passing units with this function. May they are valid only for a short period. Refering to invalid units may crash your server.


Example

function Player_Enters_World(event, pPlayer)
  pPlayer:SendBroadcastMessage("Welcome "..pPlayer:GetName())
  RegisterTimedEvent("Player_Enters_World_Text1", 5000, 1, pPlayer)
end
 
function Player_Enters_World_Text1(pPlayer)
  pPlayer:SendBroadcastMessage("Now it's 5 seconds later :-)")
end
 
RegisterServerHook(19, "Player_Enters_World")		-- SERVER_HOOK_ENTER_WORLD_2
Personal tools