God Mythera
Veteran OT User
Hello and im here to request a script for a chest to give a reward of the same item but 1 time in each chest, does anyone have a script for it?
TFS 0.4Can you explain that a bit better.. and what tfs?
I still don't understand.TFS 0.4
I simply wanna make a chest give the item in another chest but only once per chest on 1 character
I still don't understand.
What do you mean by item in another chest?
Multiple chests that give the same item?
Hello and im here to request a script for a chest to give a reward of the same item but 1 time in each chest, does anyone have a script for it?
<action actionid="45000" event="script" value="Xikini_easy_chests.lua"/>
local config = {
[1] = { uid = 45001, item = 8982, amount = 1},
[2] = { uid = 45002, item = 8982, amount = 1},
[3] = { uid = 45003, item = 8982, amount = 1},
[4] = { uid = 45004, item = 8982, amount = 1}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
for i = 1, #config do
if config[i].uid == item.uid then
if getPlayerStorageValue(cid, config[i].uid) < 1 then
if getPlayerFreeCap(cid) >= getItemWeightById(config[i].item, config[i].amount) then
local item = doCreateItemEx(config[i].item, config[i].amount)
if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "You require free inventory space to obtain this reward.")
else
doPlayerSendCancel(cid, "You have received ".. config[i].amount .." ".. config[i].item ..".")
setPlayerStorageValue(cid, config[i].uid, 1)
end
else
doPlayerSendCancel(cid, "You require ".. getItemWeightById(config[i].item, config[i].amount) .." capacity to obtain this reward.")
end
else
doPlayerSendCancel(cid, "You have already obtained this reward.")
end
break
end
end
return true
end
one small itsy bitsy problem, when i use the chest it says "You have found 1 8982." XD other then that it works amazing ^.^Had trouble checking if player had free inventory space or not. >.>
Anyways all fixed and ready to go.
@Codex NG Is there a better way I could make this, so there isn't 4 if statements in a row?
For the record.. you can use any item in the game.. you don't have to explicitly use a chest.
![]()
Code:<action actionid="45000" event="script" value="Xikini_easy_chests.lua"/>Code:local config = { [1] = { uid = 45001, item = 8982, amount = 1}, [2] = { uid = 45002, item = 8982, amount = 1}, [3] = { uid = 45003, item = 8982, amount = 1}, [4] = { uid = 45004, item = 8982, amount = 1} } function onUse(cid, item, fromPosition, itemEx, toPosition) for i = 1, #config do if config[i].uid == item.uid then if getPlayerStorageValue(cid, config[i].uid) < 1 then if getPlayerFreeCap(cid) >= getItemWeightById(config[i].item, config[i].amount) then local item = doCreateItemEx(config[i].item, config[i].amount) if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) doPlayerSendCancel(cid, "You require free inventory space to obtain this reward.") else doPlayerSendCancel(cid, "You have received ".. config[i].amount .." ".. config[i].item ..".") setPlayerStorageValue(cid, config[i].uid, 1) end else doPlayerSendCancel(cid, "You require ".. getItemWeightById(config[i].item, config[i].amount) .." capacity to obtain this reward.") end else doPlayerSendCancel(cid, "You have already obtained this reward.") end break end end return true end
Oh.one small itsy bitsy problem, when i use the chest it says "You have found 1 8982." XD other then that it works amazing ^.^
local config = {
[1] = { uid = 45001, item = 2152, amount = 1},
[2] = { uid = 45002, item = 2152, amount = 1},
[3] = { uid = 45003, item = 2152, amount = 1},
[4] = { uid = 45004, item = 2152, amount = 1}
}
local exstorage = 45000
function onUse(cid, item, fromPosition, itemEx, toPosition)
if exhaustion.check(cid, exstorage) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "You are exhausted.")
return true
end
exhaustion.set(cid, exstorage, 2)
for i = 1, #config do
if config[i].uid == item.uid then
if getPlayerStorageValue(cid, config[i].uid) < 1 then
if getPlayerFreeCap(cid) >= getItemWeightById(config[i].item, config[i].amount) then
local item = doCreateItemEx(config[i].item, config[i].amount)
if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "You require free inventory space to obtain this reward.")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found ".. config[i].amount .." ".. getItemNameById(config[i].item) ..".")
setPlayerStorageValue(cid, config[i].uid, 1)
end
else
doPlayerSendCancel(cid, "You require ".. getItemWeightById(config[i].item, config[i].amount) .." capacity to obtain this reward.")
end
else
doPlayerSendCancel(cid, "You have already obtained this reward.")
end
break
end
end
return true
end
:SSOh.
Here's an updated chest.
Fixed the itsy bitsy problem, and also added in a small exhaust so players don't spam the chest and possibly get extra rewards.
Just a failsafe.-- Quick note, gods do not get exhausted, so if your testing the exhaust, try on a normal character.
Code:local config = { [1] = { uid = 45001, item = 2152, amount = 1}, [2] = { uid = 45002, item = 2152, amount = 1}, [3] = { uid = 45003, item = 2152, amount = 1}, [4] = { uid = 45004, item = 2152, amount = 1} } local exstorage = 45000 function onUse(cid, item, fromPosition, itemEx, toPosition) if exhaustion.check(cid, exstorage) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) doPlayerSendCancel(cid, "You are exhausted.") return true end exhaustion.set(cid, exstorage, time) for i = 1, #config do if config[i].uid == item.uid then if getPlayerStorageValue(cid, config[i].uid) < 1 then if getPlayerFreeCap(cid) >= getItemWeightById(config[i].item, config[i].amount) then local item = doCreateItemEx(config[i].item, config[i].amount) if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) doPlayerSendCancel(cid, "You require free inventory space to obtain this reward.") else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found ".. config[i].amount .." ".. getItemNameById(config[i].item) ..".") setPlayerStorageValue(cid, config[i].uid, 1) end else doPlayerSendCancel(cid, "You require ".. getItemWeightById(config[i].item, config[i].amount) .." capacity to obtain this reward.") end else doPlayerSendCancel(cid, "You have already obtained this reward.") end break end end return true end
[18/02/2016 02:54:19] [Error - Action Interface]
[18/02/2016 02:54:19] data/actions/scripts/Xikini_easy_chests.lua:onUse
[18/02/2016 02:54:19] Description:
[18/02/2016 02:54:19] data/lib/034-exhaustion.lua:28: attempt to perform arithmetic on local 'time' (a nil value)
[18/02/2016 02:54:19] stack traceback:
[18/02/2016 02:54:19] data/lib/034-exhaustion.lua:28: in function 'set'
[18/02/2016 02:54:19] data/actions/scripts/Xikini_easy_chests.lua:15: in function <data/actions/scripts/Xikini_easy_chests.lua:9>
local config = {
[1] = { uid = 45001, item = 8982, amount = 1},
[2] = { uid = 45002, item = 8982, amount = 1},
[3] = { uid = 45003, item = 8982, amount = 1},
[4] = { uid = 45004, item = 8982, amount = 1}
}
local exstorage = 45000
function onUse(cid, item, fromPosition, itemEx, toPosition)
if exhaustion.check(cid, exstorage) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "You are exhausted.")
return true
end
exhaustion.set(cid, exstorage, time)
for i = 1, #config do
if config[i].uid == item.uid then
if getPlayerStorageValue(cid, config[i].uid) < 1 then
if getPlayerFreeCap(cid) >= getItemWeightById(config[i].item, config[i].amount) then
local item = doCreateItemEx(config[i].item, config[i].amount)
if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "You require free inventory space to obtain this reward.")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found ".. config[i].amount .." ".. getItemNameById(config[i].item) ..".")
setPlayerStorageValue(cid, config[i].uid, 1)
end
else
doPlayerSendCancel(cid, "You require ".. getItemWeightById(config[i].item, config[i].amount) .." capacity to obtain this reward.")
end
else
doPlayerSendCancel(cid, "You have already obtained this reward.")
end
break
end
end
return true
end
oh, thanks alot ^^derp. check up and copy again.
Was my derp, not yours. No worries.oh, thanks alot ^^