<action actionid="6216" event="script" value="twochest.lua"/>
<action actionid="6215" event="script" value="twochest2.lua"/>
local storage = 4918410
local reward = 6433
local count = 1
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 1740 or item.itemid == 1747 or item.itemid == 1748 or item.itemid == 1749 then
if getPlayerStorageValue(cid, storage) == -1 then
doPlayerAddItem(cid, reward, count)
setPlayerStorageValue(cid, storage, 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a Necromancer Shield!")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty. You've already chosed your reward.")
return true
end
end
end
local storage = 4918410
local reward = 6391
local count = 1
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 1740 or item.itemid == 1747 or item.itemid == 1748 or item.itemid == 1749 then
if getPlayerStorageValue(cid, storage) == -1 then
doPlayerAddItem(cid, reward, count)
setPlayerStorageValue(cid, storage, 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a Nightmare Shield!")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty. You've already chosed your reward.")
return true
end
end
end
Do like this:
Place two chests next to each other and when the player opens a chest, the player gets a storagevalue for the both chests, so he can't open the chest again...
action.xml:
XML:<action actionid="6216" event="script" value="twochest.lua"/> <action actionid="6215" event="script" value="twochest2.lua"/>
twochest.lua:
LUA:local storage = 4918410 local reward = 6433 local count = 1 function onUse(cid, item, fromPosition, itemEx, toPosition) if item.itemid == 1740 or item.itemid == 1747 or item.itemid == 1748 or item.itemid == 1749 then if getPlayerStorageValue(cid, storage) == -1 then doPlayerAddItem(cid, reward, count) setPlayerStorageValue(cid, storage, 1) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a Necromancer Shield!") else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty. You've already chosed your reward.") return true end end end
twochest2.lua:
LUA:local storage = 4918410 local reward = 6391 local count = 1 function onUse(cid, item, fromPosition, itemEx, toPosition) if item.itemid == 1740 or item.itemid == 1747 or item.itemid == 1748 or item.itemid == 1749 then if getPlayerStorageValue(cid, storage) == -1 then doPlayerAddItem(cid, reward, count) setPlayerStorageValue(cid, storage, 1) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a Nightmare Shield!") else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty. You've already chosed your reward.") return true end end end
local t = {
[15001] = {6433, 1},
[15002] = {6391, 1}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[item.actionid]
if v then
if getCreatureStorage(cid, v) < 0 then
doCreatureSetStorage(cid, v, 1)
local reward = doCreateItemEx(v[1], v[2] or 1)
if(doPlayerAddItemEx(cid, reward, true) ~= RETURNVALUE_NOERROR) then
return false
end
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
doCreatureSay(cid, "You have found a " .. getItemInfo(v[1]).name .. "!")
else
doPlayerSendCancel(cid, "The " .. getItemInfo(item.uid).name .. " is empty.")
end
end
return true
end
<action actionid="6501" event="script" value="startingweapon1.lua"/>
function onUse(cid, item, frompos, item2, topos)
local config = {
[7001] = {loot=2160},
[7002] = {loot=2161},
[7003] = {loot=2162}
--etc
}
local storage = 0001 -- the quest storage
local cap = getPlayerFreeCap(cid)
local reward = config[item.uid].item
if reward then
if cap < (getItemWeight(always,1) + getItemWeight(reward,1)) then
if getPlayerStorageValue(cid,storage) == -1 then
doPlayerAddItem(cid,reward,1)
doPlayerSendTextMessage(cid,22,"You've obtained a " ..getItemNameById(reward)"!")
else
doPlayerSendCancel(cid, "The Chest is Empty!")
end
else
doPlayerSendCancel(cid, "You do not have enough cap!")
end
end
return true
end
Lfmao... you don't need this script ^^Do like this:
Place two chests next to each other and when the player opens a chest, the player gets a storagevalue for the both chests, so he can't open the chest again...
action.xml:
XML:<action actionid="6216" event="script" value="twochest.lua"/> <action actionid="6215" event="script" value="twochest2.lua"/>
twochest.lua:
LUA:local storage = 4918410 local reward = 6433 local count = 1 function onUse(cid, item, fromPosition, itemEx, toPosition) if item.itemid == 1740 or item.itemid == 1747 or item.itemid == 1748 or item.itemid == 1749 then if getPlayerStorageValue(cid, storage) == -1 then doPlayerAddItem(cid, reward, count) setPlayerStorageValue(cid, storage, 1) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a Necromancer Shield!") else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty. You've already chosed your reward.") return true end end end
twochest2.lua:
LUA:local storage = 4918410 local reward = 6391 local count = 1 function onUse(cid, item, fromPosition, itemEx, toPosition) if item.itemid == 1740 or item.itemid == 1747 or item.itemid == 1748 or item.itemid == 1749 then if getPlayerStorageValue(cid, storage) == -1 then doPlayerAddItem(cid, reward, count) setPlayerStorageValue(cid, storage, 1) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a Nightmare Shield!") else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty. You've already chosed your reward.") return true end end end