• 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:
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 ^^
personal preference i guess, personally in a case like this i would deny usage 10/10 times to prevent people from using it then complaining they didnt get the full effect
 
personal preference i guess, personally in a case like this i would deny usage 10/10 times to prevent people from using it then complaining they didnt get the full effect
True.. Perhaps elaborate on the idea and make a check if the player actually wants to use it e.g through some kind of confirmation. Something like: You click it once, if your stamina is 41 < stamina < 42 then if you click once more, it'll use it and give you the stamina. Otherwise it won't. However, that might also bring confusion to the player depending on how it's done
 
You can make it so it only works if u have stamina below x, else it sends a msg saying your stamina need to be lower than x to be refilled again
 
Back
Top