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

[HELP]Lever creates npc

anytime123

New Member
Joined
Sep 28, 2011
Messages
7
Reaction score
0
Hi, im brazilian tibia lover and im new in this forum!
i need help to create one script!

Script:
my request is when the player is upon the floor, put "X" item on the altar in front and pull the lever then summon the npc and removes the item he placed on the altar.

When he leaves the floor the NPC disappears.


Here is the image for a better understanding:
imagemdotopico.jpg


Sorry for grammar errors.
 
Not tested


LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local c = {
		standPos = {x=1000, y=1000, z=1000}, -- Position player stands to use lever.
		itemPos = {x=1000, y=1000, z=1000, stackpos=255}, -- Position of the place item is put.
		itemID = 2160, -- ID of the item they need on the itemPos position.
		itemAmount = 10, -- Amount they need.
		lever = 1337, -- ActionID of the lever. 
		npcName = "Tony", -- NPC name to spawn.
		npcPos = {x=1000, y=1000, z=1000} -- Position of NPC
	}
	
local functions = {
		 getPos = getThingfromPos(c.itemPos)	
		 
		}
if getPlayerPosition(cid, c.standPos) and getThingfromPos(c.itemPos) == true then
	if(item.actionid == c.lever) then
		if functions.getPos.itemid == c.itemID and functions.getPos.type >= c.itemAmount then
			doTransformItem(item.uid, 1946)		
				doRemoveItem(functions.getPos.uid, c.itemAmount)
					doSendMagicEffect(c.itemPos, CONST_ME_POFF)
						doCreateNpc(c.npcName, c.npcPos)
	else
		doPlayerSendCancel(cid,"Sorry, you need a specific item to use this lever!")
		return true
			end
		end
	end
end
if getPlayerPostion(cid, c.standPos) == false then
       doRemoveCreature(c.npcName)
end
 
Hi!! thnks for try to help me! but an error has occurred:

Error-action interface
data/actions/scripts/leversummonnpc.lua:31:attempt to index global 'c'<a nil value>
 
Last edited:
We can try two scripts

this one creates the NPC: (Action script)
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local c = {
		standPos = {x=1000, y=1000, z=1000}, -- Position player stands to use lever.
		itemPos = {x=1000, y=1000, z=1000, stackpos=255}, -- Position of the place item is put.
		itemID = 2160, -- ID of the item they need on the itemPos position.
		itemAmount = 10, -- Amount they need.
		lever = 1337, -- ActionID of the lever. 
		npcName = "Tony", -- NPC name to spawn.
		npcPos = {x=1000, y=1000, z=1000} -- Position of NPC
	}
	
local functions = {
		 getPos = getThingfromPos(c.itemPos)	
		 
		}
if getPlayerPosition(cid, standPos) and getThingfromPos(c.itemPos) == true then
	if(item.actionid == c.lever) then
		if functions.getPos.itemid == c.itemID and functions.getPos.type >= c.itemAmount then
			doTransformItem(item.uid, 1946)		
				doRemoveItem(functions.getPos.uid, c.itemAmount)
					doSendMagicEffect(c.itemPos, CONST_ME_POFF)
						doCreateNpc(c.npcName, c.npcPos)
	else
		doPlayerSendCancel(cid,"Sorry, you need a specific item to use this lever!")
		return true
			end
		end
	end
end

This one removes the NPC: (Movement script)
LUA:
function onStepOut(cid, item, frompos, itemEx, topos)

local c = {
		standPos = {x=1000, y=1000, z=1000}, -- Position if not here remove NPC
		npcName = "Tony"
	}

if getCreaturePosition(cid, c.standPos) == false then
doRemoveCreature(c.npcName)
return true
end
end
 
1. what i put in the movements XML code?
2. an error has occurred in the movements script:
10: '<eof>' expected near 'end'
3. the first script, action script, didnt nothing. I went to the floor, put the item in the place, pulled the lever and nothing happened.
 
Last edited:
Back
Top