God Mythera
Veteran OT User
Hello and i am here to request a script, lets say you use a box and you get tools like shovel, rope, scythe, ect. and when you use the box the box is removed and adds the item tools ^^
local itemArray = {2554, 2120, 2550}
function onUse(player, item, fromPosition, target, toPosition)
for _,items in ipairs(itemArray) do
player:addItem(items, 1)
end
player:sendTextMessage(MESSAGE_INFO_DESCR, "You recieved some shit.")
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
item:remove()
return true
end
love halfawy<3This is one way you can do it:
So simple..Code:local itemArray = {2554, 2120, 2550} function onUse(player, item, fromPosition, target, toPosition) for _,items in ipairs(itemArray) do player:addItem(items, 1) end player:sendTextMessage(MESSAGE_INFO_DESCR, "You recieved some shit.") player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW) item:remove() return true end
why not for #itemArray instead of ipairs? the table does have any pairs so not really any point using ipairs/pairsThis is one way you can do it:
So simple..Code:local itemArray = {2554, 2120, 2550} function onUse(player, item, fromPosition, target, toPosition) for _,items in ipairs(itemArray) do player:addItem(items, 1) end player:sendTextMessage(MESSAGE_INFO_DESCR, "You recieved some shit.") player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW) item:remove() return true end
We can do this in several ways, which do not matter in this simple script either.why not for #itemArray instead of ipairs? the table does have any pairs so not really any point using ipairs/pairs
i see ur new to Otland. Welcome to Otland. have a nice stayBe
A
Happy
Tibian.
Yours,
Penetrator.
ipairs is in this case just fine as we have a generic indexed system for the keys but on a bigger term I agree that performence wise #itemArray is better.why not for #itemArray instead of ipairs? the table does have any pairs so not really any point using ipairs/pairs
Since there is a script now.. here's how you can add multiple items to a script, if you don't know how tables or loops workSorry haha i am using tfs 1.2
Any way to make it so it gives like 3-4 items at one time? =) and i am not a troll i am just trying to find useful scripts to help my players get tools like (shovel, rope, scythe, pick) and today i have reached record of 20 online![]()
function onUse(player, item, fromPosition, target, toPosition)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
player:addItem(item_id_here, item_count_here)
item:remove()
return true
end
I think i would rather learn how tables and loops work than write scripts like this.Since there is a script now.. here's how you can add multiple items to a script, if you don't know how tables or loops work
Code:function onUse(player, item, fromPosition, target, toPosition) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) player:addItem(item_id_here, item_count_here) item:remove() return true end