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

wall by removing time

hyz

Member
Joined
Oct 30, 2008
Messages
39
Reaction score
19
I need help because I put the action on my server and did not work following error message.

Code:
[14/10/2009 10:49:17] data/actions/scripts/wallremoving.lua:13: attempt to call global 'getThingFromPos' (a nil value)
[14/10/2009 10:49:17] stack traceback:
[14/10/2009 10:49:17] 	data/actions/scripts/wallremoving.lua:13: in function <data/actions/scripts/wallremoving.lua:4>

and here is the script

Code:
local wallPos = {x=205, y=55, z=7, stackpos=1} -- Position of the wall
    doCreateItem(3432, 1, wallPos) -- Replace 1112 to the ID of your wall

function onUse(cid, item, frompos, item2, topos)
local config = {
        removeMessage = "You removed a wall!", -- Message when you remove the wall
        createMessage = "You created a wall!", -- Message when you create the wall
        wallPos = {x=205, y=55, z=7, stackpos=1}, -- Position of the wall
        switchUID = 1337, -- Unique ID of the switch
        timer = 1*60*1000 -- After how long time the wall should be created again after using the switch 
        }
            
local getWall = getThingFromPos(config.wallPos)
    if item.uid == switchUID then
        doRemoveItem(getWall.uid, 1)
        doPlayerSendTextMessage(cid, 19, config.removeMessage)
        doTransformItem(item.uid, item.itemid+1)
        addEvent(createWall, config.timer)
    end
  end

My server is TFS 8.42
 
getThingfromPos is deprecated, getTileItemById should be used here.
A more advanced version with events:
Code:
local config = {
	removeMessage = "You removed a wall!",
	createMessage = "You created a wall!",
	wallPos = {x=205, y=55, z=7},
	wallId = 3432,
	timer = 60 -- in seconds
}
local event = 0

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local getWall = getTileItemById(config.wallPos, config.wallId).uid
	if item.itemid == 1945 then
		stopEvent(event)
		if getWall > 0 then
			doRemoveItem(getWall)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.removeMessage)
			event = addEvent(doCreateItem, config.timer * 1000, config.wallId, 1, config.wallPos)
		end
		doTransformItem(item.uid, 1946)
	elseif item.itemid == 1946 then
		stopEvent(event)
		if getWall == 0 then
			doCreateItem(config.wallId, 1, config.wallPos)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.removeMessage)
		end
		doTransformItem(item.uid, 1945)
	end
	return TRUE
end
 
Last edited:
tfs 0.3.6

not work,:huh:give error in console.

PHP:
local config = {
	removeMessage = "You removed a wall!",
	createMessage = "You created a wall!",
	wallPos = {x=205, y=55, z=7},
	wallId = 3432,
	timer = 60 -- in seconds
}
local event = 0

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local getWall = getTileItemById(config.wallPos, config.wallId).uid
	if item.itemid == 1945 then
		stopEvent(event)
		if getWall > 0 then
			doRemoveItem(getWall)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.removeMessage)
			event = addEvent(doCreateItem, config.timer * 1000, wallId, 1, wallPos)
		end
		doTransformItem(item.uid, 1946)
	elseif item.itemid == 1946 then
		stopEvent(event)
		if getWall == 0 then
			doCreateItem(wallId, 1, wallPos)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, config.removeMessage)
		end
		doTransformItem(item.uid, 1945)
	end
	return TRUE
end

[error - action interface ]

attenmpt to index a nil value

[c] in function 'doCreateItem'
 
Last edited:
gives this error and console

[Error -action interface]
data/actions/scripts/rook/rook_4.lua:onUse
Description:
attempt to index a nil value
strack traceback:
[C]: in function 'doCreateItem'

data/actions/scripts/rook/rook_4.lua:23: in function <data/actions/scripts/rook/rook_4.lua:10>
 
gives this error and console

[Error -action interface]
data/actions/scripts/rook/rook_4.lua:onUse
Description:
attempt to index a nil value
strack traceback:
[C]: in function 'doCreateItem'

data/actions/scripts/rook/rook_4.lua:23: in function <data/actions/scripts/rook/rook_4.lua:10>
you copied wrong.

http://otland.net/599584-post3.html
 
Last edited:
Back
Top