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

[8.5] [Action] Teleport scroll, need help. Event error

Moj mistrz

Monster Creator
Joined
Feb 1, 2008
Messages
932
Solutions
10
Reaction score
308
Location
Poland
Hi, i need help with that script. It is working, but when time is over teleport wont remove. Down ill give ya script and error in console.

local function deleteTeleport()
local tp = getTileItemById(position, 1387).uid
doSendMagicEffect(position, CONST_ME_POFF)
doRemoveItem(tp)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
local pos = { x=2395, y=1904, z=7 }
local tpTime = 30
local tpID = 1387
local position = { x=2395, y=1906, z=7 }

doCreateTeleport(tpID, pos, position)
doSendMagicEffect(position, CONST_ME_MAGIC_GREEN)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have ".. tpTime .." seconds until the portal

will disapear.")
doPlayerSay(cid, "You have ".. tpTime .." seconds until the portal will disapear.",

TALKTYPE_ORANGE_1)

addEvent(deleteTeleport, tpTime * 1000)
doRemoveItem(item.uid,1)

return TRUE
end

ERROR.
[05/12/2009 22:00:37] Lua Script Error: [Action Interface]
[05/12/2009 22:00:37] in a timer event called from:
[05/12/2009 22:00:37] data/actions/scripts/teleport.lua:onUse

[05/12/2009 22:00:37] attempt to index a nil value
[05/12/2009 22:00:37] stack traceback:
[05/12/2009 22:00:37] [C]: in function 'getTileItemById'
[05/12/2009 22:00:38] data/actions/scripts/teleport.lua:2: in function <data/actions/scripts/teleport.lua:1>
Thanks for help.
 
I have second problem.
local function deleteTeleport()
local position = { x=2395, y=1906, z=7 }
local tp = getTileItemById(position, 1387).uid
doSendMagicEffect(position, CONST_ME_POFF)
doRemoveItem(tp)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
local pos = { x=2395, y=1904, z=7 } --tp destination
local tpTime = 30
local tpID = 1387
local position = { x=2395, y=1906, z=7 } --position of tp

if isPlayer(itemEx.uid) == TRUE then
end
if((not(isDruid(itemEx.uid)) or getPlayerLevel(itemEx.uid) < 50) and getPlayerCustomFlagValue(itemEx.uid,

PlayerCustomFlag_GamemasterPrivileges) == FALSE) then
doCreatureSay(itemEx.uid, "Only druids of level 50 or above may use this portal scroll.",

TALKTYPE_ORANGE_1)
return TRUE
end

doCreateTeleport(tpID, pos, position)
doSendMagicEffect(position, CONST_ME_MAGIC_GREEN)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have ".. tpTime .." seconds until the portal

will disapear.")
doPlayerSay(cid, "You have ".. tpTime .." seconds until the portal will disapear.",

TALKTYPE_ORANGE_1)

addEvent(deleteTeleport, tpTime * 1000)
doRemoveItem(item.uid,1)

return TRUE
end

[05/12/2009 22:55:19] Lua Script Error: [Action Interface]
[05/12/2009 22:55:19] data/actions/scripts/teleport.lua:onUse

[05/12/2009 22:55:19] internalGetPlayerInfo(). Player not found

[05/12/2009 22:55:19] Lua Script Error: [Action Interface]
[05/12/2009 22:55:19] data/actions/scripts/teleport.lua:onUse

[05/12/2009 22:55:19] luaGetPlayerCustomFlagValue(). Player not found

[05/12/2009 22:55:19] Lua Script Error: [Action Interface]
[05/12/2009 22:55:19] data/actions/scripts/teleport.lua:onUse

[05/12/2009 22:55:19] luaDoCreatureSay(). Creature not found

I want that scroll for druids of level 50 or higher. Help :)!
 
Stop Spamming Forum?

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local tpTime = 30
local tpID = 1387
local cPos = { x=2395, y=1906, z=7 } -- Create
local tPos = { x=2395, y=1904, z=7 } -- To

local function deleteTeleport()
    getTileItemById(1387, cPos).uid > 0 and doRemoveItem(getTileItemById(1387, cPos).uid), doSendMagicEffect(cPos, CONST_ME_POFF)
end

	if getTileItemById(1387, cPos).uid == true then
		doPlayerSendCancel(cid, "The teleport already exists.")
	else
		doCreateTeleport(tpID, tPos, cPos)
		doSendMagicEffect(cPos, CONST_ME_MAGIC_GREEN)
		doCreatureSay(getCreaturePosition(cid), "You have ".. tpTime .." seconds until the portal will disapear.", TALKTYPE_ORANGE_1)
		addEvent(deleteTeleport, tpTime * 1000, cid)
		doRemoveItem(item.uid)
		return true
	end
end
 
Minor fixes,
Code:
local t = {
	tpTime = 30,
	tpID = 1387,
	cPos = {x=2395, y=1906, z=7}, -- Create
	tPos = {x=2395, y=1904, z=7} -- To
}
local function deleteTeleport()
	return getTileItemById(1387, cPos).uid > 0 and doRemoveItem(getTileItemById(1387, cPos).uid) and doSendMagicEffect(cPos, CONST_ME_POFF)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
	return TRUE, getTileItemById(1387, cPos).uid > 0 and doPlayerSendCancel(cid, "The teleport already exists.") or doCreateTeleport(tpID, tPos, cPos) and doSendMagicEffect(cPos, CONST_ME_MAGIC_GREEN) and doCreatureSay(cid, "You have ".. tpTime .." seconds until the portal disapears.", TALKTYPE_ORANGE_1) and addEvent(deleteTeleport, tpTime * 1000) and doRemoveItem(item.uid)
end
 
Back
Top