Jump to content
Sign in to follow this  
Vlinder

Daily Login Reward

Recommended Posts

Tested with TFS 0.3.6

 

Every day people login they get money. Only the day matters, so they don't have to wait 24 hours but they get the reward the next day they login.

If they login every day, they get extra money till a max of 7 days. First day is the basic start money, second day 2x as much, third day 3x as much etc. If they don't login the next day, it will start from 1 again.

If a player logs in for 7 days he will get the money x7 and he will keep getting this every new days he logs in until he doesn't login the next day anymore, then it will start from 1 again. .

 

Example first and second day.

eJQKtB.png

xZt8K_.png

 

The player's level has influence on how much money someone gets.

The calculation works like this: level^multiplier x gold.

Example of someone from lvl 8: 8^2 x 1 = 64 gold

Example of someone from lvl 50: 50^2 x 1 = 2500 gold

If you make the multiplier higher or gold lower, level would have more influence, if you make gold higher or multiplier lower, level has less influence.

You can use numbers like 2.3 and 0.9, it rounds the number.

 

creaturescripts.xml




 

loginreward.lua

local c = {
multiplier = 2,
gold = 1,
storage = 8754,
dstorage = 8375,
exstorage = 8457
}

function onLogin(cid)

local lvl, day = getPlayerLevel(cid), tonumber(os.date("%w"))
local money = math.floor(lvl^c.multiplier * c.gold)

if getPlayerStorageValue(cid, c.dstorage) == (day - 1) or getPlayerStorageValue(cid, c.dstorage) == (day - 7) and exhaustion.check(cid, c.exstorage) then
	setPlayerStorageValue(cid, c.dstorage, day)
	setPlayerStorageValue(cid, c.storage, getPlayerStorageValue(cid, c.storage) == 7 and 7 or (getPlayerStorageValue(cid, c.storage) + 1))
	doPlayerAddMoney(cid, money * getPlayerStorageValue(cid, c.storage))
	doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Daily login reward ["..getPlayerStorageValue(cid, c.storage).."]: "..(money * getPlayerStorageValue(cid, c.storage)).." gold.")
	doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_YELLOW)
	exhaustion.set(cid, c.exstorage, 48 * 60 * 60)
elseif getPlayerStorageValue(cid, c.dstorage) ~= day or getPlayerStorageValue(cid, c.dstorage) == -1 then
	setPlayerStorageValue(cid, c.dstorage, day)
	setPlayerStorageValue(cid, c.storage, 1)
	doPlayerAddMoney(cid, money)
	doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Daily login reward ["..getPlayerStorageValue(cid, c.storage).."]: "..(money * getPlayerStorageValue(cid, c.storage)).." gold.")
	doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_YELLOW)
end
return true
end

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

Privacy Policy