• 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 [TFS 0.X] Action who remove storage and set new one

potinho

Intermediate OT User
Joined
Oct 11, 2009
Messages
1,397
Solutions
17
Reaction score
148
Location
Brazil
I'm working on a new system, and I'd like to ask for some help. I have an item that sets a storage for the player. But I will need something different: I need another item that I create to remove this storage and add a new one. can you help me?

actual script:

Lua:
local storage = 9870
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, storage) == -1 then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have learned the password to access the old world city. The password is Rookgaard!")
         setPlayerStorageValue(cid, storage, 1)
         doRemoveItem(item.uid, 1)
     else
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've read the stories about the world of Tibia and already know how to access your abandoned city.")
     end
     return true
end
 
Solution
Yeah, I explained it in a really bad way, but that's about it. I managed to add outfits and addons on my 7.72 server, but in Outfits.xml I will need to duplicate an addon to work (the only way I could). Would be like this:

XML:
<outfit id="16" premium="yes" default="0">        <list gender="0" lookType="320" storage="1000" name="Shaman"/>        <list gender="1" lookType="305"  storage="1000" name="Shaman"/>    </outfit> <outfit id="17" premium="yes" default="0">        <list gender="0" lookType="320" addons="1" storage="2000" name="Shaman"/>        <list gender="1" lookType="305" addons="1" storage="2000" name="Shaman"/>    </outfit> <outfit id="18" premium="yes" default="0">        <list gender="0" lookType="320" addons="2"...
Are you just explaining poorly?
This request seems entirely too simple.

Lua:
local storage1 = 9870
local storage2 = ????

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, storage1) == 1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Removing required storage, and giving second storage +1 in it's place.")
        setPlayerStorageValue(cid, storage1, -1)
        local current_value = getPlayerStorageValue(cid, storage2)
        setPlayerStorageValue(cid, storage1, current_value == -1 and 1 or current_value + 1) -- gives +1 to storage value
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Required storage not available.")
    end
    return true
end
 
Are you just explaining poorly?
This request seems entirely too simple.

Lua:
local storage1 = 9870
local storage2 = ????

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, storage1) == 1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Removing required storage, and giving second storage +1 in it's place.")
        setPlayerStorageValue(cid, storage1, -1)
        local current_value = getPlayerStorageValue(cid, storage2)
        setPlayerStorageValue(cid, storage1, current_value == -1 and 1 or current_value + 1) -- gives +1 to storage value
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Required storage not available.")
    end
    return true
end
Yeah, I explained it in a really bad way, but that's about it. I managed to add outfits and addons on my 7.72 server, but in Outfits.xml I will need to duplicate an addon to work (the only way I could). Would be like this:

XML:
<outfit id="16" premium="yes" default="0">        <list gender="0" lookType="320" storage="1000" name="Shaman"/>        <list gender="1" lookType="305"  storage="1000" name="Shaman"/>    </outfit> <outfit id="17" premium="yes" default="0">        <list gender="0" lookType="320" addons="1" storage="2000" name="Shaman"/>        <list gender="1" lookType="305" addons="1" storage="2000" name="Shaman"/>    </outfit> <outfit id="18" premium="yes" default="0">        <list gender="0" lookType="320" addons="2" storage="3000" name="Shaman"/>        <list gender="1" lookType="305" addons="2" storage="3000" name="Shaman"/>    </outfit>

So when the player took the first part, it would set storage 1000. When it took the second, 2000 (and remove storage 1000 so it wouldn't be duplicated). And when you took the last one, it would set storage 3000 and remove storage 2000.
 
Yeah, I explained it in a really bad way, but that's about it. I managed to add outfits and addons on my 7.72 server, but in Outfits.xml I will need to duplicate an addon to work (the only way I could). Would be like this:

XML:
<outfit id="16" premium="yes" default="0">        <list gender="0" lookType="320" storage="1000" name="Shaman"/>        <list gender="1" lookType="305"  storage="1000" name="Shaman"/>    </outfit> <outfit id="17" premium="yes" default="0">        <list gender="0" lookType="320" addons="1" storage="2000" name="Shaman"/>        <list gender="1" lookType="305" addons="1" storage="2000" name="Shaman"/>    </outfit> <outfit id="18" premium="yes" default="0">        <list gender="0" lookType="320" addons="2" storage="3000" name="Shaman"/>        <list gender="1" lookType="305" addons="2" storage="3000" name="Shaman"/>    </outfit>

So when the player took the first part, it would set storage 1000. When it took the second, 2000 (and remove storage 1000 so it wouldn't be duplicated). And when you took the last one, it would set storage 3000 and remove storage 2000.
Lua:
local storage1 = 1000
local storage2 = 2000
local storage3 = 3000

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, storage3) == 1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Outfit and All Addons already obtained.")
        return true
    elseif getPlayerStorageValue(cid, storage2) == 1 then
        setPlayerStorageValue(cid, storage2, -1)
        setPlayerStorageValue(cid, storage3, 1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Addon 2 obtained.")
    elseif getPlayerStorageValue(cid, storage1) == 1 then
        setPlayerStorageValue(cid, storage1, -1)
        setPlayerStorageValue(cid, storage2, 1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Addon 1 obtained.")
    else
        setPlayerStorageValue(cid, storage1, 1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Outfit obtained.")
    end
    doRemoveItem(item.uid, 1)
    return true
end
 
Solution
Back
Top