TFS 0.X resting

Discussion in 'Support' started by elnelson, Aug 3, 2018.

  1. elnelson

    elnelson Lunaria World developer

    Joined:
    Jun 20, 2009
    Messages:
    296
    Likes Received:
    8
    Best Answers:
    2
    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
    Code (Lua):
    1.  
    2. function onUse(cid, item, fromPosition, itemEx, toPosition)
    3.    local config = {
    4.        soul = 0, -- amount of souls to start
    5.        timer = 1, -- time in minutes
    6.        rateStamina = 10, -- percent
    7.    }
    8.    
    9.    if getPlayerSoul(cid) >= config.soul then
    10.        local myOutfit, cstamina, secondPos, changeType, changeStraw, straw = getCreatureOutfit(cid), getPlayerStamina(cid), toPosition, 0, 0, 0
    11.        local clookType = myOutfit.lookType
    12.        if itemEx.itemid == 5501 then
    13.            toPosition = toPosition.x - 1
    14.            straw = 5500
    15.        elseif itemEx.itemid == 5503 then
    16.            toPosition = toPosition.y - 1
    17.            straw = 5502
    18.        elseif itemEx.itemid == 5500 then
    19.            secondPos = secondPos.x + 1
    20.            straw = itemEx.itemid
    21.        elseif itemEx.itemid == 5502 then
    22.            secondPos = secondPos.y + 1
    23.            straw = itemEx.itemid
    24.        end
    25.        if itemEx.itemid == 5500 or 5501 then
    26.            if getPlayerSex(cid) == PLAYERSEX_FEMALE then
    27.                changeType = 7841
    28.                changeStraw = 7842
    29.            else
    30.                changeType = 5496
    31.                changeStraw = 5497
    32.            end
    33.        elseif itemEx.itemid == 5502 or 5503 then
    34.            if getPlayerSex(cid) == PLAYERSEX_FEMALE then
    35.                changeType = 7843
    36.                changeStraw = 7844
    37.            else
    38.                changeType = 5498
    39.                changeStraw = 5499
    40.            end
    41.        end
    42.        doTeleportThing(cid, toPosition, false)
    43.        doCreatureChangeOutfit(cid, {lookTypeEx = changeType})
    44.        doCreatureSetNoMove(cid, true)  
    45.        doTransformItem(getTileItemById(secondPos, straw).uid, changeStraw)  
    46.        doSendAnimatedText(toPosition, "RESTING", TEXTCOLOR_ORANGE)
    47.        addEvent(function()
    48.            if isPlayer(cid) then
    49.                doPlayerSetStamina(cid, cstamina + cstamina * config.rateStamina)
    50.                doCreatureChangeOutfit(cid, {lookType = clookType})
    51.                doRemoveItem(getTileItemById(secondPos, changeStraw).uid, 1)
    52.                doCreateItem(straw, 1, secondPos)
    53.                doCreatureSetNoMove(cid, false)
    54.                doSendAnimatedText(toPosition, "RESTED", TEXTCOLOR_GREEN)
    55.            end
    56.        end, config.timer * 60 * 1000)
    57.    end
    58.    return true
    59. end
    60.  
    and i got these errors:
    Code (Lua):
    1.  
    2. [17:52:07.767] [Error - Action Interface]
    3. [17:52:07.773] data/actions/scripts/resting.lua:onUse
    4. [17:52:07.775] Description:
    5. [17:52:07.778] attempt to index a number value
    6. [17:52:07.783] stack traceback:
    7. [17:52:07.785]  [C]: in function 'getTileItemById'
    8. [17:52:07.788]  data/actions/scripts/resting.lua:44: in function <data/actions/scripts/resting.lua:1>
    9. [17:52:13.080] [Error - Action Interface]
    10. [17:52:13.098] data/actions/scripts/resting.lua:onUse
    11. [17:52:13.118] Description:
    12. [17:52:13.140] attempt to index a number value
    13. [17:52:13.143] stack traceback:
    14. [17:52:13.145]  [C]: in function 'doTeleportThing'
    15. [17:52:13.156]  data/actions/scripts/resting.lua:41: in function <data/actions/scripts/resting.lua:1>
     
  2. Xikini

    Xikini I whore myself out for likes

    Joined:
    Nov 17, 2010
    Messages:
    3,572
    Likes Received:
    1,828
    Best Answers:
    80
    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?
    Code (Lua):
    1. function onUse(cid, item, fromPosition, itemEx, toPosition)
    2.     local config = {
    3.         soul = 0, -- amount of souls to start
    4.         timer = 1, -- time in minutes
    5.         rateStamina = 10, -- percent
    6.     }
    7.    
    8.     if getPlayerSoul(cid) >= config.soul then
    9.         local myOutfit, cstamina, secondPos, changeType, changeStraw, straw = getCreatureOutfit(cid), getPlayerStamina(cid), {x = toPosition.x, y = toPosition.y, z = toPosition.z}, 0, 0, 0
    10.         local clookType = myOutfit.lookType
    11.         if itemEx.itemid == 5501 then
    12.             secondPos = {x = toPosition.x - 1, y = toPosition.y, z = toPosition.z}
    13.             straw = 5500
    14.         elseif itemEx.itemid == 5503 then
    15.             secondPos = {x = toPosition.x, y = toPosition.y - 1, z = toPosition.z}
    16.             straw = 5502
    17.         elseif itemEx.itemid == 5500 then
    18.             secondPos = {x = toPosition.x + 1, y = toPosition.y, z = toPosition.z}
    19.             straw = itemEx.itemid
    20.         elseif itemEx.itemid == 5502 then
    21.             secondPos = {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}
    22.             straw = itemEx.itemid
    23.         end
    24.         if itemEx.itemid == 5500 or 5501 then
    25.             if getPlayerSex(cid) == PLAYERSEX_FEMALE then
    26.                 changeType = 7841
    27.                 changeStraw = 7842
    28.             else
    29.                 changeType = 5496
    30.                 changeStraw = 5497
    31.             end
    32.         elseif itemEx.itemid == 5502 or 5503 then
    33.             if getPlayerSex(cid) == PLAYERSEX_FEMALE then
    34.                 changeType = 7843
    35.                 changeStraw = 7844
    36.             else
    37.                 changeType = 5498
    38.                 changeStraw = 5499
    39.             end
    40.         end
    41.         doTeleportThing(cid, toPosition, false)
    42.         doCreatureChangeOutfit(cid, {lookTypeEx = changeType})
    43.         doCreatureSetNoMove(cid, true)
    44.         doTransformItem(getTileItemById(secondPos, straw).uid, changeStraw)
    45.         doSendAnimatedText(toPosition, "RESTING", TEXTCOLOR_ORANGE)
    46.         addEvent(function()
    47.             if isPlayer(cid) then
    48.                 doPlayerSetStamina(cid, cstamina + cstamina * config.rateStamina)
    49.                 doCreatureChangeOutfit(cid, {lookType = clookType})
    50.                 doRemoveItem(getTileItemById(secondPos, changeStraw).uid, 1)
    51.                 doCreateItem(straw, 1, secondPos)
    52.                 doCreatureSetNoMove(cid, false)
    53.                 doSendAnimatedText(toPosition, "RESTED", TEXTCOLOR_GREEN)
    54.             end
    55.         end, config.timer * 60 * 1000)
    56.     end
    57.     return true
    58. end
     

Share This Page

Loading...