• 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:
Here is a script..

This one will remove 2 payment items, and add another item to your backpack... this "switch" can be used several times by same player = This is not a one time quest/player

Code:
function onUse(cid, item, frompos, item2, topos)
getpos1 = {x=000, y=000, z=00, stackpos=1}
payment1 = getThingfromPos(getpos1)

getpos2 = {x=000, y=000, z=00, stackpos=1}
payment2 = getThingfromPos(getpos2)



if item.uid == 000 and item.itemid == 1945 and payment1.itemid == 000 and payment2.itemid == 000 then
doRemoveItem(item1.uid,1)
doRemoveItem(iten2.uid,1)
doTransformItem(item.uid,item.itemid+1)
doPlayerAddItem(cid,000,1)
elseif item.uid == 000 and item.itemid == 1946 then
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry not possible.")
end
  return 1
  end

Hope it will work, didn't test it..

post here if there is something that seems to not work..


Sincerely!
 
Here is a script..

This one will remove 2 payment items, and add another item to your backpack... this "switch" can be used several times by same player = This is not a one time quest/player

Code:
function onUse(cid, item, frompos, item2, topos)
getpos1 = {x=000, y=000, z=00, stackpos=1}
payment1 = getThingfromPos(getpos1)

getpos2 = {x=000, y=000, z=00, stackpos=1}
payment2 = getThingfromPos(getpos2)



if item.uid == 000 and item.itemid == 1945 and payment1.itemid == 000 and payment2.itemid == 000 then
doRemoveItem(item1.uid,1)
doRemoveItem(iten2.uid,1)
doTransformItem(item.uid,item.itemid+1)
doPlayerAddItem(cid,000,1)
elseif item.uid == 000 and item.itemid == 1946 then
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry not possible.")
end
  return 1
  end

Hope it will work, didn't test it..

post here if there is something that seems to not work..


Sincerely!

what should i add in actions.xml (A) ?
and where can i put the ID for item1 and item2 ?
 
put the script in a text file in
Data/Actions/Scripts.

and in Data/Actions/Actions.xml you add this:
Code:
<action uniqueid="000" script="[COLOR="Red"]put name of text file.lua[/COLOR]" />
 
put the script in a text file in
Data/Actions/Scripts.

and in Data/Actions/Actions.xml you add this:
Code:
<action uniqueid="000" script="[COLOR="Red"]put name of text file.lua[/COLOR]" />

O: iam a really noob where can i change the itemID for item1 and item2 then ? and switch id ?
 
Code:
function onUse(cid, item, frompos, item2, topos)
getpos1 = {x=[COLOR="Red"][B][U]000[/U][/B][/COLOR], y=[COLOR="Red"][B][U]000[/U][/B][/COLOR], z=[COLOR="Red"][B][U]00[/U][/B][/COLOR], stackpos=1}
payment1 = getThingfromPos(getpos1)

getpos2 = {x=[COLOR="Red"][B][U]000[/U][/B][/COLOR], y=[COLOR="Red"][B][U]000[/U][/B][/COLOR], z=[COLOR="Red"][B][U]00[/U][/B][/COLOR], stackpos=1}
payment2 = getThingfromPos(getpos2)


if item.uid == [COLOR="Indigo"][B][U][B][U]000[/U][/B][/U][/B][/COLOR] and item.itemid == 1945 and payment1.itemid == [COLOR="Blue"][B][U]000[/U] [/B][/COLOR]and payment2.itemid == [COLOR="Blue"][B][U]000[/U][/B][/COLOR] then
doRemoveItem(item1.uid,1)
doRemoveItem(iten2.uid,1)
doTransformItem(item.uid,item.itemid+1)
doPlayerAddItem(cid,000,1)
elseif item.uid == [COLOR="Indigo"][B][U]000[/U][/B][/COLOR] and item.itemid == 1946 then
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry not possible.")
end
  return 1
  end

Red Colour -Position of items

Blue Colour -Id of items

Purple Colour -Unid of Switch
 
Code:
function onUse(cid, item, frompos, item2, topos)
getpos1 = {x=[COLOR="Red"][B][U]000[/U][/B][/COLOR], y=[COLOR="Red"][B][U]000[/U][/B][/COLOR], z=[COLOR="Red"][B][U]00[/U][/B][/COLOR], stackpos=1}
payment1 = getThingfromPos(getpos1)

getpos2 = {x=[COLOR="Red"][B][U]000[/U][/B][/COLOR], y=[COLOR="Red"][B][U]000[/U][/B][/COLOR], z=[COLOR="Red"][B][U]00[/U][/B][/COLOR], stackpos=1}
payment2 = getThingfromPos(getpos2)


if item.uid == [COLOR="Indigo"][B][U][B][U]000[/U][/B][/U][/B][/COLOR] and item.itemid == 1945 and payment1.itemid == [COLOR="Blue"][B][U]000[/U] [/B][/COLOR]and payment2.itemid == [COLOR="Blue"][B][U]000[/U][/B][/COLOR] then
doRemoveItem(item1.uid,1)
doRemoveItem(iten2.uid,1)
doTransformItem(item.uid,item.itemid+1)
doPlayerAddItem(cid,000,1)
elseif item.uid == [COLOR="Indigo"][B][U]000[/U][/B][/COLOR] and item.itemid == 1946 then
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry not possible.")
end
  return 1
  end

Red Colour -Position of items

Blue Colour -Id of items

Purple Colour -Unid of Switch
EDIT:
where can i set the new item ID then ?

doPlayerAddItem(cid,000,1)

right ?
 
None of this work
..
script 1 i dont get any error in console but its dont work ?

script 2 i get this error in console
[15/08/2009 15:58:50] Lua Script Error: [Action Interface]
[15/08/2009 15:58:50] data/actions/scripts/poiquest.lua:eek:nUse

[15/08/2009 15:58:50] luaDoPlayerSendCancel(). Player not found
 
16:01 You see a switch.
ItemID: [1945], UniqueID: [6464].
Position: [X: 213] [Y: 669] [Z: 7].
16:01 You see a Big Poi.
It weighs 3.00 oz.
Quest Item.
ItemID: [2217].
Position: [X: 214] [Y: 669] [Z: 7].
16:01 You see Mini Poi.
It weighs 3.00 oz.
Quest Item.
ItemID: [2137].
Position: [X: 212] [Y: 669] [Z: 7].
There something wrong :O ?

Edit :
New item ID : 10521
 
It should work now.
I made the message wrong.

Remember to Edit: Script.lua
PHP:
(item.uid == 5000)
 
try this:

Code:
function onUse(cid, item, frompos, item2, topos)
getpos1 = {x=000, y=000, z=00}
payment1 = getThingfromPos(getpos1)

getpos2 = {x=000, y=000, z=00}
payment2 = getThingfromPos(getpos2)



if item.uid == 000 and item.itemid == 1945 and payment1.itemid == 000 and payment2.itemid == 000 then
doRemoveItem(item1.uid,1)
doRemoveItem(iten2.uid,1)
doTransformItem(item.uid,item.itemid+1)
doPlayerAddItem(cid,000,1)
elseif item.uid == 000 and item.itemid == 1946 then
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry not possible.")
end
  return 1
  end
 
You know your self,thanks for not making me say it.
EDIT:
cant u click edit?it is that hard?:(

yes to hard ^^
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:
Back
Top