God Mythera
Veteran OT User
I tried to find a script for 0.4 but when ever i use the item it disappears even when stamina is full. Does anyone have a script for tfs 0.4?
I am using this script, but even if my stamina is full it uses it...Just make it check if stamina is full before using the rune.. or make it check if 'happy hour' stamina is gone.
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.")
doRemoveItem(item.uid)
end
return true
end
local maxStamina = 42 * 60 * 1000
local happyHour = getConfigValue("staminaRatingLimitTop")
function onUse(cid, item, fromPosition, itemEx, toPosition)
local staminaTime = getPlayerStamina(cid) - getConfigValue("staminaRatingLimitTop")
if(getPlayerStamina(cid) >= happyHour) then
doPlayerSendCancel(cid, "You still have ".. staminaTime .." minutes worth of happyHour.")
return true
end
if(not isPremium(cid)) then
doPlayerSendCancel(cid, "You must have a premium account.")
return true
end
if doRemoveItem(item.uid) == TRUE then
doPlayerSetStamina(cid, maxStamina)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
end
return true
end
local refuel_time = 42 * 60 * 1000
function onUse(cid, item, fromPosition, itemEx, toPosition)
-- console print to determine players stamina before executing the script.
print(getPlayerStamina(cid))
-- check if premium
if not isPremium(cid) then
doPlayerSendCancel(cid, "You must have a premium account to use this item.")
return true
end
-- check if stamina is full
if getPlayerStamina(cid) >= refuel_time then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina is full.")
return true
end
-- if everything else checks out fine.. refuel stamina, remove item.
doPlayerSetStamina(cid, refuel_time)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.")
doRemoveItem(item.uid)
-- console print to show what stamina is now that it's been refilled
print(getPlayerStamina(cid))
return true
end
If it returns minutes.. why does it check in seconds? :/it returns how many minutes of stamina a player has left
I tried this and it still removes item even if stamina is full : s-- Edit wrote this in-between rushes at work. Didn't realise Cade submitted a reply.
I'm not at home to test and I'm not familiar with how getPlayerStamina returns values.
It's just a re-written version of the one you posted that should make debugging easier.
If it's all working, just remove the prints later on.
Code:local refuel_time = 42 * 60 * 1000 function onUse(cid, item, fromPosition, itemEx, toPosition) -- console print to determine players stamina before executing the script. print(getPlayerStamina(cid)) -- check if premium if not isPremium(cid) then doPlayerSendCancel(cid, "You must have a premium account to use this item.") return true end -- check if stamina is full if getPlayerStamina(cid) >= refuel_time then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina is full.") return true end -- if everything else checks out fine.. refuel stamina, remove item. doPlayerSetStamina(cid, refuel_time) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.") doRemoveItem(item.uid) -- console print to show what stamina is now that it's been refilled print(getPlayerStamina(cid)) return true end
I am guessing the script will only work if you are under 40 hours?Code:local maxStamina = 42 * 60 * 1000 local happyHour = getConfigValue("staminaRatingLimitTop") function onUse(cid, item, fromPosition, itemEx, toPosition) local staminaTime = getPlayerStamina(cid) - getConfigValue("staminaRatingLimitTop") if(getPlayerStamina(cid) >= happyHour) then doPlayerSendCancel(cid, "You still have ".. staminaTime .." minutes worth of happyHour.") return true end if(not isPremium(cid)) then doPlayerSendCancel(cid, "You must have a premium account.") return true end if doRemoveItem(item.uid) == TRUE then doPlayerSetStamina(cid, maxStamina) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your stamina has been refilled.") end return true end
Fixed your script. Now it can't be used during happy hour.