• 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] Use only if you have "X" storage

potinho

Intermediate OT User
Joined
Oct 11, 2009
Messages
1,397
Solutions
17
Reaction score
148
Location
Brazil
Good evening, how to make it possible to use a certain item only if you have "X" storage? I have an action that gives the player a storage, but I only want it to be able to use it if it already has another storage (313722) = 1.

Lua:
local storage = 396122
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, storage) == -1 then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got a new look, open your clothes to check it out!!")
         setPlayerStorageValue(cid, storage, 1)
         doRemoveItem(item.uid, 1)
     else
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already have this appearance.")
     end
     return true
end
 
Solution
like a scroll, that i use one time
Post automatically merged:


i want to use a scroll in rpg, that scroll it gives me a rpg but i need to get a previuos storage to be able to use that scroll

Lua:
local storage = 396122
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, storage) == 1 then -- here you check if the player has storage(396122) and value(1, 2, 3...)
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got a new look, open your clothes to check it out!!")
         setPlayerStorageValue(cid, storage, 2) -- keep it like this if you want the player to use it only once, or, delete this line to use it multiple times(still the player will need more than 1 item if he wants to use it...
Good evening, how to make it possible to use a certain item only if you have "X" storage? I have an action that gives the player a storage, but I only want it to be able to use it if it already has another storage (313722) = 1.

Lua:
local storage = 396122
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, storage) == -1 then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got a new look, open your clothes to check it out!!")
         setPlayerStorageValue(cid, storage, 1)
         doRemoveItem(item.uid, 1)
     else
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already have this appearance.")
     end
     return true
end

Just change

Lua:
if getPlayerStorageValue(cid, storage) == -1 then

Where is -1, change to storage value you want(like 1, 2, 3...)


storage you want to check the value:
Lua:
local storage = 396122
 
Good evening, how to make it possible to use a certain item only if you have "X" storage? I have an action that gives the player a storage, but I only want it to be able to use it if it already has another storage (313722) = 1.

Lua:
local storage = 396122
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, storage) == -1 then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got a new look, open your clothes to check it out!!")
         setPlayerStorageValue(cid, storage, 1)
         doRemoveItem(item.uid, 1)
     else
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already have this appearance.")
     end
     return true
end
I think I didn't express myself well. This current script gives a storage. I want to create a validator that, for the player to use the item and have storage 391722, it already needs to have storage 347122.
 
I think I didn't express myself well. This current script gives a storage. I want to create a validator that, for the player to use the item and have storage 391722, it already needs to have storage 347122.
what item are you talking about? like a potion or equip a item?

or are you talking about something like a lever and that he can use several times or just once
 
what item are you talking about? like a potion or equip a item?

or are you talking about something like a lever and that he can use several times or just once
like a scroll, that i use one time
Post automatically merged:

like a scroll, that i use one time
i want to use a scroll in rpg, that scroll it gives me a rpg but i need to get a previuos storage to be able to use that scroll
 
like a scroll, that i use one time
Post automatically merged:


i want to use a scroll in rpg, that scroll it gives me a rpg but i need to get a previuos storage to be able to use that scroll

Lua:
local storage = 396122
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, storage) == 1 then -- here you check if the player has storage(396122) and value(1, 2, 3...)
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got a new look, open your clothes to check it out!!")
         setPlayerStorageValue(cid, storage, 2) -- keep it like this if you want the player to use it only once, or, delete this line to use it multiple times(still the player will need more than 1 item if he wants to use it more than once)
         doRemoveItem(item.uid, 1) -- this line removes the item when the player uses
     else
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already have this appearance.")
     end
     return true
end

see if that's it
 
Solution
Lua:
local storage = 396122
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, storage) == 1 then -- here you check if the player has storage(396122) and value(1, 2, 3...)
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got a new look, open your clothes to check it out!!")
         setPlayerStorageValue(cid, storage, 2) -- keep it like this if you want the player to use it only once, or, delete this line to use it multiple times(still the player will need more than 1 item if he wants to use it more than once)
         doRemoveItem(item.uid, 1) -- this line removes the item when the player uses
     else
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already have this appearance.")
     end
     return true
end

see if that's it
Done like this, works. Thank you! Just a improvement, i want if player already have "storagemount = 1" its not possible to use more than once. I put like u said in setPlayerStorageValue, but its using many times.

Lua:
local storagedefault = 313722
local storagemount = 396122
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, storagedefault) == 1 then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got a new look, open your clothes to check it out!!")
         setPlayerStorageValue(cid, storagemount, 2)
         doRemoveItem(item.uid, 1)
     else
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to get first clothes first.")
     end
     return true
end
Post automatically merged:

Done like this, works. Thank you! Just a improvement, i want if player already have "storagemount = 1" its not possible to use more than once. I put like u said in setPlayerStorageValue, but its using many times.

Lua:
local storagedefault = 313722
local storagemount = 396122
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, storagedefault) == 1 then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got a new look, open your clothes to check it out!!")
         setPlayerStorageValue(cid, storagemount, 2)
         doRemoveItem(item.uid, 1)
     else
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to get first clothes first.")
     end
     return true
end
Got it!

Lua:
local storagedefault = 313722
local storagemount = 396122
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, storagemount) == 1 then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already mounted.")
    else
     if getPlayerStorageValue(cid, storagedefault) == 1 then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got a new look, open your clothes to check it out!!")
         setPlayerStorageValue(cid, storagemount, 1)
         doRemoveItem(item.uid, 1)
     else
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must have the first appearance.")
        end
     end
     return true
end
 
Last edited:
Back
Top