• 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!

TFS 1.2 Is it possible to give storage if player uses x amount of potions

Tbol

Active Member
Joined
Apr 7, 2019
Messages
394
Reaction score
43
Is it even possible? If player uses potions like 2500 times he gets storage x? And probably it should save it somehow too because if he disconnects the progress wont be lost.
Using this one right now
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
ITEM = 5279
local storage = 50000
local wait = 1.5
local pos1 = {x = getPlayerPosition(cid).x + 0, y = getPlayerPosition(cid).y + 0, z = getPlayerPosition(cid).z}
if fromPosition.x ~= CONTAINER_POSITION and exhaustion.get(cid, storage) == FALSE then
REG_HEALTH = 2000
REG_MANA = 2000
doPlayerAddMana(cid, REG_MANA)
doCreatureAddHealth(cid, REG_HEALTH)
Player(cid):say("Used potion!", TALKTYPE_SAY) 
doSendMagicEffect(pos1, 210)
doRemoveItem(item.uid, 1)
exhaustion.set(cid, storage, wait)
elseif item.itemid == ITEM and exhaustion.get(cid, storage) == FALSE then
REG_HEALTH = 20000
REG_MANA = 20000
doPlayerAddMana(cid, REG_MANA)
doCreatureAddHealth(cid, REG_HEALTH)
Player(cid):say("Used potion!", TALKTYPE_SAY) 
doSendMagicEffect(pos1, 210)
doRemoveItem(item.uid,1)
exhaustion.set(cid, storage, wait)
else
doPlayerSendCancel(cid, "You are exhausted.")
end
return TRUE
end
 

Evil Puncker

I know nothing
TFS Developer
Joined
May 30, 2009
Messages
8,116
Solutions
218
Reaction score
4,034
Is it even possible?
of course it is, just look at these examples:
 
OP
OP
Tbol

Tbol

Active Member
Joined
Apr 7, 2019
Messages
394
Reaction score
43
of course it is, just look at these examples:
Basically its
Lua:
        if getPlayerStorageValue(cid,21066) == 2500 then
        doPlayerSendTextMessage(cid,22,"Congratulations! You earned the achievement \"Potion Addict\".")
       doPlayerAddAchievement(cid, 66)
        end
and every time he uses potion need to add
Lua:
setPlayerStorageValue(cid, 21066, getCreatureStorage(cid, 21066) + 1)
or i miss understood something?
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,810
Solutions
433
Reaction score
3,949
Basically its
Lua:
        if getPlayerStorageValue(cid,21066) == 2500 then
        doPlayerSendTextMessage(cid,22,"Congratulations! You earned the achievement \"Potion Addict\".")
       doPlayerAddAchievement(cid, 66)
        end
and every time he uses potion need to add
Lua:
setPlayerStorageValue(cid, 21066, getCreatureStorage(cid, 21066) + 1)
or i miss understood something?
Lua:
local storageX = 45000
local storagePotions = 45001

local currentValue = player:getStorageValue(storagePotions)
if currentValue < 2500 then
    local newValue = currentValue < 0 and 1 or currentValue + 1
    player:setStorageValue(storagePotions, newValue)
elseif currentValue == 2500 then
    player:setStorageValue(storagePotions, 2501)
    player:setStorageValue(storageX, 1)
end
 
OP
OP
Tbol

Tbol

Active Member
Joined
Apr 7, 2019
Messages
394
Reaction score
43
Lua:
local storageX = 45000
local storagePotions = 45001

local currentValue = player:getStorageValue(storagePotions)
if currentValue < 2500 then
    local newValue = currentValue < 0 and 1 or currentValue + 1
    player:setStorageValue(storagePotions, newValue)
elseif currentValue == 2500 then
    player:setStorageValue(storagePotions, 2501)
    player:setStorageValue(storageX, 1)
end
Thanks gonna try it out
 
Top