• 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 Fix need logout and login to update bar

gmstrikker

Well-Known Member
Joined
Jul 30, 2014
Messages
458
Solutions
1
Reaction score
50
I need some help to my stamina potion script, when use its working fine
But to update the stamina bar (on skills) need relog to update...

There is a way to fix it? To update the bar with no relog?

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
  local exhaustedstamina = 3024774
  local cfg = {}
  cfg.refuel = 56 * 60 * 1000
   
  if(os.time() < getCreatureStorage(cid, exhaustedstamina)) then
  doPlayerSendCancel(cid, "You can only use it once every 15 days! You will be able to use this item again on: " .. os.date("%B", getPlayerStorageValue(cid, exhaustedstamina)) .. "-" .. os.date("%d", getPlayerStorageValue(cid, exhaustedstamina)) .. "-" .. os.date("%Y", getPlayerStorageValue(cid, exhaustedstamina)) .. "  " .. os.date("%X", getPlayerStorageValue(cid, exhaustedstamina)) .. ".")
  return true
  end
   
  if(getPlayerStamina(cid) >= cfg.refuel) then
  doPlayerSendCancel(cid, "Your stamina is already full.")
  else
  doPlayerSetStamina(cid, cfg.refuel)
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
  doRemoveItem(item.uid)
  doCreatureSetStorage(cid, exhaustedstamina, os.time() + (15*24*60*60))
  doSendMagicEffect(getCreaturePosition(cid), 14)
  end
   
  return true
end
 
Change
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
to
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina will be refilled upon your next login.")

jk jk
I'm not 100% sure, but you can try to use
Code:
doPlayerAddStamina(cid, minutes)
instead of
Code:
doPlayerSetStamina(cid, cfg.refuel)

(I also think it checks minutes, not seconds. :s.. and at the moment it's checking for 56 hours of stamina.. I thought maximum was 42 hours?)

Try this..?
-- checking for 40 hours stamina.. so it's past their 'happy hours'.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local exhaustedstamina = 3024774
    local cfg = {}
    cfg.refuel = 40 * 60
   
    if(os.time() < getCreatureStorage(cid, exhaustedstamina)) then
        doPlayerSendCancel(cid, "You can only use it once every 15 days! You will be able to use this item again on: " .. os.date("%B", getPlayerStorageValue(cid, exhaustedstamina)) .. "-" .. os.date("%d", getPlayerStorageValue(cid, exhaustedstamina)) .. "-" .. os.date("%Y", getPlayerStorageValue(cid, exhaustedstamina)) .. "  " .. os.date("%X", getPlayerStorageValue(cid, exhaustedstamina)) .. ".")
        return true
    end
   
    if getPlayerStamina(cid) >= cfg.refuel then
        doPlayerSendCancel(cid, "Your stamina is already full.")
    else
        doPlayerAddStamina(cid, cfg.refuel - getPlayerStamina(cid))
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
        doRemoveItem(item.uid)
        doCreatureSetStorage(cid, exhaustedstamina, os.time() + (15*24*60*60))
        doSendMagicEffect(getCreaturePosition(cid), 14)
    end
   
    return true
end
 
cuz testing my script is such hard work.. fml
"The only thing I want is so players don't need to log out"
"Oh hey! What if we force kick the players!? What a fantastic idea."
Code:
doRemoveCreature(cid[, executeLogout = true])
Actually doPlayerAddStamina(cid, minutes) should work..

Code:
if (getTilePzInfo(getThingPos(cid)) == TRUE) then
Not sure if getCreaturePosition(cid) works instead of getThingPos..
Yes, yes it would.
 
cuz testing my script is such hard work.. fml
"The only thing I want is so players don't need to log out"
"Oh hey! What if we force kick the players!? What a fantastic idea."
Code:
doRemoveCreature(cid[, executeLogout = true])

Yes, yes it would.

hahahaha

my problem was to update the bar
if the only way to update bar is relogin
why not kick the player?

i dont want player use the item and cant see stamina changing
 
hahahaha

my problem was to update the bar
if the only way to update bar is relogin
why not kick the player?

i dont want player use the item and cant see stamina changing
Because I gave you a script which would (most likely) update the bar, without having to kick them?
All you had to do was copy paste it.
 
hahahaha

my problem was to update the bar
if the only way to update bar is relogin
why not kick the player?

i dont want player use the item and cant see stamina changing
I have an even better idea, let's ban the player for 10 seconds so we really make sure they can't login and then poff stamina refilled!
 
Back
Top