• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] Player wages on timer.

Status
Not open for further replies.

jar0fair

Emulation Addict
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.

Code:
--Wage System
--Book of the Fallen.
--forums.fallenrp.com
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:ModifyMoney(20)
	player:SendBroadcastMessage("You have played for "..time[guid].." minutes this session and have earned 20 copper.")
   	end
 
local function OnLine(event, player)
	local guid = player:GetGUIDLow()
	time[guid] = 0
    player:RegisterEvent(Player_Onlinetime, Timer, 0, player)
end


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

 RegisterPlayerEvent(3, OnLine)
 RegisterPlayerEvent(4, OffLine)
 
Status
Not open for further replies.
Top