• 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 [lua] [TFS 1.3] Does not save progress and a small error in lua code.

Crest

New Member
Joined
Mar 25, 2008
Messages
18
Reaction score
2
Location
Poland
Hello.

Im here for about 12 years (shit :D), and never ask for help but now I have a problem.

First, Im using tfs1.3 for 8.6 version, I set all, run ots, login to game, worka good but when I relog I lost all items, stats, I start from 0 every time when relog characters, I quess IT can be problem with db or acess to db to save. Im using UniServerZ for MySQL and PHP. I got error in console, check screen. I think UniServerZ have setup for read only, no read/write.

Anyone can help me with IT?

And The second problem is with lua, antibot system, I know its easy to fix IT but last time when I making some in lua was some years ago. I add screen from console and lua code.

Lua:
player:registerEvent("Antibot")
    player:registerEvent("Antibot2")
  

function Player.sendTibiaTime(self, hours, minutes)
    local msg = NetworkMessage()
    msg:addByte(0xEF)
    msg:addByte(hours)
    msg:addByte(minutes)
    msg:sendToPlayer(self)
    msg:delete()
    return true
end

local function onMovementRemoveProtection(cid, oldPosition, time)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerPosition = player:getPosition()
    if (playerPosition.x ~= oldPosition.x or playerPosition.y ~= oldPosition.y or playerPosition.z ~= oldPosition.z) or player:getTarget() then
        player:setStorageValue(Storage.combatProtectionStorage, 0)
        return true
    end

    addEvent(onMovementRemoveProtection, 1000, cid, oldPosition, time - 1)
end

function onLogin(player)
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end

    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    local playerId = player:getId()
    
    -- Stamina
    nextUseStaminaTime[player.uid] = 0
    


    if (player:getGroup():getId() >= 4) then
        --player:setGhostMode(true)
    end

    
    if (player:getAccountType() == ACCOUNT_TYPE_TUTOR) then
        local msg = [[:: Tutor Rules
            1 *> 3 Warnings you lose the job.
            2 *> Without parallel conversations with players in Help, if the player starts offending, you simply mute it.
            3 *> Be educated with the players in Help and especially in the Private, try to help as much as possible.
            4 *> Always be on time, if you do not have a justification you will be removed from the staff.
            5 *> Help is only allowed to ask questions related to tibia.
            6 *> It is not allowed to divulge time up or to help in quest.
            7 *> You are not allowed to sell items in the Help.
            8 *> If the player encounters a bug, ask to go to the website to send a ticket and explain in detail.
            9 *> Always keep the Tutors Chat open. (required).
            10 *> You have finished your schedule, you have no tutor online, you communicate with some CM in-game or ts and stay in the help until someone logs in, if you can.
            11 *> Always keep a good Portuguese in the Help, we want tutors who support, not that they speak a satanic ritual.
            12 *> If you see a tutor doing something that violates the rules, take a print and send it to your superiors. "
            - Commands -
            Mute Player: / mute nick, 90. (90 seconds)
            Unmute Player: / unmute nick.
            - Commands -]]
        player:popupFYI(msg)
    end

     -- OPEN CHANNELS
    if table.contains({"Rookgaard", "Dawnport"}, player:getTown():getName())then
        player:openChannel(3) -- world chat
        player:openChannel(6) -- advertsing rook main
    else
        player:openChannel(3) -- world chat
        player:openChannel(5) -- advertsing main
    end

    
     if player:getStorageValue(Storage.combatProtectionStorage) < 1 then
        player:setStorageValue(Storage.combatProtectionStorage, 1)
        onMovementRemoveProtection(playerId, player:getPosition(), 10)
    end

    
    return true
end
 

Attachments

Lua:
function Player.sendTibiaTime(self, hours, minutes)
    local msg = NetworkMessage()
    msg:addByte(0xEF)
    msg:addByte(hours)
    msg:addByte(minutes)
    msg:sendToPlayer(self)
    msg:delete()
    return true
end

local function onMovementRemoveProtection(cid, oldPosition, time)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerPosition = player:getPosition()
    if (playerPosition.x ~= oldPosition.x or playerPosition.y ~= oldPosition.y or playerPosition.z ~= oldPosition.z) or player:getTarget() then
        player:setStorageValue(Storage.combatProtectionStorage, 0)
        return true
    end

    addEvent(onMovementRemoveProtection, 1000, cid, oldPosition, time - 1)
end

function onLogin(player)
    player:registerEvent("Antibot")
    player:registerEvent("Antibot2")
    
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end

    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    local playerId = player:getId()
    
    -- Stamina
    nextUseStaminaTime[player.uid] = 0
    


    if (player:getGroup():getId() >= 4) then
        --player:setGhostMode(true)
    end

    
    if (player:getAccountType() == ACCOUNT_TYPE_TUTOR) then
        local msg = [[:: Tutor Rules
            1 *> 3 Warnings you lose the job.
            2 *> Without parallel conversations with players in Help, if the player starts offending, you simply mute it.
            3 *> Be educated with the players in Help and especially in the Private, try to help as much as possible.
            4 *> Always be on time, if you do not have a justification you will be removed from the staff.
            5 *> Help is only allowed to ask questions related to tibia.
            6 *> It is not allowed to divulge time up or to help in quest.
            7 *> You are not allowed to sell items in the Help.
            8 *> If the player encounters a bug, ask to go to the website to send a ticket and explain in detail.
            9 *> Always keep the Tutors Chat open. (required).
            10 *> You have finished your schedule, you have no tutor online, you communicate with some CM in-game or ts and stay in the help until someone logs in, if you can.
            11 *> Always keep a good Portuguese in the Help, we want tutors who support, not that they speak a satanic ritual.
            12 *> If you see a tutor doing something that violates the rules, take a print and send it to your superiors. "
            - Commands -
            Mute Player: / mute nick, 90. (90 seconds)
            Unmute Player: / unmute nick.
            - Commands -]]
        player:popupFYI(msg)
    end

     -- OPEN CHANNELS
    if table.contains({"Rookgaard", "Dawnport"}, player:getTown():getName())then
        player:openChannel(3) -- world chat
        player:openChannel(6) -- advertsing rook main
    else
        player:openChannel(3) -- world chat
        player:openChannel(5) -- advertsing main
    end

    
     if player:getStorageValue(Storage.combatProtectionStorage) < 1 then
        player:setStorageValue(Storage.combatProtectionStorage, 1)
        onMovementRemoveProtection(playerId, player:getPosition(), 10)
    end

    
    return true
end
 
seems like you mixed otserbr code with tfs 1.3 8.6, this is not advisable 😳 and might led to way more errors
Thanks for your answer. Im using tfs1.3 from [8.6] [TFS1.3] Global + Source + Web + tools + Quest Reward System (https://otland.net/threads/8-6-tfs1-3-global-source-web-tools-quest-reward-system.271659/)

So its should work I think


One more thing, I get error only on God acc, when I make a normal character login and logout console its clean but still dont save progress.
 
Last edited:
Back
Top