Ahilphino
Excellent OT User
- Joined
- Jun 5, 2013
- Messages
- 1,666
- Solutions
- 1
- Reaction score
- 723
SCRIPT IS FOR TFS 1.X
what does this script do?
simply adds another message when you level up and it looks like this:
11:21 It took you 9 seconds to advance in level from your last advance.
11:21 You advanced from Level 1129 to Level 1130.
11:24 It took you 3 minutes and 16 seconds to advance in level from your last advance.
11:24 You advanced from Level 1130 to Level 1131.
ok so the script is really easy and it can be done better by more experienced ppl. but i saw it in a server and i loved that feature so I made it for myself and I will post it here so more servers can use it
also the timestring function is from someone else on otland.
creaturescripts\scripts\timelevel.lua
also add this in login.lua
and in creaturescripts.xml
that's it! now it will work! it's made for tfs 1.x!!!!!
TO SCRIPTERS:
if someone that knows how to remove level advance from sources this could be much better and have only white text with this text, if you know how to remove it from sources please post! and if u wanna improve the code please post ur editions since im quite bad
what does this script do?
simply adds another message when you level up and it looks like this:
11:21 It took you 9 seconds to advance in level from your last advance.
11:21 You advanced from Level 1129 to Level 1130.
11:24 It took you 3 minutes and 16 seconds to advance in level from your last advance.
11:24 You advanced from Level 1130 to Level 1131.
ok so the script is really easy and it can be done better by more experienced ppl. but i saw it in a server and i loved that feature so I made it for myself and I will post it here so more servers can use it
also the timestring function is from someone else on otland.
creaturescripts\scripts\timelevel.lua
Code:
function timeString(timeDiff)
local dateFormat = {
{"day", timeDiff / 60 / 60 / 24},
{"hour", timeDiff / 60 / 60 % 24},
{"minute", timeDiff / 60 % 60},
{"second", timeDiff % 60}
}
local out = {}
for k, t in ipairs(dateFormat) do
local v = math.floor(t[2])
if(v > 0) then
table.insert(out, (k < #dateFormat and (#out > 0 and ', ' or '') or ' and ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or ''))
end
end
local ret = table.concat(out)
if ret:len() < 16 and ret:find("second") then
local a, b = ret:find(" and ")
ret = ret:sub(b+1)
end
return ret
end
function onAdvance(player, skill, oldlevel, newlevel)
if skill ~= SKILL_LEVEL then
return true
end
oldtime = player:getStorageValue(3499)
timenow = os.time()
if oldtime == -1 then
player:setStorageValue(3499, timenow)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "It took you " .. timeString(timenow - oldtime) .. " to advance in level from your last advance.")
player:setStorageValue(3499, timenow)
end
return true
end
also add this in login.lua
Code:
player:registerEvent("timelevel")
and in creaturescripts.xml
Code:
<event type="advance" name="timelevel" script="timelevel.lua"/>
that's it! now it will work! it's made for tfs 1.x!!!!!
TO SCRIPTERS:
if someone that knows how to remove level advance from sources this could be much better and have only white text with this text, if you know how to remove it from sources please post! and if u wanna improve the code please post ur editions since im quite bad
Code:
You advanced to level 35 in 3 minutes and 10 seconds. (we could just make 1 line like this with source change)
Last edited: