• 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 TFS 1.2 can not log out for XX seconds.

CyberShaman21

New Member
Joined
Dec 9, 2017
Messages
52
Reaction score
4
Hi
I want rebuild foods script . After you eat food you can't logout for xx seconds.

i found this script
Code:
local storage = 102
function onLogout(cid)
    if (getCreatureStorage(cid, storage) == 1) then
        doPlayerSendCancel(cid, "You can not log out during these effects.")
        return false
    end
    return true
end

and try to connect with food script
Code:
local foods = {
    [26413] = {5, "Crunch.", 100}, -- carrot

}

local storage = 102
function onLogout(cid)
    if (getCreatureStorage(cid, food[3]) == 1) then
        doPlayerSendCancel(cid, "You can not log out during these effects.")
        return false
    end
    return true
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local food = foods[item.itemid]
    if not food then
        return false
    end

    local condition = player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
    if condition and math.floor(condition:getTicks() / 1000 + (food[1] * 12)) >= 1200 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You are full.")
    else
        player:feed(food[1] * 12)
        player:say(food[2], TALKTYPE_MONSTER_SAY)
        item:remove(1)
        onLogout(cid)
    end
    return true
end

a I get error "attempt to call global 'onLogout' <a nil value>

I is good code?
 
that's not how it works
you need to register a logout script through creaturescripts.xml and create a new file for the onLogout function
for example look at logout.lua
you don't need to call the onLogout function either
 
Honestly I'm more curious about why players shouldn't be logging out after eating food. xP

Instead of the logout script though..
You could give the player battle lock after eating food to stop them from logging out.
Would that not be an acceptable solution?
 
How long can they not logout for? Is the the full duration of whatever food they eat? So if they eat 5 peices of food the time they cant log out is longer?
 
Back
Top