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

[tfs 0.3.6][lever creating item with specific action id]

SonGoqu

New Member
Joined
Nov 27, 2008
Messages
64
Reaction score
0
Hello,
I need a script for a lever that replace an item with another, the another item should have a special action id:

a. old item id: 12471 (this item, when I touch the lever should be replaced)
b. new item id: 11759 (this item, when it will be created should have aid=8103)

I make this script:

Code:
[COLOR="navy"]function onUse(cid, item, frompos, item2, topos)
gatepos = {x=1473, y=2656, z=8, stackpos=1}
getgate = getThingfromPos(gatepos)

if item.uid == 8103 and item.itemid == 1945 and getgate.itemid == 12471 then
doCreateItem(11759,1,gatepos)
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 8103 and item.itemid == 1946
and getgate.itemid == 11759 then
doCreateItem(12471,1,gatepos)
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry, not possible.")
end
return 1
end[/COLOR]

it works but I need the new item with aid=8103.
The second is: when I touch the lever back the item 11759 should be replaced with the normal 12471 item.


Can someone help me?
 
Code:
function onUse(cid, item, frompos, item2, topos)
gatepos = {x=1473, y=2656, z=8, stackpos=1}
getgate = getThingfromPos(gatepos)

local shitter = doCreateItem(11759,1,gatepos)
if item.uid == 8103 and item.itemid == 1945 and getgate.itemid == 12471 then
doRemoveItem(getgate.uid)
setItemSpecialAttribute(shitter.uid, aid, 8103)
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 8103 and item.itemid == 1946
and getgate.itemid == 11759 then
doRemoveItem(getgate.uid)
doCreateItem(12471,1,gatepos)
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry, not possible.")
end
return true
end

Don't get turned up tho, it probably won't work as most of my scripts made after 11 pm =D
 
Thx but:

- the items are replaced but without aid=8103
- I get this error:

Code:
[COLOR="navy"][Error - Action Interface] 
data/actions/scripts/dzwignie/dzwignia_khameiro2.lua:onUse
Description: 
data/actions/scripts/dzwignie/dzwignia_khameiro2.lua:8: attempt to index local 'shitter' (a number value)
stack traceback:
	data/actions/scripts/dzwignie/dzwignia_khameiro2.lua:8: in function <data/actions/scripts/dzwignie/dzwignia_khameiro2.lua:1>
[/COLOR]
 
Code:
function onUse(cid, item, frompos, item2, topos)
gatepos = {x=1473, y=2656, z=8, stackpos=1}
getgate = getThingfromPos(gatepos)

if item.uid == 8103 and item.itemid == 1945 and getgate.itemid == 12471 then
doRemoveItem(getgate.uid)
doCreateItem(11759,1,gatepos)
setItemSpecialAttribute(getgate.uid, aid, 8103)
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 8103 and item.itemid == 1946
and getgate.itemid == 11759 then
doRemoveItem(getgate.uid)
doCreateItem(12471,1,gatepos)
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry, not possible.")
end
return true
end

try this
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local f = item.itemid == 1945
	local a = getTileItemById({x=1473, y=2656, z=8}, f and 12471 or 11759).uid
	doTransformItem(a, f and 11759 or 12471)
	return doTransformItem(item.uid, f and 1946 or 1945) and (f and doItemSetAttribute(a, 'aid', 8103) or doItemEraseAttribute(a, 'aid'))
end
 
Code:
function onUse(cid, item, frompos, item2, topos)
gatepos = {x=1473, y=2656, z=8, stackpos=1}
getgate = getThingfromPos(gatepos)

if item.uid == 8103 and item.itemid == 1945 and getgate.itemid == 12471 then
doRemoveItem(getgate.uid)
doCreateItem(11759,1,gatepos)
setItemSpecialAttribute(getgate.uid, aid, 8103)
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 8103 and item.itemid == 1946
and getgate.itemid == 11759 then
doRemoveItem(getgate.uid)
doCreateItem(12471,1,gatepos)
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry, not possible.")
end
return true
end

try this


Then I get this error:

Code:
[COLOR="darkgreen"][Error - Action Interface] 
data/actions/scripts/dzwignie/dzwignia_khameiro2.lua:onUse
Description: 
data/actions/scripts/dzwignie/dzwignia_khameiro2.lua:8: attempt to call global 'setItemSpecialAttribute' (a nil value)
stack traceback:
	data/actions/scripts/dzwignie/dzwignia_khameiro2.lua:8: in function <data/actions/scripts/dzwignie/dzwignia_khameiro2.lua:1>
[/COLOR]

and I don't get the action ID that I need.


-------------------------------------------------------------------


Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local f = item.itemid == 1945
	local a = getTileItemById({x=1473, y=2656, z=8}, f and 12471 or 11759).uid
	doTransformItem(a, f and 11759 or 12471)
	return doTransformItem(item.uid, f and 1946 or 1945) and (f and doItemSetAttribute(a, 'aid', 8103) or doItemEraseAttribute(a, 'aid'))
end

The Action ID will be crated but the Items 11759 and 12471 don't be replaced as they should, I will show it on this pictures:

8837svzkjof1qz74czyh.png


xc8q8oupxfcz55dxuqms.png


hgo6xkv00jofryxdf3bw.png


2c6u2fcmpptt94bie2.png
 
it's fault of tfs ;p.

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local f = item.itemid == 1945
	doRemoveItem(getTileItemById({x=1473, y=2656, z=8}, f and 12471 or 11759).uid)
	local a = doCreateItem(f and 11759 or 12471, 1, {x=1473, y=2656, z=8})
	return doTransformItem(item.uid, f and 1946 or 1945) and (f and doItemSetAttribute(a, 'aid', 8103) or doItemEraseAttribute(a, 'aid'))
end
 
it's fault of tfs ;p.

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local f = item.itemid == 1945
	doRemoveItem(getTileItemById({x=1473, y=2656, z=8}, f and 12471 or 11759).uid)
	local a = doCreateItem(f and 11759 or 12471, 1, {x=1473, y=2656, z=8})
	return doTransformItem(item.uid, f and 1946 or 1945) and (f and doItemSetAttribute(a, 'aid', 8103) or doItemEraseAttribute(a, 'aid'))
end

Thank You it works perfectly!!!
 
I have one more question, can You repair this script, it is for "lvl to lvl door"

Code:
[COLOR="darkgreen"]function onUse(cid, item, fromPosition, itemEx, toPosition)
	local k = getPlayerLevel(cid)
	if k >= 1 and k <= 13 then
		doTransformItem(item.uid, item.itemid + 1)
		doTeleportThing(cid, toPosition, true)
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Players from lvl 1 to lvl 13 can pass this door.')
	end
	return true
end[/COLOR]

All works, but when someone stay on this door and "klick" to close then the door don't close but it will be created a next item (.itemid + 1). How to repair this?


wxijc1oo0iubglqkuqo.png
kexnnp4gptcpow04802e.png
bk17il1dt8ez18chy386.png
tc31e94anbys9s5jl827.png
 
Last edited:
Back
Top