• 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!

[Request] Use item get xxx items

God Mythera

Veteran OT User
Joined
Aug 11, 2012
Messages
2,051
Solutions
2
Reaction score
260
Location
United States
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 ^^
 
This is one way you can do it:
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
So simple..
 
This is one way you can do it:
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
So simple..
love halfawy<3
 
This is one way you can do it:
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
So simple..
why not for #itemArray instead of ipairs? the table does have any pairs so not really any point using ipairs/pairs
 
why not for #itemArray instead of ipairs? the table does have any pairs so not really any point using ipairs/pairs
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.
 
Sorry haha i am using tfs 1.2 :p


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 :D
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
 
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
I think i would rather learn how tables and loops work than write scripts like this. :confused:
 
Back
Top