• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Reward for login

RunarM

Finally back
Joined
Jul 17, 2008
Messages
1,636
Reaction score
32
Location
Norway/Tromsø
Does anyone know how to make a script that rewards the player for entering the server?

Example:
Day 1: 1 hour online = +2k [5 hours: 3k extra)
Day 2: 1 hour online = +4k [5 hours: 3k extra)
Day 3: 1 hour online = +6k [5 hours: 3k extra)
Day 4: 1 hour online = +8k [5 hours: 3k extra)
Day 5: 1 hour online = +10k [5 hours: 3k extra)

You get it, it adds 2k every day if the player is 1 hour online and if he is online 5 hours it adds 3k extra, if you ain't online 1 hour the next day it will start at day 1 again.. Can anyone help me with that ;)?


Thanks, RunarM.
 
It's not exactly what you request, but you got the base:
Code:
local received = {}

function onThink(interval)
	for _, cid in ipairs(getPlayersOnline()) do
		if(not received[cid]) then
			if(getPlayerLastLogin(cid) + 2 * 60 * 60 < os.time()) then
				doPlayerMoney(cid, 2000)
				received[cid] = true
			end
		end
	end
	return true
end
 
It's not exactly what you request, but you got the base:
Code:
local received = {}

function onThink(interval)
	for _, cid in ipairs(getPlayersOnline()) do
		if(not received[cid]) then
			if(getPlayerLastLogin(cid) + 2 * 60 * 60 < os.time()) then
				doPlayerMoney(cid, 2000)
				received[cid] = true
			end
		end
	end
	return true
end

Will that add 2k everyday or just once?
 
Once per server restart, you can set up global save @ specified hour so it'll be adding reward every day ;p.
 
Though so :S

every day is that to you every 24h or at a specific time point (e.g. server computers 00:00)

if 24h, then it'd be like:
first login - register date/time and check if has been online for 2h
next login check if has passed 24h since first login, if not it won't store login time over it...
next login again, check 24h, and if it did pass this time it will register date/time over last one, and then check 2h shit and so on!!

you need 2 storages for this
1. store login time (for this day)
2. onLogout add how long he played... (e.g. if i play 30 minutes, then logout it will store 30*60, then if i login again play 20 minutes it add 30*60 + 20*60 etc... when passed 2*60*60 it give reward and stop counting time until next day, this storage will reset too)
 
Back
Top