• 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 Small Stamina Refil

Forkz

Member
Joined
Jun 29, 2020
Messages
171
Solutions
1
Reaction score
23
Hi Otlanders,

I'm using the script below to fully recover the character's stamina.
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local cfg = {}
    cfg.refuel = 42 * 60 * 1000
    if(getPlayerStamina(cid) >= cfg.refuel) then
        doPlayerSendCancel(cid, "Your stamina is already full.")
    elseif(not isPremium(cid)) then
        doPlayerSendCancel(cid, "You must have a premium account.")
    else
        doPlayerSetStamina(cid, cfg.refuel)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        doSendMagicEffect(fromPosition, 30)
        doRemoveItem(item.uid)
    end
    return true
end

I would like to modify it to recover only 10h, someone help me?
 
Solution
Thats the issue lol..

Here this should work:

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local stamina = 42 * 60
    local refuel = 10 * 60
    if(getPlayerStamina(cid) >= stamina) then
        doPlayerSendCancel(cid, "Your stamina is already full.")
    elseif(not isPremium(cid)) then
        doPlayerSendCancel(cid, "You must have a premium account.")
    else
        doPlayerSetStamina(cid, (getPlayerStamina(cid) + refuel))
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        doSendMagicEffect(fromPosition, 30)
        doRemoveItem(item.uid)
    end
    return true
end

Mjmackan

Mapper ~ Writer
Joined
Jul 18, 2009
Messages
1,209
Solutions
8
Reaction score
90
Location
Sweden
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local cfg = {}
    cfg.refuel = 10 * 60 * 1000
    if(getPlayerStamina(cid) >= cfg.refuel) then
        doPlayerSendCancel(cid, "Your stamina is already full.")
    elseif(not isPremium(cid)) then
        doPlayerSendCancel(cid, "You must have a premium account.")
    else
        doPlayerSetStamina(cid, (getPlayerStamina(cid) + cfg.refuel)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        doSendMagicEffect(fromPosition, 30)
        doRemoveItem(item.uid)
    end
    return true
end
 
OP
Forkz

Forkz

Member
Joined
Jun 29, 2020
Messages
171
Solutions
1
Reaction score
23
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local cfg = {}
    cfg.refuel = 10 * 60 * 1000
    if(getPlayerStamina(cid) >= cfg.refuel) then
        doPlayerSendCancel(cid, "Your stamina is already full.")
    elseif(not isPremium(cid)) then
        doPlayerSendCancel(cid, "You must have a premium account.")
    else
        doPlayerSetStamina(cid, (getPlayerStamina(cid) + cfg.refuel)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        doSendMagicEffect(fromPosition, 30)
        doRemoveItem(item.uid)
    end
    return true
end
Still "healing" all the stamina
 
OP
Forkz

Forkz

Member
Joined
Jun 29, 2020
Messages
171
Solutions
1
Reaction score
23
doPlayerSetStamina(cid, (getPlayerStamina(cid) + cfg.refuel))
change this line
Yes, I had already changed. Thanks
Post automatically merged:

It would have to be something like this


Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local cfg = {}
    full.stamina = 42 * 60 * 1000
    cfg.refuel = 10 * 60 * 1000
    if(getPlayerStamina(cid) >= full.stamina) then
        doPlayerSendCancel(cid, "Your stamina is already full.")
    elseif(not isPremium(cid)) then
        doPlayerSendCancel(cid, "You must have a premium account.")
    else
        doPlayerSetStamina(cid, (getPlayerStamina(cid) + cfg.refuel))
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        doSendMagicEffect(fromPosition, 30)
        doRemoveItem(item.uid)
    end
    return true
end
 
Last edited:

Ascuas Funkeln

Rakkedo Game
Joined
Apr 14, 2013
Messages
515
Solutions
30
Reaction score
266
Location
Poland
GitHub
AscuasFunkeln
Yes, I had already changed. Thanks
Post automatically merged:

It would have to be something like this


Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local cfg = {}
    full.stamina = 42 * 60 * 1000
    cfg.refuel = 10 * 60 * 1000
    if(getPlayerStamina(cid) >= full.stamina) then
        doPlayerSendCancel(cid, "Your stamina is already full.")
    elseif(not isPremium(cid)) then
        doPlayerSendCancel(cid, "You must have a premium account.")
    else
        doPlayerSetStamina(cid, (getPlayerStamina(cid) + cfg.refuel))
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        doSendMagicEffect(fromPosition, 30)
        doRemoveItem(item.uid)
    end
    return true
end
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition)
    local StaminaLevel = player:getStamina()
    local StaminaMax = 42 * 60 * 1000
    local StaminaValue = 10 * 60 * 100
    if StaminaLevel >= StaminaMax then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina is already full.")
    elseif(not player:isPremium()) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You must have a premium account.")
    else
        player:setStamina(StaminaLevel + StaminaValue)
        player:getPosition():sendMagicEffect(30)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        Item(item.uid):remove(1)
    end
    return true
end

Cuz i see you other threads, you use 1.2?
 

Mjmackan

Mapper ~ Writer
Joined
Jul 18, 2009
Messages
1,209
Solutions
8
Reaction score
90
Location
Sweden
Use this and send me the console prints.

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local stamina = 42 * 60 * 1000
    local refuel = 10 * 60 * 1000
    if(getPlayerStamina(cid) >= stamina) then
        doPlayerSendCancel(cid, "Your stamina is already full.")
    elseif(not isPremium(cid)) then
        doPlayerSendCancel(cid, "You must have a premium account.")
    else
        print("Before stamina:"..(getPlayerStamina(cid))
        doPlayerSetStamina(cid, (getPlayerStamina(cid) + refuel)
        print("After stamina:"..(getPlayerStamina(cid))
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        doSendMagicEffect(fromPosition, 30)
        doRemoveItem(item.uid)
    end
    return true
end
 
OP
Forkz

Forkz

Member
Joined
Jun 29, 2020
Messages
171
Solutions
1
Reaction score
23
Use this and send me the console prints.

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local stamina = 42 * 60 * 1000
    local refuel = 10 * 60 * 1000
    if(getPlayerStamina(cid) >= stamina) then
        doPlayerSendCancel(cid, "Your stamina is already full.")
    elseif(not isPremium(cid)) then
        doPlayerSendCancel(cid, "You must have a premium account.")
    else
        print("Before stamina:"..(getPlayerStamina(cid))
        doPlayerSetStamina(cid, (getPlayerStamina(cid) + refuel)
        print("After stamina:"..(getPlayerStamina(cid))
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        doSendMagicEffect(fromPosition, 30)
        doRemoveItem(item.uid)
    end
    return true
end
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local stamina = 42 * 60 * 1000
    local refuel = 10 * 60 * 1000
    if(getPlayerStamina(cid) >= stamina) then
        doPlayerSendCancel(cid, "Your stamina is already full.")
    elseif(not isPremium(cid)) then
        doPlayerSendCancel(cid, "You must have a premium account.")
    else
        print("Before stamina:"..(getPlayerStamina(cid)))
        doPlayerSetStamina(cid, (getPlayerStamina(cid) + refuel))
        print("After stamina:"..(getPlayerStamina(cid)))
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        doSendMagicEffect(fromPosition, 30)
        doRemoveItem(item.uid)
    end
    return true
end

No errors on the console, but it recovers the full stamina, not the "10h"


C++:
Before stamina:1119
After stamina:2520
Post automatically merged:

Lua:
function onUse(player, item, fromPosition, itemEx, toPosition)
    local StaminaLevel = player:getStamina()
    local StaminaMax = 42 * 60 * 1000
    local StaminaValue = 10 * 60 * 100
    if StaminaLevel >= StaminaMax then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina is already full.")
    elseif(not player:isPremium()) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You must have a premium account.")
    else
        player:setStamina(StaminaLevel + StaminaValue)
        player:getPosition():sendMagicEffect(30)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        Item(item.uid):remove(1)
    end
    return true
end

Cuz i see you other threads, you use 1.2?
No, i using TFS 0.4
 

Ascuas Funkeln

Rakkedo Game
Joined
Apr 14, 2013
Messages
515
Solutions
30
Reaction score
266
Location
Poland
GitHub
AscuasFunkeln
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local stamina = 42 * 60 * 1000
    local refuel = 10 * 60 * 1000
    if(getPlayerStamina(cid) >= stamina) then
        doPlayerSendCancel(cid, "Your stamina is already full.")
    elseif(not isPremium(cid)) then
        doPlayerSendCancel(cid, "You must have a premium account.")
    else
        print("Before stamina:"..(getPlayerStamina(cid)))
        doPlayerSetStamina(cid, (getPlayerStamina(cid) + refuel))
        print("After stamina:"..(getPlayerStamina(cid)))
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        doSendMagicEffect(fromPosition, 30)
        doRemoveItem(item.uid)
    end
    return true
end

No errors on the console, but it recovers the full stamina, not the "10h"


C++:
Before stamina:1119
After stamina:2520
Post automatically merged:


No, i using TFS 0.4
Trust me, migrate to higher release :)
 

Mjmackan

Mapper ~ Writer
Joined
Jul 18, 2009
Messages
1,209
Solutions
8
Reaction score
90
Location
Sweden
Thats the issue lol..

Here this should work:

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local stamina = 42 * 60
    local refuel = 10 * 60
    if(getPlayerStamina(cid) >= stamina) then
        doPlayerSendCancel(cid, "Your stamina is already full.")
    elseif(not isPremium(cid)) then
        doPlayerSendCancel(cid, "You must have a premium account.")
    else
        doPlayerSetStamina(cid, (getPlayerStamina(cid) + refuel))
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        doSendMagicEffect(fromPosition, 30)
        doRemoveItem(item.uid)
    end
    return true
end
 
Solution
OP
Forkz

Forkz

Member
Joined
Jun 29, 2020
Messages
171
Solutions
1
Reaction score
23
Thats the issue lol..

Here this should work:

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local stamina = 42 * 60
    local refuel = 10 * 60
    if(getPlayerStamina(cid) >= stamina) then
        doPlayerSendCancel(cid, "Your stamina is already full.")
    elseif(not isPremium(cid)) then
        doPlayerSendCancel(cid, "You must have a premium account.")
    else
        doPlayerSetStamina(cid, (getPlayerStamina(cid) + refuel))
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        doSendMagicEffect(fromPosition, 30)
        doRemoveItem(item.uid)
    end
    return true
end
Working bro, thanks!
 

adrian alvarez

New Member
Joined
Mar 7, 2017
Messages
34
Solutions
1
Reaction score
3
Now we are on Stamina, anyone know how to transform it on revscript ?
I will have tried several times, but doesnt work , for tfs 1.3
Lua:
local stamina = Action()

function stamina.onUse(player, item, fromPosition, itemEx, toPosition)
    local StaminaLevel = player:getStamina()
    local StaminaMax = 42 * 60
    local StaminaValue = 4 * 60
    if StaminaLevel >= StaminaMax then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina is already full.")
    elseif(not player:isPremium()) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You must have a premium account.")
    else
        player:setStamina(StaminaLevel + StaminaValue)
        player:getPosition():sendMagicEffect(30)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        Item(item.uid):remove(1)
    end
    return true
end

stamina:id(12662)
stamina:register()



transform this and do not release a single error, increase 4 hours of stamina or change it to your liking xd
 

Mjmackan

Mapper ~ Writer
Joined
Jul 18, 2009
Messages
1,209
Solutions
8
Reaction score
90
Location
Sweden
Lua:
local stamina = Action()

function stamina.onUse(player, item, fromPosition, itemEx, toPosition)
    local StaminaLevel = player:getStamina()
    local StaminaMax = 42 * 60
    local StaminaValue = 4 * 60
    if StaminaLevel >= StaminaMax then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina is already full.")
    elseif(not player:isPremium()) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You must have a premium account.")
    else
        player:setStamina(StaminaLevel + StaminaValue)
        player:getPosition():sendMagicEffect(30)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        Item(item.uid):remove(1)
    end
    return true
end

stamina:id(12662)
stamina:register()



transform this and do not release a single error, increase 4 hours of stamina or change it to your liking xd
Instead of bumping old support threads, create a new thread.
 

Indahouse

Member
Joined
May 13, 2015
Messages
79
Reaction score
10
That's crazy when you create a thread it says look before if you didnt see a topic similar, for some month or days you can revive it, not doing 200 milions threads for a stamina refill. Is for this after you are looking for a such script and you found 50 pages of people doing each time new thread, is very bad and your are lost on this forum.

Here is the script, people just making a reply for says this instead of helping, you finish thinking they are here for increade is messages and finally he didnt apport anything.

Lua:
local smallstaminarefill = Action()
function smallstaminarefill.onUse(player, item, ...)
    local stamina = player:getStamina()
    if stamina >= 2520 then
        player:sendCancelMessage("You have full stamina.")
        return true
    end
    player:setStamina(math.min(2520, stamina + 120))
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:sendCancelMessage("You have regenerated 2 hours of Stamina.")
    item:remove(1)
    return true
end

smallstaminarefill:id(36185)
smallstaminarefill:register()
 
Top