• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Quest script

tfs..? broken script..? ids of items..? any related scripts (ex: quest storages)..?
We want to help, but you have to help us help you.
tfs 0.3.6. -- untested. haven't been scripting for awhile.
Code:
local items = {
   [1] = {itemID = 1111, amount = 1},
   [2] = {itemID = 1111, amount = 1},
   [3] = {itemID = 1111, amount = 1}
}

function onUse(cid, item, frompos, item2, topos)
   for i = 1, #items do
     doPlayerAddItem(cid, items[i].itemID, items[i].amount)
   end
   return true
end
-- edit
This may be helpful to add in as well.
Code:
if getPlayerStorageValue(cid, 11111) == 1 then
   return doPlayerSendTextMessage(cid, 22, "This chest is empty.")
end
setPlayerStorageValue(cid, 11111, 1)
 
Last edited by a moderator:
I think you do not understand me, but ultimately could fix my script?

Loading actions... [Error - LuaInterface::loadFile] data/actions/scripts/freeset1.lua:3: 'end' expected (to close 'function' at line 1) near 'elseif'
[7/1/2016 18:27:20] [Error - Event::checkScript] Cannot load script (data/actions/scripts/freeset1.lua)
[7/1/2016 18:27:20] data/actions/scripts/freeset1.lua:3: 'end' expected (to close 'function' at line 1) near 'elseif'
[7/1/2016 18:27:26] (done).




function onUse(cid, item, frompos, item2, topos)

elseif item.uid == 1881 then
ids = {2501, 2503, 2504}
charges = {1, 1, 1, 1}
if getPlayerStorageValue(cid,1881) == -1 then
setPlayerStorageValue(cid,1881,1)
bp = doPlayerAddItem(cid, 2365, 1)
for i = 1, #ids do
doAddContainerItem(bp, ids, charges)
end
else
doPlayerSendTextMessage(cid,25,"It is empty.")
end

elseif item.uid == 1882 then
ids = {7902, 7897, 7896}
charges = {1, 1, 1, 1}
if getPlayerStorageValue(cid,1882) == -1 then
setPlayerStorageValue(cid,1882,1)
bp = doPlayerAddItem(cid, 2365, 1)
for i = 1, #ids do
doAddContainerItem(bp, ids, charges)
end
else
doPlayerSendTextMessage(cid,25,"It is empty.")
end


end
return TRUE
end
 
I think you do not understand me, but ultimately could fix my script?

Loading actions... [Error - LuaInterface::loadFile] data/actions/scripts/freeset1.lua:3: 'end' expected (to close 'function' at line 1) near 'elseif'
[7/1/2016 18:27:20] [Error - Event::checkScript] Cannot load script (data/actions/scripts/freeset1.lua)
[7/1/2016 18:27:20] data/actions/scripts/freeset1.lua:3: 'end' expected (to close 'function' at line 1) near 'elseif'
[7/1/2016 18:27:26] (done).




function onUse(cid, item, frompos, item2, topos)

elseif item.uid == 1881 then
ids = {2501, 2503, 2504}
charges = {1, 1, 1, 1}
if getPlayerStorageValue(cid,1881) == -1 then
setPlayerStorageValue(cid,1881,1)
bp = doPlayerAddItem(cid, 2365, 1)
for i = 1, #ids do
doAddContainerItem(bp, ids, charges)
end
else
doPlayerSendTextMessage(cid,25,"It is empty.")
end

elseif item.uid == 1882 then
ids = {7902, 7897, 7896}
charges = {1, 1, 1, 1}
if getPlayerStorageValue(cid,1882) == -1 then
setPlayerStorageValue(cid,1882,1)
bp = doPlayerAddItem(cid, 2365, 1)
for i = 1, #ids do
doAddContainerItem(bp, ids, charges)
end
else
doPlayerSendTextMessage(cid,25,"It is empty.")
end


end
return TRUE
end
[.code]use code tags please.[./code]

Try this.
Code:
function onUse(cid, item, frompos, item2, topos)

   if item.uid == 1881 then
     ids = {2501, 2503, 2504}
     amount = {1, 1, 1}
     if getPlayerStorageValue(cid, 1881) == -1 then
       setPlayerStorageValue(cid, 1881, 1)
       bp = doPlayerAddItem(cid, 2365, 1)
       for i = 1, #ids do
         doAddContainerItem(bp, ids, amount)
       end
     else
       return doPlayerSendTextMessage(cid, 25, "It is empty.")
     end

   elseif item.uid == 1882 then
     ids = {7902, 7897, 7896}
     amount = {1, 1, 1}
     if getPlayerStorageValue(cid, 1882) == -1 then
       setPlayerStorageValue(cid, 1882, 1)
       bp = doPlayerAddItem(cid, 2365, 1)
       for i = 1, #ids do
         doAddContainerItem(bp, ids, amount)
       end
     else
       return doPlayerSendTextMessage(cid, 25, "It is empty.")
     end

   end

   return true
end
 
Back
Top