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

TFS 1.X+ The script does not want to run despite the correct functions and registration in login.lua

Svira

Active Member
Joined
Jan 27, 2008
Messages
268
Solutions
11
Reaction score
36
Hello, I wanted to add the time in which the player reached the next level, unfortunately despite the registration in login.lua the script will not be triggered. It is read because when an error is specifically entered in it, it appears in the console.

Currently it looks like this and doesn't cause any errors, but also doesn't send print.

TFS 1.2+

Lua:
function onAdvance(player, skill, oldlevel, newlevel)
    print("1")
    if player:isPlayer() and skill == SKILL_LEVEL then
    print("2")
        return true
    end

    print("3")
    oldtime = player:getStorageValue(3499)
    timenow = os.time()
    if oldtime == -1 then
        player:setStorageValue(3499, timenow)
    print("4")
    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


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
 
Did you register the event in creaturescripts.xml?

I've used the same function as follows:

XML:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
    ...
    <event type="advance" name="PromotionLetter" script="promotionLetter.lua"/>
    ...
</creaturescripts>
 
Last edited:
Did you register the event in creaturescripts.xml?

I've used the same function as follows:

XML:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
    ...
    <event type="advance" name="PromotionLetter" script="promotionLetter.lua"/>
    ...
</creaturescripts>
As in the topic, it is correctly added in creaturescript.xml and properly registered in login.lua
on the exact same server at another vendor the script works without error ... lol2
 
I just did a quick little test; are the names, even the capitalization, identical? It's the only thing I can think of why it wouldn't work. I changed (on my server)

Lua:
player:registerEvent("ScarabCaves1")
The 'S' of 'Scarabcaves1' to lowercase or 'scarabcaves1' with

XML:
<event type="kill" name="ScarabCaves1" script="scarabCaves1.lua"/>

In the lua file. It stopped working.
 
I just did a quick little test; are the names, even the capitalization, identical? It's the only thing I can think of why it wouldn't work. I changed (on my server)

Lua:
player:registerEvent("ScarabCaves1")
The 'S' of 'Scarabcaves1' to lowercase or 'scarabcaves1' with

XML:
<event type="kill" name="ScarabCaves1" script="scarabCaves1.lua"/>

In the lua file. It stopped working.
for me, the size of the characters is correct, the name is also ok. I really do not see the reason for this script to not work, but it does not start.

I also did a test. on a different VPS but the same server with the same configuration and works ...
so why do I have a problem on VPS with better paremetram?

the same provider, the same files - one works, the other does not xD
 
That's so specifically weird, I wouldn't have any idea about VPS's though. Hope you can resolve it but I think someone with more experience should probably read this.

The only possibility (bit far-fetched perhaps) is that there's some undefined behaviour somewhere such that the problem occurs on one VPS but not on the other; but I wouldn't have the slighest idea on how to locate such a thing.

Good luck, I really hope someone finds a solution.
 
Back
Top