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

Creating a campfire

  • Thread starter Thread starter tejdi
  • Start date Start date
T

tejdi

Guest
Hello i need script:
If player is using 5 woods (ItemID: [5901]) which are on the campfire (ItemID: [1422]) + Position: [X: 1119] [Y: 1028] [Z: 7] then campfire will transform from ID: 1422 to 1423.
Rep for help!
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
     local tile = Tile(Position(1119, 1028, 7))
     local thing, wood = pushThing(tile:getItemById(1422)).uid, pushThing(tile:getItemById(5901, 5)).uid
     if pushThing(Tile(toPosition):getItemById(1422)).uid > 0 and thing > 0 then
         if wood > 0 then
             Item(wood):remove()
             Item(thing):transform(1423)
         else
             Player(cid):sendCancelMessage("You need to place 5 wood to create a campfire.")
         end
     end
     return true
end
 
Last edited:
Thanks @Limos !
My script's looking:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
     local tile = Tile(Position(1119, 1028, 7))
     local thing, wood = pushThing(tile:getItemById(1422)).uid, pushThing(tile:getItemById(5901, 5)).uid
     if pushThing(Tile(toPosition):getItemById(1422)).uid > 0 and thing > 0 then
         if wood > 0 then
             Item(wood):remove()
             Item(thing):transform(1423)
            Position(tile):sendMagicEffect(CONST_ME_MAGIC_RED)
            setPlayerStorageValue(cid, 3001,7)
            Position(cid):sendMagicEffect(CONST_ME_MAGIC_RED)
         else
             Player(cid):sendCancelMessage("You need to place 5 wood to create a campfire.")
         end
     end
     return true
end

Can we add this?:
After 5 minutes campfire [1423] will transform to [1422] again?
Sorry but i'm new in TFS 1.0 and it's really other than 4.0 :P
 
Code:
local function revertItem(position, itemId, transformId)
    local item = Tile(position):getItemById(itemId)
    if item then
        item:transform(transformId)
    end
end

addEvent(revertItem, 5 * 60 * 1000, position, itemId, transformId)
 
Error [It's my fault i think]:
edPyRXS.jpg
 
Code:
local campfirePosition = Position(1119, 1028, 7)

local function revertItem()
    local item = Tile(campfirePosition):getItemById(1423)
    if item then
        item:transform(1422)
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    if item.itemid ~= 1422 then
        return true
    end

    local player, tile = Player(cid), Tile(campfirePosition)
    local thing, wood = tile:getItemById(1422), tile:getItemById(5901, 5)
    if thing and wood then
        wood:remove()
        thing:transform(1423)
        campfirePosition:sendMagicEffect(CONST_ME_MAGIC_RED)
        player:setStorageValue(3001, 7)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
        addEvent(revertItem, 5 * 60 * 1000)
    else
        player:sendCancelMessage("You need to place 5 wood to create a campfire.")
    end
    return true
end
 
Code:
local function revertItem(position, itemId, transformId)
    local item = Tile(position):getItemById(itemId)
    if item then
        item:transform(transformId)
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    if toPosition.x == CONTAINER_POSITION then
        return false
    end

    local tile = Tile(toPosition)
    local campfire = tile:getItemById(1422)
    if not campfire then
        return false
    end

    local wood = tile:getItemById(5901, 5)
    if not wood then
        Player(cid):sendCancelMessage("You need to place 5 wood to create a campfire.")
        return true
    end

    wood:remove()
    campfire:transform(1423)
    toPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
    addEvent(revertItem, 5 * 60 * 1000, toPosition, 1423, 1422)

    local player = Player(cid)
    player:setStorageValue(3001, 7)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
    return true
end
 
Back
Top