View Full Version : [SOLVED] Player wages on timer.

04-03-2016, 07:05 PM
Hello, I am having some issues with my server's wage script. It loops a 20 minute timer on player log-in and adds some money every 20 minutes. It works okay, but stops functioning if the player loads into a new zone, or is teleported, this script no longer provides the player with any money. It seems the register event stops triggering. I am really looking for some help either getting this script to work, or getting a similar script to work, providing money to our players. Thank you, in advance.

--Wage System
--Book of the Fallen.
local Timer = 1200000 -- 1200000 = 20 minutes timer between rewards
local time = {}

local function Player_Onlinetime(event, delay, calls, player)
local guid = player:GetGUIDLow()
time[guid] = time[guid] + 20
player:SendBroadcastMessage("You have played for "..time[guid].." minutes this session and have earned 20 copper.")

local function OnLine(event, player)
local guid = player:GetGUIDLow()
time[guid] = 0
player:RegisterEvent(Player_Onlinetime, Timer, 0, player)

local function OffLine(event, player)
local guid = player:GetGUIDLow()
time[guid] = nil

RegisterPlayerEvent(3, OnLine)
RegisterPlayerEvent(4, OffLine)

04-03-2016, 09:44 PM
Well you could try to schedule a global lua event, that does all the work.
Something amongst these lines: http://paste2.org/tZdJOjZw

NOTE: This particular script requires the time in seconds.
Not the time in miliseconds (so 1200 instead of 1200000)


04-05-2016, 02:22 AM
This worked wonders. Thank you so much.

Mark this baby solved.