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

Lua Need Help whit 2 to 1 script! (rep ofc)

Teddy

SweStream.se
Joined
Oct 2, 2008
Messages
3,797
Reaction score
10
Location
Sweden 172
Hello guys/girls :D
i need some help whit a new script over here ..
i need a script when
you set a item on ITEM1 zone and ITEM2 zone and pull the switch you get a new item and the other item disappear ..

IMG :
sr1jy5.png

ofc i give rep


---
EDIT :
anyone have it ? i cant get it work ..
No errors in console ..
actions.xml
Code:
<action uniqueid="9494" script="poiquest.lua" />
poiquest.lua
Code:
local items = { remove1 = 2217, remove2 = 2137, newItem = 2217 }
local positions =
{
    [1] = {place = {x=212, y=669, z=7}}, -- Second Item Position
    [2] = {place = {x=214, y=669, z=7}} -- Second Item Position
}

local place1 = getThingfromPos(positions[1].place)
local place2 = getThingfromPos(positions[2].place)

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (item.itemid == 1945) and (item.uid == 9494) then
        if (place1 == items.remove1) and (place1 == items.remove2) then
            doRemoveItem(place1.uid, 1)
            doRemoveItem(place2.uid, 1)
            doPlayerAddItem(cid, items.newItem, 1)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "New Item Added!")
        else
            doPlayerSendCancel(cid, "You must have the items on the correct spot.")
        end
    elseif (item.itemid == 1946) then
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
        doTransformItem(item.uid, item.itemid-1)
    end
    return TRUE
end
7wzjy7.png
 
Last edited:
Should Work

Lua:
local items = 
{ 
    remove1 = XXXX, -- First Item
    remove2 = XXXX, -- Second Item
    newItem = XXXX -- New Item
}

local positions =
{
    pos_1 = {x=100, y=100, z=7, stackpos=1}, -- First Item Position
    pos_2 = {x=100, y=100, z=7, stackpos=1}, -- Second Item Position
    pos_3 = {x=100, y=100, z=7} -- Lever Position
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local get1 = getThingfromPos(positions.pos_1)
local get2 = getThingfromPos(positions.pos_2)
    if item.itemid == 1945 and (item.uid == 5000) then
	if (get1.itemid == items.remove1) and (get2.itemid == items.remove2) or (get1.itemid == items.remove2) and (get2.itemid == items.remove1) then
            doRemoveItem(get1.uid, 1) 
            doRemoveItem(get2.uid, 1)
            doPlayerAddItem(cid, items.newItem, 1)
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
        else
            doPlayerSendCancel(cid, "You must place the items on the two spots.")
        end
    elseif item.itemid == 1946 then
        doTransformItem(item.uid,item.itemid-1)
        doSendMagicEffect(positions.pos_3, CONST_ME_POFF)
    end
    return TRUE
end
 
Last edited:
Lua:
local items = 
{ 
    remove1 = XXXX, -- First Item
    remove2 = XXXX, -- Second Item
    newItem = XXXX -- New Item
}

local positions =
{
    pos_1 = {x=100, y=100, z=7, stackpos=1}, -- First Item Position
    pos_2 = {x=100, y=100, z=7, stackpos=1}, -- Second Item Position
    pos_3 = {x=100, y=100, z=7} -- Lever Position
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local get1 = getThingfromPos(positions.pos_1)
local get2 = getThingfromPos(positions.pos_2)
    if item.itemid == 1945 and (item.uid == 5000) then
	if (get1.itemid == items.remove1) and (get2.itemid == items.remove2) or (get1.itemid == items.remove2) and (get2.itemid == items.remove1) then
            doRemoveItem(get1.uid, 1) 
            doRemoveItem(get2.uid, 1)
            doPlayerAddItem(cid, items.newItem, 1)
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
        else
            doPlayerSendCancel(cid, "You must place the items on the two spots.")
        end
    elseif item.itemid == 1946 then
        doTransformItem(item.uid,item.itemid-1)
        doSendMagicEffect(positions.pos_3, CONST_ME_POFF)
    end
    return TRUE
end

like i say in your pm ..
something in this script make my server crash when i dont have it its run fine :O ?
FIXED IT /Whit the crash/ but still have the same problem ..
Code:
  local items =
{
    remove1 = 2137, -- First Item
    remove2 = 2217, -- Second Item
    newItem = 10521 -- New Item
}

local positions =
{
    pos_1 = {x=212, y=669, z=7, stackpos=1}, -- First Item Position
    pos_2 = {x=214, y=669, z=7, stackpos=1}, -- Second Item Position
    pos_3 = {x=213, y=669, z=7} -- Lever Position
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local get1 = getThingfromPos(positions.pos_1)
local get2 = getThingfromPos(positions.pos_2)
    if (item.uid == 9494) and (get1.itemid == items.remove1) and (get2.itemid == items.remove2) or (get1.itemid == items.remove2) and (get2.itemid == items.remove1) then
        if item.itemid == 1945 then
            doTransformItem(item.uid,item.itemid+1)
            doSendMagicEffect(positions.pos_3, CONST_ME_POFF)
        elseif item.itemid == 1946 then
            doTransformItem(item.uid,item.itemid-1)
            doSendMagicEffect(positions.pos_3, CONST_ME_POFF)
        end
        doRemoveItem(get1.uid, 1)
        doRemoveItem(get2.uid, 1)
        doPlayerAddItem(cid, items.newItem, 1)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
    else
        doPlayerSendCancel(cid, "You must place the items on the two spots.")
    end
    return TRUE
end
 
Last edited:
That is weird, I don't know why it makes your server crash.

no.. its was not the script sry..
but i dont get it work .. ?
script right now :
Code:
  local items =
{
    remove1 = 2137, -- First Item
    remove2 = 2217, -- Second Item
    newItem = 10521 -- New Item
}

local positions =
{
    pos_1 = {x=212, y=669, z=7, stackpos=1}, -- First Item Position
    pos_2 = {x=214, y=669, z=7, stackpos=1}, -- Second Item Position
    pos_3 = {x=213, y=669, z=7} -- Lever Position
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local get1 = getThingfromPos(positions.pos_1)
local get2 = getThingfromPos(positions.pos_2)
    if (item.uid == 9494) and (get1.itemid == items.remove1) and (get2.itemid == items.remove2) or (get1.itemid == items.remove2) and (get2.itemid == items.remove1) then
        if item.itemid == 1945 then
            doTransformItem(item.uid,item.itemid+1)
            doSendMagicEffect(positions.pos_3, CONST_ME_POFF)
        elseif item.itemid == 1946 then
            doTransformItem(item.uid,item.itemid-1)
            doSendMagicEffect(positions.pos_3, CONST_ME_POFF)
        end
        doRemoveItem(get1.uid, 1)
        doRemoveItem(get2.uid, 1)
        doPlayerAddItem(cid, items.newItem, 1)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
    else
        doPlayerSendCancel(cid, "You must place the items on the two spots.")
    end
    return TRUE
end
 
Back
Top