• 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!

Lua Double experiance day

pasibun

New Member
Joined
Nov 7, 2011
Messages
147
Reaction score
1
Update:
Thanks to Scarlet Ayleid and Summ who build a certain day of the week exprate script.

Globalevent to set exprate player who is online:
LUA:
function onTimer()
	local message = "test"
	local expRate = 1
	if (os.date('%A') == 'Wednesday') then
		message = "Extra experience day has been started" 
		expRate = 2
	elseif (os.date('%A') ~= 'Wednesday') then
		message = "Extra experience day is over"
		expRate = 1
	else
		return true
	end
	for _, cid in pairs(getPlayersOnline()) do
		doPlayerSetRate(cid, SKILL__LEVEL, expRate)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, message)
	end
	return true
end

Creaturescript to set exprate player who logs in on double exp day:
LUA:
function onLogin(cid)
	if (os.date('%A') == 'Wednesday') then
		doPlayerSetRate(cid, SKILL__LEVEL, 2)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Today is extra experience day")
	end
	return true
end
 
Last edited:
Code:
intervalTime = 10000
Should happen between 10000 milliseconds... As for the rest I only see that it says either your exp has ended, is going to and will end, but not startup.

- - - Updated - - -

As for improving it I'm sorry but I'm not a scripter.
 
PHP:
doPlayerSetRate(cid, SKILL__LEVEL, config.rate)

Should "startup" it. This should execute the exprate for every CID (single player)
 
PHP:
doPlayerSetRate(cid, SKILL__LEVEL, config.rate)

Should "startup" it. This should execute the exprate for every CID (single player)

But you only got functions for it telling you it's over, it's going to be over and it has been over, you still don't have the "It has started" on it.
 
Well, issn't that this part?..
LUA:
function onThink(cid, intervalTime)
    if (os.date('%A') == 'Wednesday') then
        doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your extra exp rate will expire at: " .. os.date("%X"))
 
Last edited by a moderator:
From what I'm seeing IF the OS says it's Wednesday then you would set the player's rate skill to the config.rate and it will tell you that it will expire in X, personally I would have a message saying "Double exp for X or until X" instead of "It will expire X"
 
Alright i understand.. but what I meant was..

It works, but it executes the script 2 times every second.
It should be less intensive for the server to execute it that often.

Also, is this the best way?
 
Just add it on login:

LUA:
function onLogin(cid)
    if (os.date('%A') == 'Wednesday') then
        doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your extra exp rate will expire at: " .. os.date("%X"))

Also you could then use a talkaction to end the event for all if Wednesday is over.
LUA:
function onSay(cid, words, p)
    for _, pid in pairs(getPlayersOnline()) do
        doPlayerSetRate(pid, SKILL__LEVEL, 1) -- dunno if you need to set 1 here or the default exp rate, you should check
        doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_BLUE, "Extra experience day is over")
    end  
    return true
end
 
The login script that Summ provided is ok, but it won't affect players that are already logged in, and using a talk event to end it every week is lame imo

Have you tried messing around with globalevents?
XML:
<globalevent name="BonusEXP" time="00:00:00" event="script" value="bonusExp.lua"/>

bonusExp.lua
LUA:
function onTime()
  local message = ""
  local expRate = 1
  if (os.date('%A') == 'Wednesday') then
    message = "Your extra exp rate will expire at: " .. os.date("%X")
    expRate = config.rate
  elseif (os.date('%A') == 'Thursday') then
    message = "Extra experience day is over"
    expRate = 1
  else
    return true
  end
  for _, cid in pairs(getPlayersOnline()) do
    doPlayerSetRate(cid, SKILL__LEVEL, expRate)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, message)
  end
  return true
end

Haven't tested, but it should work as you want :)
 
Last edited:
@Scarlet
I edited your post, you still had "function onSay(cid, words, p)" in it.
 
Scarlet Ayleid, you rock! :D

- - - Updated - - -

ahh thank you all,,
I have tryed the script of scarled ayleid.. and i did get a small error in my console

Code:
[Warning - Event::loadScript] Event onTimer not found (data/globalevents/scripts/exp event/exp event.lua)
 
ahh sorry,, that I did not see that!:P

- - - Updated - - -

Code:
[01/11/2012 14:07:00] [Error - GlobalEvent Interface] 
[01/11/2012 14:07:00] data/globalevents/scripts/exp event/exp event.lua:onTimer
[01/11/2012 14:07:00] Description: 
[01/11/2012 14:07:00] data/globalevents/scripts/exp event/exp event.lua:6: attempt to index global 'config' (a nil value)
[01/11/2012 14:07:00] stack traceback:
[01/11/2012 14:07:00] 	data/globalevents/scripts/exp event/exp event.lua:6: in function <data/globalevents/scripts/exp event/exp event.lua:1>
[01/11/2012 14:07:00] [Error - GlobalEvents::timer] Couldn't execute event: exp

mm, another error when it wants to execute

and another question.. does this work with stages?
 
Last edited:
Replace "config.rate" with the exp rate you wont the players to have during double exp day.
 
LUA:
local expRates = {
    {1, 100},
    {10, 90},
    {20, 80}
}


function onTimer()
    local message = ""
    if (os.date('%A') == 'Wednesday') then
        message = "Your extra exp rate will expire at: " .. os.date("%X")
    elseif (os.date('%A') == 'Thursday') then
        message = "Extra experience day is over"
    else
        return true
    end
    for _, cid in pairs(getPlayersOnline()) do
        for i = 1, #expRates, 1 do
            if(expRates[i][1] < getPlayerLevel(cid)) then
                doPlayerSetRate(cid, SKILL__LEVEL, expRates[i - 1][2])
                break
            end
        end
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, message)
    end
    return true
end

- - - Updated - - -

Just change the table on the top, in that example

Level 1 players get 100x
Levels between 2 and 10 get 90x
Levels between 11 and 20 get 80x
 
Last edited:
Back
Top