• 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 0.X resting

elnelson

Lunaria World Dev
Joined
Jun 20, 2009
Messages
579
Solutions
2
Reaction score
58
Location
México
Hello, otlanders. i have this script but it is not working properly, it suppose to regenerate stamina but when i use it i got 3 errors on console and doesnt work.
here is the script
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local config = {
       soul = 0, -- amount of souls to start
       timer = 1, -- time in minutes
       rateStamina = 10, -- percent
   }
   
   if getPlayerSoul(cid) >= config.soul then
       local myOutfit, cstamina, secondPos, changeType, changeStraw, straw = getCreatureOutfit(cid), getPlayerStamina(cid), toPosition, 0, 0, 0
       local clookType = myOutfit.lookType
       if itemEx.itemid == 5501 then
           toPosition = toPosition.x - 1
           straw = 5500
       elseif itemEx.itemid == 5503 then
           toPosition = toPosition.y - 1
           straw = 5502
       elseif itemEx.itemid == 5500 then
           secondPos = secondPos.x + 1
           straw = itemEx.itemid
       elseif itemEx.itemid == 5502 then
           secondPos = secondPos.y + 1
           straw = itemEx.itemid
       end
       if itemEx.itemid == 5500 or 5501 then
           if getPlayerSex(cid) == PLAYERSEX_FEMALE then
               changeType = 7841
               changeStraw = 7842
           else
               changeType = 5496
               changeStraw = 5497
           end
       elseif itemEx.itemid == 5502 or 5503 then
           if getPlayerSex(cid) == PLAYERSEX_FEMALE then
               changeType = 7843
               changeStraw = 7844
           else
               changeType = 5498
               changeStraw = 5499
           end
       end
       doTeleportThing(cid, toPosition, false)
       doCreatureChangeOutfit(cid, {lookTypeEx = changeType})
       doCreatureSetNoMove(cid, true)   
       doTransformItem(getTileItemById(secondPos, straw).uid, changeStraw)   
       doSendAnimatedText(toPosition, "RESTING", TEXTCOLOR_ORANGE)
       addEvent(function()
           if isPlayer(cid) then
               doPlayerSetStamina(cid, cstamina + cstamina * config.rateStamina)
               doCreatureChangeOutfit(cid, {lookType = clookType})
               doRemoveItem(getTileItemById(secondPos, changeStraw).uid, 1)
               doCreateItem(straw, 1, secondPos)
               doCreatureSetNoMove(cid, false)
               doSendAnimatedText(toPosition, "RESTED", TEXTCOLOR_GREEN)
           end
       end, config.timer * 60 * 1000)
   end
   return true
end

and i got these errors:
Lua:
[17:52:07.767] [Error - Action Interface]
[17:52:07.773] data/actions/scripts/resting.lua:onUse
[17:52:07.775] Description:
[17:52:07.778] attempt to index a number value
[17:52:07.783] stack traceback:
[17:52:07.785]  [C]: in function 'getTileItemById'
[17:52:07.788]  data/actions/scripts/resting.lua:44: in function <data/actions/scripts/resting.lua:1>
[17:52:13.080] [Error - Action Interface]
[17:52:13.098] data/actions/scripts/resting.lua:onUse
[17:52:13.118] Description:
[17:52:13.140] attempt to index a number value
[17:52:13.143] stack traceback:
[17:52:13.145]  [C]: in function 'doTeleportThing'
[17:52:13.156]  data/actions/scripts/resting.lua:41: in function <data/actions/scripts/resting.lua:1>
 
I'm not following exactly what the script is supposed to be doing, but I think you are setting the positions incorrectly..
So try this?
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local config = {
        soul = 0, -- amount of souls to start
        timer = 1, -- time in minutes
        rateStamina = 10, -- percent
    }
   
    if getPlayerSoul(cid) >= config.soul then
        local myOutfit, cstamina, secondPos, changeType, changeStraw, straw = getCreatureOutfit(cid), getPlayerStamina(cid), {x = toPosition.x, y = toPosition.y, z = toPosition.z}, 0, 0, 0
        local clookType = myOutfit.lookType
        if itemEx.itemid == 5501 then
            secondPos = {x = toPosition.x - 1, y = toPosition.y, z = toPosition.z}
            straw = 5500
        elseif itemEx.itemid == 5503 then
            secondPos = {x = toPosition.x, y = toPosition.y - 1, z = toPosition.z}
            straw = 5502
        elseif itemEx.itemid == 5500 then
            secondPos = {x = toPosition.x + 1, y = toPosition.y, z = toPosition.z}
            straw = itemEx.itemid
        elseif itemEx.itemid == 5502 then
            secondPos = {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}
            straw = itemEx.itemid
        end
        if itemEx.itemid == 5500 or 5501 then
            if getPlayerSex(cid) == PLAYERSEX_FEMALE then
                changeType = 7841
                changeStraw = 7842
            else
                changeType = 5496
                changeStraw = 5497
            end
        elseif itemEx.itemid == 5502 or 5503 then
            if getPlayerSex(cid) == PLAYERSEX_FEMALE then
                changeType = 7843
                changeStraw = 7844
            else
                changeType = 5498
                changeStraw = 5499
            end
        end
        doTeleportThing(cid, toPosition, false)
        doCreatureChangeOutfit(cid, {lookTypeEx = changeType})
        doCreatureSetNoMove(cid, true) 
        doTransformItem(getTileItemById(secondPos, straw).uid, changeStraw) 
        doSendAnimatedText(toPosition, "RESTING", TEXTCOLOR_ORANGE)
        addEvent(function()
            if isPlayer(cid) then
                doPlayerSetStamina(cid, cstamina + cstamina * config.rateStamina)
                doCreatureChangeOutfit(cid, {lookType = clookType})
                doRemoveItem(getTileItemById(secondPos, changeStraw).uid, 1)
                doCreateItem(straw, 1, secondPos)
                doCreatureSetNoMove(cid, false)
                doSendAnimatedText(toPosition, "RESTED", TEXTCOLOR_GREEN)
            end
        end, config.timer * 60 * 1000)
    end
    return true
end
 
Back
Top