• 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 Use one item per place

hasbro

Member
Joined
Feb 15, 2009
Messages
287
Reaction score
6
Hey, i have doubt in one thing, i have item id 15465 and this item have in some places and player need use 8 of this items but he cant use it same item ... he need go to other place and use again ..Can someone help me?
 
If the item is added in the map on certain places and shouldn't be removed, you can add an uniqueid to it, then set the storage to that uniqueid.
Lua:
local storage = item.uid
If the item is something people get with a quest for example, you can set the same storage number but every item 1 extra value and remove the item after using.
 
Yes, i try do that but i found one problem..Each item i will need add different storage and i need only 1 storage to all item each item you use you gain +1 storage..
 
You can do both, storage with item.uid to check if someone already used the item, then add different storage with +1 value, so if you used all items, the value of that second storage will be 7 (or 8 if you set it to 0).
 
Like that?
Lua:
local table = {
[] = {storage = 1}
}
for k,v in pairs do
if item.uid == k then
if getPlayerStorageValue(cid,77878) <= 8 then
setPlayerStorageValue(cid, v.storage, getPlayerStorageValue(cid,v.storage) + 1)
doSendMagicEffect(toPosition,31)
end
end
end
 
You don't need to use a table or anything, you can just check for the item.uid as storage to see if someone already used the item.
Lua:
if(getPlayerStorageValue(cid, item.uid) > 0) then
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You already used this item.")
	return true
end
Then under it add what it should do and set the storages.
Lua:
setPlayerStorageValue(cid, item.uid, 1)
setPlayerStorageValue(cid, 9566, getPlayerStorageValue(cid, 9566) + 1)
 
Thanks limos, work fine..

- - - Updated - - -

Limos, other doubt to restore this storage to -1 , i can use isinarray? ou setPlayerStorageValue(cid,item.uid , -1) in the npc?
 
If you want an npc to check if someone used all items, you only have to use the second storage.
Lua:
if(getPlayerStorageValue(cid, 9566) >= 7) then
 
You can do it like this, use the uniqueids of the items in the storages table.
Lua:
local storages = {10922, 10923, 10924}
for _, storage in pairs(storages) do
	setPlayerStorageValue(cid, storage, -1)
end
 
Back
Top