I have TFS 0.3.6.
Because on Tibia 8.54 you don't have stackable potions, I wanted to make charges.
I found the following potions script:
http://otland.net/f132/potion-charges-139406/index2.html#post1347175
That script works fine.
But I also want to make a talkaction !potions that will fix all potions you have too potions with charges. That way you don't have to use all potions on each other yourself.
I came pretty far, got this now:
For every potion in the table it will count how much you got.
Then it will create a potion with 100 charges for every 100 you got. And also one potion with charges that are left over(less then 100).
The problem is the following: if I buy 500 potions and say !potions, I get 5 potions with 100 charges. Everything fine. BUT if I say !potions one more time, I get(as expected) 1 potion with 5 charges.
To solve this I need to count all actionIds of all potions(charges are counted with actionId, actionid 5 means 5 charges). But how can I do that?
One more problem: if someone has like 1000 potions or more the command works, but the client the player is on crashes. Some kind of performance issue...
I searched on this forum but couldn't find the answer.
Hope someone will answer my question here...
I have another question about potion with charges: http://otland.net/f16/set-item-weight-147382/
Because on Tibia 8.54 you don't have stackable potions, I wanted to make charges.
I found the following potions script:
http://otland.net/f132/potion-charges-139406/index2.html#post1347175
That script works fine.
But I also want to make a talkaction !potions that will fix all potions you have too potions with charges. That way you don't have to use all potions on each other yourself.
I came pretty far, got this now:
Lua:
local items = { 8704,7618,7588,7591,8473,7620,7589,7590,8472 } --all potion itemids
function onSay(cid, words, param, channel)
for index,value in ipairs(items) do
local itemcount = getPlayerItemCount(cid, value)
if(itemcount > 0) then
local countHundreds = math.floor((itemcount / 100))
local countLeft = itemcount - (countHundreds * 100)
--remove all potions
doPlayerRemoveItem(cid, value, itemcount)
--for every 100 potions you got create new one with 100 charges
if (countHundreds > 0 ) then
for i=countHundreds,1,-1 do
--creating the item
local item = doCreateItemEx(value, 1)
local name = getItemInfo(value).name
doItemSetAttribute(item, 'aid', 100)
doItemSetAttribute(item, 'name', name .. ' (Charges: ' .. 100 .. ')')
-------
doPlayerAddItemEx(cid, item, 1)
end
end
--potions that are left over(less then 100), create new potion with charges
if(countLeft > 0) then
--creating the item
local item = doCreateItemEx(value, 1)
local name = getItemInfo(value).name
doItemSetAttribute(item, 'aid', countLeft)
doItemSetAttribute(item, 'name', name .. ' (Charges: ' .. countLeft .. ')')
-------
doPlayerAddItemEx(cid, item, 1)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Changed potions to potions with charges.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
end
end
return true
end
For every potion in the table it will count how much you got.
Then it will create a potion with 100 charges for every 100 you got. And also one potion with charges that are left over(less then 100).
The problem is the following: if I buy 500 potions and say !potions, I get 5 potions with 100 charges. Everything fine. BUT if I say !potions one more time, I get(as expected) 1 potion with 5 charges.
To solve this I need to count all actionIds of all potions(charges are counted with actionId, actionid 5 means 5 charges). But how can I do that?
One more problem: if someone has like 1000 potions or more the command works, but the client the player is on crashes. Some kind of performance issue...
I searched on this forum but couldn't find the answer.
Hope someone will answer my question here...
I have another question about potion with charges: http://otland.net/f16/set-item-weight-147382/
Last edited: