• 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 stamina pill

Lbtg

Advanced OT User
Joined
Nov 22, 2008
Messages
2,398
Reaction score
165
hello i use 0.4 i got this script
i wanna make it refils 1 hoour stamina ,
now it moves your stamina to 1 hour lol
script
PHP:
function onUse(cid, item, frompos, item2, topos)
local config = {
staminafull = 1*60, effect = 1 }
player = getPlayerPosition(cid)
playerstamina = getPlayerStamina(cid)
playeracc = getPlayerAccess(cid)
playerfood = getPlayerFood(cid)
if playeracc <= 2 then
    if playerfood ~= 0 then
        if playerstamina ~= config.staminafull then
            setPlayerStamina(cid, config.staminafull)
            doRemoveItem(item.uid, 1)
            doPlayerSendTextMessage(cid,22,"Stamina added by a stamina pill!")
            doSendMagicEffect(player, config.effect)
        else
            doPlayerSendTextMessage(cid,22,"You dont need a stamina pill!")
        end
    else
        doPlayerSendTextMessage(cid,22,"You can't use it if hungry!")
    end
else
doPlayerSendTextMessage(cid,22,"You are a member of the staff. You dont Need it!")
end
return true
end
 
Last edited:
hello i got this script
i wanna make it refils 1 hoour stamina ,
now it moves your stamina to 1 hour lol
script
PHP:
function onUse(cid, item, frompos, item2, topos)
local config = {
staminafull = 1*60, effect = 1 }
player = getPlayerPosition(cid)
playerstamina = getPlayerStamina(cid)
playeracc = getPlayerAccess(cid)
playerfood = getPlayerFood(cid)
if playeracc <= 2 then
    if playerfood ~= 0 then
        if playerstamina ~= config.staminafull then
            setPlayerStamina(cid, config.staminafull)
            doRemoveItem(item.uid, 1)
            doPlayerSendTextMessage(cid,22,"Stamina added by a stamina pill!")
            doSendMagicEffect(player, config.effect)
        else
            doPlayerSendTextMessage(cid,22,"You dont need a stamina pill!")
        end
    else
        doPlayerSendTextMessage(cid,22,"You can't use it if hungry!")
    end
else
doPlayerSendTextMessage(cid,22,"You are a member of the staff. You dont Need it!")
end
return true
end

Perhaps try:

Code:
function onUse(cid, item, frompos, item2, topos)

local config = {
staminafull = 1*60, effect = 1 }
player = getPlayerPosition(cid)
playerstamina = getPlayerStamina(cid)
playeracc = getPlayerAccess(cid)
playerfood = getPlayerFood(cid)
if playeracc <= 2 then
    if playerfood ~= 0 then
        if playerstamina ~= config.staminafull then
            setPlayerStamina(cid, config.staminafull + playerstamina)
            doRemoveItem(item.uid, 1)
            doPlayerSendTextMessage(cid, 22, "Stamina added by a stamina pill!")
            doSendMagicEffect(cid, config.effect)
        else
            doPlayerSendTextMessage(cid, 22, "You dont need a stamina pill!")
        end
    else
        doPlayerSendTextMessage(cid, 22, "You can't use it if hungry!")
    end
else
    doPlayerSendTextMessage(cid, 22, "You are a member of the staff. You don't need it!")
end
return true
end
 
w
Perhaps try:

Code:
function onUse(cid, item, frompos, item2, topos)

local config = {
staminafull = 1*60, effect = 1 }
player = getPlayerPosition(cid)
playerstamina = getPlayerStamina(cid)
playeracc = getPlayerAccess(cid)
playerfood = getPlayerFood(cid)
if playeracc <= 2 then
    if playerfood ~= 0 then
        if playerstamina ~= config.staminafull then
            setPlayerStamina(cid, config.staminafull + playerstamina)
            doRemoveItem(item.uid, 1)
            doPlayerSendTextMessage(cid, 22, "Stamina added by a stamina pill!")
            doSendMagicEffect(cid, config.effect)
        else
            doPlayerSendTextMessage(cid, 22, "You dont need a stamina pill!")
        end
    else
        doPlayerSendTextMessage(cid, 22, "You can't use it if hungry!")
    end
else
    doPlayerSendTextMessage(cid, 22, "You are a member of the staff. You don't need it!")
end
return true
end
works perfecly could you add so it works effects on use since now it doesnt work ? :)
errror
HTML:
[12:49:38.211] [Error - Action Interface]
[12:49:38.211] data/actions/scripts/staminadoll1.lua:onUse
[12:49:38.211] Description:
[12:49:38.211] attempt to index a number value
[12:49:38.211] stack traceback:
[12:49:38.211]  [C]: in function 'doSendMagicEffect'
[12:49:38.211]  data/actions/scripts/staminadoll1.lua:15: in function <data/actions/scripts/staminadoll1.lua:1>

aswell could you add so if player has full stamina he cant eat pill he gets cancel message with poff effect " your stamina is to full to refill it"
 
Code:
function onUse(cid, item, frompos, item2, topos)

local config = {
    stamina_amount = 1 * 60,
    fullstamina_effect = CONST_ME_POFF, --//Change to the effects you want here
    stamina_effect = CONST_ME_HEARTS  --//Change to the effects you want here
}

player = getPlayerPosition(cid)
playerstamina = getPlayerStamina(cid)
playeracc = getPlayerAccess(cid)
playerfood = getPlayerFood(cid)
if playeracc <= 2 then
    if playerfood ~= 0 then
        if playerstamina ~= config.stamina_amount then
            setPlayerStamina(cid, config.stamina_amount + playerstamina)
            doRemoveItem(item.uid, 1)
            doPlayerSendTextMessage(cid, 22, "" .. config.stamina_amount .."minutes of stamina has been added by a stamina pill!")
            doSendMagicEffect(cid, config.fullstamina_effect)
        else
            doPlayerSendTextMessage(cid, 22, "You dont need a stamina pill!")
            doSendMagicEffect(cid, config.fullstamina_effect)
        end
    else
        doPlayerSendTextMessage(cid, 22, "You can't use it if hungry!")
    end
else
    doPlayerSendTextMessage(cid, 22, "You are a member of the staff. You don't need it!")
end
return true
end

Not sure if this was what you wanted
 
error cant see any effects but stamina gets added
HTML:
[13:16:49.019] [Error - Action Interface]
[13:16:49.019] data/actions/scripts/staminadoll1.lua:onUse
[13:16:49.019] Description:
[13:16:49.019] attempt to index a number value
[13:16:49.019] stack traceback:
[13:16:49.019]  [C]: in function 'doSendMagicEffect'
[13:16:49.019]  data/actions/scripts/staminadoll1.lua:19: in function <data/actions/scripts/staminadoll1.lua:1>
 
and + it says
16:16 60hour(s) of stamina has been added by a stamina pill! ^^
I already edited it to minutes xD. It was a bad addition, i'm aware

Code:
function onUse(cid, item, frompos, item2, topos)

local config = {
    stamina_amount = 1 * 60,
    fullstamina_effect = CONST_ME_POFF, --//Change to the effects you want here
    stamina_effect = CONST_ME_HEARTS  --//Change to the effects you want here
}

player = getPlayerPosition(cid)
playerstamina = getPlayerStamina(cid)
playeracc = getPlayerAccess(cid)
playerfood = getPlayerFood(cid)
if playeracc <= 2 then
    if playerfood ~= 0 then
        if playerstamina ~= config.stamina_amount then
            setPlayerStamina(cid, config.stamina_amount + playerstamina)
            doRemoveItem(item.uid, 1)
            doPlayerSendTextMessage(cid, 22, "" .. config.stamina_amount .." minutes of stamina has been added by a stamina pill!")
            doSendMagicEffect(getCreaturePosition(cid), config.fullstamina_effect)
        else
            doPlayerSendTextMessage(cid, 22, "You dont need a stamina pill!")
            doSendMagicEffect(getCreaturePosition(cid), config.fullstamina_effect)
        end
    else
        doPlayerSendTextMessage(cid, 22, "You can't use it if hungry!")
    end
else
    doPlayerSendTextMessage(cid, 22, "You are a member of the staff. You don't need it!")
end
return true
end
 
Last edited:
still error
HTML:
[13:23:20.864] [Error - Action Interface]
[13:23:20.864] data/actions/scripts/staminadoll1.lua:onUse
[13:23:20.864] Description:
[13:23:20.864] attempt to index a number value
[13:23:20.864] stack traceback:
[13:23:20.864]  [C]: in function 'doSendMagicEffect'
[13:23:20.864]  data/actions/scripts/staminadoll1.lua:19: in function <data/actions/scripts/staminadoll1.lua:1>

thanks bro for helping me out :)
 
oke it works , but after my stamina is full i still can eat it and i recieve message
16:36 60 minutes of stamina has been added by a stamina pill!
i still can eat nonstop after my stamina is full
also i think effects is reversed
 
change
Code:
if playerstamina ~= config.stamina_amount then
to
Code:
if playerstamina < (41 * 60) then
no point checking if stamina == 60 minutes left, but rather check if its >60 minutes missing on stamina bar
 
change
Code:
if playerstamina ~= config.stamina_amount then
to
Code:
if playerstamina < (41 * 60) then
no point checking if stamina == 60 minutes left, but rather check if its >60 minutes missing on stamina bar
perfect
but if stamina is full and i try eat item i get same effect as on eat then stamina is low
 
PHP:
function onUse(cid, item, frompos, item2, topos)

local config = {
    stamina_amount = 1 * 60,
    fullstamina_effect = 11, --//Change to the effects you want here
    stamina_effect = CONST_ME_POFF  --//Change to the effects you want here
}

player = getPlayerPosition(cid)
playerstamina = getPlayerStamina(cid)
playeracc = getPlayerAccess(cid)
playerfood = getPlayerFood(cid)
if playeracc <= 2 then
    if playerfood ~= 0 then
         if playerstamina < (41 * 60) then
            setPlayerStamina(cid, config.stamina_amount + playerstamina)
            doRemoveItem(item.uid, 1)
            doPlayerSendTextMessage(cid, 22, "" .. config.stamina_amount .." minutes of stamina has been added by a stamina pill!")
            doSendMagicEffect(getCreaturePosition(cid), config.fullstamina_effect)
        else
            doPlayerSendTextMessage(cid, 22, "You dont need a stamina pill!")
            doSendMagicEffect(getCreaturePosition(cid), config.stamina_effect)
        end
    else
        doPlayerSendTextMessage(cid, 22, "You can't use it if hungry!")
    end
else
    doPlayerSendTextMessage(cid, 22, "You are a member of the staff. You don't need it!")
end
return true
end
 
PHP:
function onUse(cid, item, frompos, item2, topos)

local config = {
    stamina_amount = 1 * 60,
    fullstamina_effect = 11, --//Change to the effects you want here
    stamina_effect = CONST_ME_POFF  --//Change to the effects you want here
}

player = getPlayerPosition(cid)
playerstamina = getPlayerStamina(cid)
playeracc = getPlayerAccess(cid)
playerfood = getPlayerFood(cid)
if playeracc <= 2 then
    if playerfood ~= 0 then
         if playerstamina < (41 * 60) then
            setPlayerStamina(cid, config.stamina_amount + playerstamina)
            doRemoveItem(item.uid, 1)
            doPlayerSendTextMessage(cid, 22, "" .. config.stamina_amount .." minutes of stamina has been added by a stamina pill!")
            doSendMagicEffect(getCreaturePosition(cid), config.fullstamina_effect)
        else
            doPlayerSendTextMessage(cid, 22, "You dont need a stamina pill!")
            doSendMagicEffect(getCreaturePosition(cid), config.stamina_effect)
        end
    else
        doPlayerSendTextMessage(cid, 22, "You can't use it if hungry!")
    end
else
    doPlayerSendTextMessage(cid, 22, "You are a member of the staff. You don't need it!")
end
return true
end
change this line
Code:
 if playerstamina < (41 * 60) then
to
Code:
 if playerstamina < (42 * 60) then
as otherwise e.g if t was a function (mathematics) then let it go towards 41, it'll never reach it. Instead, it'll go towards 40,99999999999 and poff it doesn't work in every case you want it to work e.g when playerstamina is >= 41.
 
change this line
Code:
 if playerstamina < (41 * 60) then
to
Code:
 if playerstamina < (42 * 60) then
as otherwise e.g if t was a function (mathematics) then let it go towards 41, it'll never reach it. Instead, it'll go towards 40,99999999999 and poff it doesn't work in every case you want it to work e.g when playerstamina is >= 41.
if you have 42*60 you can use it as soon as you lose 1 minute of stamina, which incase a player clicks it by accident would waste some stamina
while 41*60 will never activate unless the doll will give the full effect (and in tibia there is no difference if stamina is (40h<stam<42h) considering the entire 2 hour interval is bonus xp (with standard settings), so its not really a problem)
realistically the only time you would ever want to refill stamina is when it is outside bonus range aka <440h anyway
 
if you have 42*60 you can use it as soon as you lose 1 minute of stamina, which incase a player clicks it by accident would waste some stamina
while 41*60 will never activate unless the doll will give the full effect (and in tibia there is no difference if stamina is (40h<stam<42h) considering the entire 2 hour interval is bonus xp (with standard settings), so its not really a problem)
ah, yeah that's true. Solution:

Code:
local config = {
    stamina_amount = 1 * 60,
    fullstamina_effect = 11, --//Change to the effects you want here
    stamina_effect = CONST_ME_POFF  --//Change to the effects you want here
}
player = getCreaturePosition(cid)
playerstamina = getPlayerStamina(cid)
playeracc = getPlayerAccess(cid)
playerfood = getPlayerFood(cid)
if playeracc <= 2 then
    if playerfood ~= 0 then
         if playerstamina < (41 * 60) then
            setPlayerStamina(cid, config.stamina_amount + playerstamina)
            doRemoveItem(item.uid, 1)
            doPlayerSendTextMessage(cid, 22, "" .. config.stamina_amount .." minutes of stamina has been added by a stamina pill!")
            doSendMagicEffect(getCreaturePosition(cid), config.fullstamina_effect)
        elseif((41 * 60) < playerstamina < (42 * 60)) then
            setPlayerStamina(cid, (42 * 60))
            doPlayerSendTextMesssage(cid, 22, "Your stamina has been fully refilled!")
            doSendMagicEffect(player, config.fullstamina_effect)
        else
            doPlayerSendTextMessage(cid, 22, "You dont need a stamina pill!")
            doSendMagicEffect(player, config.stamina_effect)
        end
    else
        doPlayerSendTextMessage(cid, 22, "You can't use it if hungry!")
    end
else
    doPlayerSendTextMessage(cid, 22, "You are a member of the staff. You don't need it!")
return true
end

Edit: Sure, now you can use it whenever but personally I feel it'd be weird if it prevents me to use it whenever you want to ^^
 
Back
Top